Hibernate and JPA implementation.
I am using Criteria query to create dynamic query. My generated query as bellow.
select entity1.*,entity2.*,entity3.* from entity1 this_, entity2 entity2_1_, entity3 entity3_2_ where this_.column=entity2_1_.column and entity2_1_.column=entity3_2_.column(+) and this_.xxxxx = ? and this_.xxxxx = ? and this_.xxxxx = ?
Collection<entity1> xxxx = (Collection<entity1>)Criteria.list();
Getting Exception :
java.lang.ClassCastException: com.xxx.xxx..persistence.pojo.entity2E at org.hibernate.type.ComponentType.toLoggableString(ComponentType.java:400) at org.hibernate.pretty.MessageHelper.collectionInfoString(MessageHelper.java:307) at org.hibernate.loader.Loader.readCollectionElement(Loader.java:1008) at org.hibernate.loader.Loader.readCollectionElements(Loader.java:669) at org.hibernate.loader.Loader.getRowFromResultSet(Loader.java:614) at org.hibernate.loader.Loader.doQuery(Loader.java:724) at org.hibernate.loader.Loader.doQueryAndInitializeNonLazyCollections(Loader.java:259) at org.hibernate.loader.Loader.doList(Loader.java:2228) at org.hibernate.loader.Loader.listIgnoreQueryCache(Loader.java:2125) at org.hibernate.loader.Loader.list(Loader.java:2120) at org.hibernate.loader.criteria.CriteriaLoader.list(CriteriaLoader.java:118) at org.hibernate.impl.SessionImpl.list(SessionImpl.java:1596) at org.hibernate.impl.CriteriaImpl.list(CriteriaImpl.java:306) at org.hibernate.impl.CriteriaImpl$Subcriteria.list(CriteriaImpl.java:481)
In hibernate log getting.
result row: EntityKey[com.xxx.xxx.persistence.pojo.entity2#component[column1,column2]{column1=value1, column2=value2}], EntityKey[com.xxx.xxx.persistence.pojo.entity3#component[column1,column2]{column1=value1, column2=value2}], EntityKey[com.xxx.xxx..persistence.pojo.entity1#value] Want to extract only entity1 from result row. Any help on this......
|