ClassCastException « Query « JPA Q&A





1. Query Level 2 Caching throwing ClassCastException    stackoverflow.com

I am using JPA and Hibernate for the database. I have configured (EHCacache) second level cache and query level cache, but just to make sure that caching is working I was ...

2. HQL for select two columns from one table    stackoverflow.com

I want to select two columns from a table. I m writing this query:- select c.custName, c.city from CustomerTab as c order by c.custName this hql is working fine but when i m ...

3. Hibernate createQuery() throws ClassCastException, Transformer doesn't help    stackoverflow.com

Trying to SELECT an entity using Using Hibernate 3.6 and MySQL5.1 but I keep getting a ClassCastException.

@Entity
@Table( name = "USER" )
public class User {
   @Id
   @Column(name= "user_id")
 ...

4. ClassCastException in find    forum.hibernate.org

java.lang.ClassCastException:iunique.model.Subscription cannot be cast to iunique.model.Subscription at iunique.service.ServicesManagerImpl.findSubscriptionByMSISDN(ServicesManagerImpl.java:56) at iunique.service.ServicesManagerImpl.getActiveServices(ServicesManagerImpl.java:97) at java.lang.reflect.Method.invoke(Method.java:597) at org.apache.wicket.proxy.LazyInitProxyFactory$JdkHandler.invoke(LazyInitProxyFactory.java:416) at org.apache.wicket.proxy.$Proxy18.getActiveServices(Unknown Source) at iunique.web.status.ServiceList.(ServiceList.java:29) at java.lang.reflect.Constructor.newInstance(Constructor.java:513) at org.apache.wicket.session.DefaultPageFactory.createPage(DefaultPageFactory.java:188) at org.apache.wicket.session.DefaultPageFactory.newPage(DefaultPageFactory.java:89) at org.apache.wicket.request.target.component.BookmarkablePageRequestTarget.newPage(BookmarkablePageRequestTarget.java:305) at org.apache.wicket.request.target.component.BookmarkablePageRequestTarget.getPage(BookmarkablePageRequestTarget.java:320) at org.apache.wicket.request.target.component.BookmarkablePageRequestTarget.processEvents(BookmarkablePageRequestTarget.java:234) at org.apache.wicket.request.AbstractRequestCycleProcessor.processEvents(AbstractRequestCycleProcessor.java:92) at org.apache.wicket.RequestCycle.processEventsAndRespond(RequestCycle.java:1250) at org.apache.wicket.RequestCycle.step(RequestCycle.java:1329) at org.apache.wicket.RequestCycle.steps(RequestCycle.java:1428) at org.apache.wicket.RequestCycle.request(RequestCycle.java:545) at org.apache.wicket.protocol.http.WicketFilter.doGet(WicketFilter.java:479) at org.apache.wicket.protocol.http.WicketFilter.doFilter(WicketFilter.java:312) at org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:235) at org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:206) at org.apache.catalina.core.StandardWrapperValve.invoke(StandardWrapperValve.java:233) at org.apache.catalina.core.StandardContextValve.invoke(StandardContextValve.java:191) at org.apache.catalina.core.StandardHostValve.invoke(StandardHostValve.java:127) at org.apache.catalina.valves.ErrorReportValve.invoke(ErrorReportValve.java:102) at org.apache.catalina.core.StandardEngineValve.invoke(StandardEngineValve.java:109) at org.apache.catalina.connector.CoyoteAdapter.service(CoyoteAdapter.java:298) ...

5. Count do not work java.lang.ClassCastException    forum.hibernate.org

6. ClassCastException with order-by and SortedSet    forum.hibernate.org

I'm having troubles using the order-by attribute of the tag with Hibernate 2 and JDK 1.4 I've got a class (referred to as MyClassDTO in the mapping below) that contains a collection defined as a SortedSet MyClassDTO contains the attributes String objId String name SortedSet approvals (initialized to a new TreeSet() ) The objects placed in the collection are ApprovalDTO ...

