Hibernate version: 3.13
Hello,
i want create a disjunction on a criteria which create a joint on object which is composed of a composite-id and containig in a list...(see Cisp_Concept_RelationConcep mapping)...
for a simple object used in a one-to-many association it's ok,
but for this object it's KO...
Mapping documents:
Concept.hbm.xml :
Code:
[...]
<bag name="cispClassification_relationConcept_set"
lazy="true"
cascade="all-delete-orphan" inverse="true">
<key column="concept_id"/>
<one-to-many class="com.vidal.bo.model.thesaurus.concept.classification.Cisp_Concept_RelationConcept"/>
</bag>
[...]
Cisp_Concept_RelationConcept.hbm.xml :Code:
<class name="com.vidal.bo.model.thesaurus.concept.classification.Cisp_Concept_RelationConcept"
table="cispClassification_concept_relationConcept">
<composite-id>
<key-many-to-one lazy="false" name="concept" class="com.vidal.bo.model.thesaurus.concept.Concept"
column="concept_Id"/>
<key-many-to-one lazy="false" name="cispClassification" class="com.vidal.bo.model.dictionary.classification.CispClassification"
column="cispClassification_Id"/>
<key-many-to-one lazy="false" name="relationConcept"
class="com.vidal.bo.model.dictionary.thesaurus.concept.RelationConcept"
column="relationConcept_Id"/>
</composite-id>
<property name="processStatus" column="processStatus" type="int" />
<property name="typeResearch" type="yes_no" column="isTypeResearch" />
<property name="typeAlert" type="yes_no" column="isTypeAlert" />
</class>
CispClassification.hbm.xml :Code:
<class name="com.vidal.bo.model.dictionary.classification.CispClassification"
table="cispClassification">
<id name="id" column="cispClassification_id" type="long">
<generator class="identity" />
</id>
<property name="name" type="string" column="name" />
<property name="code" type="string" column="code" />
<property name="ranking" type="long" column="ranking" />
<many-to-one name="parent" column="parentId" lazy="false" not-null="false"
class="com.vidal.bo.model.dictionary.classification.CispClassification"/>
<set name="children" inverse="false" cascade="none"
lazy="false">
<key column="parentId" />
<one-to-many
class="com.vidal.bo.model.dictionary.classification.CispClassification" />
</set>
Code between sessionFactory.openSession() and session.close():Code:
try {
// main criteria
Criteria executableCriteria = this.getSession().createCriteria(Concept.class);
// value to search in concept name or lexicalALternative name
String valueToSearch = concept.getName();
// Criterion list
List<Criterion> criterions = new ArrayList<Criterion>();
if ( concept.getSemanticLabel() != null ) {
executableCriteria.createCriteria("semanticLabel", "sl", Criteria.LEFT_JOIN);
executableCriteria.createCriteria("sl.conceptType", "ct", Criteria.LEFT_JOIN);
criterions.add(Expression.eq("ct.name", concept.getSemanticLabel().getConceptType().getName()));
}
else {
criterions.add(Expression.like("this.name", valueToSearch, MatchMode.ANYWHERE));
// ====================================
// ======= Advanced search ============
// ====================================
[...]
// this is the code for the joint disjunction on a list...
// CISP
else if ( concept.getCispClassification_relationConcept_set().size() != 0 ) {
executableCriteria.createCriteria("cispClassification_relationConcept_set", "ccr", Criteria.LEFT_JOIN);
executableCriteria.createCriteria("ccr.cispClassification", "cisp", Criteria.FULL_JOIN);
criterions.add(Expression.eq("cisp.name", concept.getCispClassification_relationConcept_set().get(0).getCispClassification()
.getName()));
}
[...]
}
// ====================================
// ===== On compléte le critéria ======
// ====================================
Disjunction disjunction = Expression.disjunction();
executableCriteria.add(disjunction);
executableCriteria.setResultTransformer(CriteriaSpecification.DISTINCT_ROOT_ENTITY);
for ( Criterion c : criterions )
disjunction.add(c);
// ====================================
// ========== Execute query ===========
// ====================================
List<Concept> result = executableCriteria.list();
logger.info("findByExampleConcept [" + Concept.class.getSimpleName() + "]");
return result;
Stack trace: Code:
Hibernate: select this_.concept_id as concept1_129_1_, this_.name as name129_1_, this_.semanticLabel_id as semantic3_129_1_, ccr1_.concept_id as concept1_3_, ccr1_.cispClassification_Id as cispClas2_3_, ccr1_.relationConcept_Id as relation3_3_, ccr1_.concept_Id as concept1_132_0_, ccr1_.cispClassification_Id as cispClas2_132_0_, ccr1_.relationConcept_Id as relation3_132_0_, ccr1_.processStatus as processS4_132_0_, ccr1_.isTypeResearch as isTypeRe5_132_0_, ccr1_.isTypeAlert as isTypeAl6_132_0_ from concept this_ left outer join cispClassification_concept_relationConcept ccr1_ on this_.concept_id=ccr1_.concept_id where (this_.name like ? or cisp2_.name=?)
2007-01-19 17:26:55,240 WARN [org.springframework.remoting.support.RemoteInvocationTraceInterceptor] - Processing of RmiServiceExporter remote call resulted in fatal exception: com.vidal.bo.service.thesaurus.concept.IConceptManager.findByExampleEntity
org.hibernate.exception.GenericJDBCException: could not execute query
at org.hibernate.exception.SQLStateConverter.handledNonSpecificException(SQLStateConverter.java:103)
at org.hibernate.exception.SQLStateConverter.convert(SQLStateConverter.java:91)
at org.hibernate.exception.JDBCExceptionHelper.convert(JDBCExceptionHelper.java:43)
at org.hibernate.loader.Loader.doList(Loader.java:2148)
at org.hibernate.loader.Loader.listIgnoreQueryCache(Loader.java:2029)
at org.hibernate.loader.Loader.list(Loader.java:2024)
at org.hibernate.loader.criteria.CriteriaLoader.list(CriteriaLoader.java:94)
at org.hibernate.impl.SessionImpl.list(SessionImpl.java:1533)
at org.hibernate.impl.CriteriaImpl.list(CriteriaImpl.java:283)
at com.vidal.bo.dao.thesaurus.concept.ConceptDAO.findByExampleConcept(ConceptDAO.java:109)
at com.vidal.bo.service.thesaurus.concept.ConceptManager.findByExampleEntity(ConceptManager.java:153)
at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
at sun.reflect.NativeMethodAccessorImpl.invoke(Unknown Source)
at sun.reflect.DelegatingMethodAccessorImpl.invoke(Unknown Source)
at java.lang.reflect.Method.invoke(Unknown Source)
at org.springframework.aop.support.AopUtils.invokeJoinpointUsingReflection(AopUtils.java:287)
at org.springframework.aop.framework.ReflectiveMethodInvocation.invokeJoinpoint(ReflectiveMethodInvocation.java:181)
at org.springframework.aop.framework.ReflectiveMethodInvocation.proceed(ReflectiveMethodInvocation.java:148)
at org.springframework.transaction.interceptor.TransactionInterceptor.invoke(TransactionInterceptor.java:96)
at org.springframework.aop.framework.ReflectiveMethodInvocation.proceed(ReflectiveMethodInvocation.java:170)
at org.springframework.aop.framework.JdkDynamicAopProxy.invoke(JdkDynamicAopProxy.java:176)
at $Proxy36.findByExampleEntity(Unknown Source)
at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
at sun.reflect.NativeMethodAccessorImpl.invoke(Unknown Source)
at sun.reflect.DelegatingMethodAccessorImpl.invoke(Unknown Source)
at java.lang.reflect.Method.invoke(Unknown Source)
at org.springframework.aop.support.AopUtils.invokeJoinpointUsingReflection(AopUtils.java:287)
at org.springframework.aop.framework.ReflectiveMethodInvocation.invokeJoinpoint(ReflectiveMethodInvocation.java:181)
at org.springframework.aop.framework.ReflectiveMethodInvocation.proceed(ReflectiveMethodInvocation.java:148)
at org.springframework.remoting.support.RemoteInvocationTraceInterceptor.invoke(RemoteInvocationTraceInterceptor.java:68)
at org.springframework.aop.framework.ReflectiveMethodInvocation.proceed(ReflectiveMethodInvocation.java:170)
at org.springframework.aop.framework.JdkDynamicAopProxy.invoke(JdkDynamicAopProxy.java:176)
at $Proxy36.findByExampleEntity(Unknown Source)
at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
at sun.reflect.NativeMethodAccessorImpl.invoke(Unknown Source)
at sun.reflect.DelegatingMethodAccessorImpl.invoke(Unknown Source)
at java.lang.reflect.Method.invoke(Unknown Source)
at org.springframework.remoting.support.RemoteInvocation.invoke(RemoteInvocation.java:179)
at org.springframework.remoting.support.DefaultRemoteInvocationExecutor.invoke(DefaultRemoteInvocationExecutor.java:33)
at org.springframework.remoting.support.RemoteInvocationBasedExporter.invoke(RemoteInvocationBasedExporter.java:76)
at org.springframework.remoting.rmi.RmiBasedExporter.invoke(RmiBasedExporter.java:72)
at org.springframework.remoting.rmi.RmiInvocationWrapper.invoke(RmiInvocationWrapper.java:62)
at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
at sun.reflect.NativeMethodAccessorImpl.invoke(Unknown Source)
at sun.reflect.DelegatingMethodAccessorImpl.invoke(Unknown Source)
at java.lang.reflect.Method.invoke(Unknown Source)
at sun.rmi.server.UnicastServerRef.dispatch(Unknown Source)
at sun.rmi.transport.Transport$1.run(Unknown Source)
at java.security.AccessController.doPrivileged(Native Method)
at sun.rmi.transport.Transport.serviceCall(Unknown Source)
at sun.rmi.transport.tcp.TCPTransport.handleMessages(Unknown Source)
at sun.rmi.transport.tcp.TCPTransport$ConnectionHandler.run(Unknown Source)
at java.lang.Thread.run(Unknown Source)
Caused by: java.sql.SQLException: L'identificateur en plusieurs parties 'cisp2_.name' ne peut pas être lié.
at net.sourceforge.jtds.jdbc.SQLDiagnostic.addDiagnostic(SQLDiagnostic.java:365)
at net.sourceforge.jtds.jdbc.TdsCore.tdsErrorToken(TdsCore.java:2781)
at net.sourceforge.jtds.jdbc.TdsCore.nextToken(TdsCore.java:2224)
at net.sourceforge.jtds.jdbc.TdsCore.getMoreResults(TdsCore.java:628)
at net.sourceforge.jtds.jdbc.JtdsStatement.executeSQLQuery(JtdsStatement.java:418)
at net.sourceforge.jtds.jdbc.JtdsPreparedStatement.executeQuery(JtdsPreparedStatement.java:693)
at org.hibernate.jdbc.AbstractBatcher.getResultSet(AbstractBatcher.java:139)
at org.hibernate.loader.Loader.getResultSet(Loader.java:1669)
at org.hibernate.loader.Loader.doQuery(Loader.java:662)
at org.hibernate.loader.Loader.doQueryAndInitializeNonLazyCollections(Loader.java:224)
at org.hibernate.loader.Loader.doList(Loader.java:2145)
... 49 more
In fact there isn't the joint with table : cispClassification !!!!
Help ;)