7. session.refresh() causes ClassCastException    forum.hibernate.org

Author Message keviny Post subject: session.refresh() causes ClassCastException Posted: Mon Mar 08, 2004 2:30 am Beginner Joined: Wed Aug 27, 2003 6:15 am Posts: 22 Hi all I've tested this with Hibernate 2.1.1 and 2.1.2 and yielded the same result. The DB is Oracle 9.2.0.3.0. What I've done is simply use session.load(Class, Serializable) to load an object and refresh ...

8. ClassCastException in sorted Set    forum.hibernate.org

OK. I am trying to provide some sorting for collections which result from many-to-many relationships. I have seen previous posts which suggest that the DB "order-by" attribute of a collection mapping does not apply to objects in the "child" half of a M2M relationship, and that this behaviour is "not supported" (this is a little irritating actually). So, as a second ...

9. ClassCastException in method next() of ScrollableResults    forum.hibernate.org

Hibernate version:2.1.7 Mapping documents: Code between sessionFactory.openSession() and session.close(): Code: try{ Session hibSess = ks.getHibernateSession(); Query query = hibSess.createQuery(strBuffQuery.toString()); ...





10. Error using named query: ClassCastException    forum.hibernate.org

Hi all, I've found an error using named queries with hibernate 3 beta 4 (CVS today checkout). I've tracked down the problem to the class org.hibernate.hql.ast.SyntheticAndFactory(line 44): Code: fragment = ( SqlFragment ) ASTUtil.create( astFactory, SQL_TOKEN, whereFragment ); but the method returns AST object (org.hibernate.hql.ast.ASTUtil:34): ...

11. ClassCastException when finding a Long value    forum.hibernate.org

Newbie Joined: Fri Mar 11, 2005 2:03 am Posts: 4 I'm getting a ClassCastException when I'm trying to select with the "displayId" as part of the criteria. If I only add the "itemName" to the criteria, everything works fine. Any ideas? Hibernate version: 2.1.8 Mapping documents: @hibernate.property column="REQ_DISPLAYED_ID" unique="true" length="22" not-null="true" ...

13. ClassCastException when using Query By Example    forum.hibernate.org

Regular Joined: Thu Jul 08, 2004 1:21 pm Posts: 68 Location: Recife - Pernambuco - Brazil Hi, I am getting a exception when trying to use query by example for a simple component. I haven't get this before, and I could not see where is the error. I am using Hibernate Annotations support for tests purpose. The information about error is ...

14. many-to-one classCastException on query.    forum.hibernate.org

Newbie Joined: Thu Mar 24, 2005 10:07 am Posts: 14 Need help with Hibernate? Read this first: http://www.hibernate.org/ForumMailingli ... AskForHelp Im really hoping someone can help me. This might be a newbie question but I have a situation where I fear there will be performance issues. I have an auction scenario. An Auction contains a Set of Bids. Bids are tied ...

15. Confused by behavior of Subqueries.in(); ClassCastException    forum.hibernate.org

Been working with Hibernate for a while now, but until recently I haven't had to dig very deeply into the Criteria queries stuff. Now I do, and it looks like the manual has been updated fairly recently - I don't remember seeing the stuff on Subqueries the last time I looked a few months ago. I thought I understood from the ...

16. Adding then Removing Projection causes ClassCastException    forum.hibernate.org

@Entity @Table(name="users") @SequenceGenerator(name="seq_users",sequenceName="seq_users") public class User extends BaseEntity { @Override @Id @GeneratedValue(strategy=GenerationType.SEQUENCE, generator="seq_users") public Long getId() { return super.getId(); } @Column(nullable=false,unique=true,length=32) public String getUsername() { return username; } }





17. ClassCastException using sort= for Tr    forum.hibernate.org

I have the following as part of my definition of a FilterField: Code: private Set details; private Comparator comparator = new FilterFieldDetailComparator(); public FilterField() { details = new TreeSet(comparator); } The relevant part of the hibernate mapping file I have shows: Code: ...

18. ClassCastException trying to cache sql query    forum.hibernate.org

I'm getting a class cast exception when trying to cache a sql query that returns a count. The query works just fine if I don't try and cache it. Here's the code that causes it. Session hSession = HibernateSessionFactory.getSession(); java.math.BigDecimal rc = (java.math.BigDecimal)hSession.createSQLQuery( "SELECT COUNT(DISTINCT ac_cc_id)"+ " FROM attorney_case ac "+ " JOIN consumer_case_category_xref cccx ON ac.ac_cc_id=cccx.cccx_cc_id "+ " JOIN category_to_users ...

19. ClassCastException sort    forum.hibernate.org

Im having an object that contains a list of replys. as long as the replys were not sorted anything went fine. but as soon as i added the sort attribute as shown bolow I got an ClassCastExcption when trying to load the object. Mapping (extract) (I'm ...

20. ClassCastException when performing a SELECT i.e. session.get    forum.hibernate.org

Hibernate version:3.0.5 Name and version of the database you are using: Oracle 10g Ok, I'm having touble with preforming a select, i.e. with session.get I dropped all my tables and created a small one just to try and figure out what's the problem, with no luck. Notice that I succeed on INSERT, i.e. session.persist, though fail in the SELECT. My bean ...

21. ClassCastException on a simple query    forum.hibernate.org

birwin Post subject: Posted: Thu Nov 30, 2006 12:22 pm Newbie Joined: Wed Nov 29, 2006 6:55 pm Posts: 10 Exception (From JBoss log file): Code: 2006-11-30 09:18:12,001 DEBUG [org.hibernate.engine.TwoPhaseLoad] done materializing entity [com.sosstaffing.trax.persistence.biolynx.Client#5133] 2006-11-30 09:18:12,001 DEBUG [org.hibernate.engine.StatefulPersistenceContext] initializing non-lazy collections 2006-11-30 09:18:12,001 DEBUG [org.hibernate.loader.Loader] done entity load 2006-11-30 09:18:12,001 ERROR [STDERR] java.lang.ClassCastException: com.sosstaffing.trax.persistence.biolynx.Client 2006-11-30 09:18:12,001 ERROR [STDERR] ...

22. ClassCastException using count    forum.hibernate.org

Hi, I am trying to get the count using HQL. This is my code: Integer id = (Integer)session.createQuery("select count(*) from Orders").uniqueResult(); When i try to cast the return value as Integer i get a ClassCastException java.lang.ClassCastException: java.lang.Long It works fine if i cast to a Long. Is there any problem with the code? Any help is appreciated Thanks in advance

23. ClassCastException when using Criteria query    forum.hibernate.org

24. ClassCastException when using Criteria query    forum.hibernate.org

25. Named query ClassCastException on Short param    forum.hibernate.org

public List findByCriteriaForPryzwyz(Integer artNr, Short shortNr ) { return getHibernateTemplate().findByNamedQueryAndNamedParam( "ThisIsAQuery", new String[] { "artNr", "shortNr" }, new Object[] { artNr, shortNr }); ...

26. ClassCastException while using count(*) in HQL query    forum.hibernate.org

Hi, I am using Hibernate 3.3.1 GA version for one of my project. I am getting following exception while using "count()" agreegate function. "java.lang.ClassCastException: java.lang.Long cannot be cast to java.lang.Integer" Following is the sample code that I have written for testing count() function: Code in TestDAO: ===================================== String strQuery = "Select count(empId) as empCount from TbTestEmp where deptNo = ?"; Query ...

27. help with createSQLQuery, getting ClassCastException    forum.hibernate.org

Hi, I have 2 entities with a join condition on column BOOK_ID. One is Chapter, which has its own BOOK_ID column and one is Book whose getId() column is also BOOK_ID. Note that I have not done a many-to-one mapping on Chapter.BOOK_ID to let Hibernate know about the possible join. I'm trying to use createSQLQuery: select c.CHAPTER_ID, (b.*) from CHAPTERS c ...