-->
These old forums are deprecated now and set to read-only. We are waiting for you on our new forums!
More modern, Discourse-based and with GitHub/Google/Twitter authentication built-in.

All times are UTC - 5 hours [ DST ]



Forum locked This topic is locked, you cannot edit posts or make further replies.  [ 2 posts ] 
Author Message
 Post subject: Criteria mit Many to Many Beziehung
PostPosted: Fri Nov 11, 2011 5:18 am 
Newbie

Joined: Fri Nov 11, 2011 4:44 am
Posts: 4
Hallo,

Ich habe eine "many to many" Beziehung zwichen Users und Projects:

@ManyToMany ( fetch = FetchType.EAGER )//Tipo de busqueda
@JoinTable(name="USERPROJECTS" //Tabla de intercambio
, joinColumns={@JoinColumn(name="IDUSER") //Llave foránea
}
, inverseJoinColumns={@JoinColumn(name="IDPROJECT") //Llave foránea
})
@Where( clause = "DELETIONDATE is null" )
private List<Project> projects;

und ich möchte eine Criteria machen, das manche Users züruckgibt. Eine der Konditionen ist, das der User in einen oder mehreren Projekten teilnihmt. Ich habe es so versucht:

criteria.add(Restrictions.in("projects", (List<Project>)projects));

und "projects" ist eine Liste die, die ausgewählte projekten für die IN Bedingung, enthält.

Aber ich bekomme die nächste SQLException:

org.hibernate.exception.GenericJDBCException
could not execute query
SQL
select this_.id as id1_7_, this_.deletionDate as deletion2_1_7_, this_.email as email1_7_, this_.lastNames as lastNames1_7_, this_.name as name1_7_, this_.newPasswordRequested as newPassw6_1_7_, this_.IDORGANIZATION as IDORGAN10_1_7_, this_.password as password1_7_, this_.role as role1_7_, this_.userName as userName1_7_, organizati2_.id as id0_0_, organizati2_.certifications as certific3_0_0_, organizati2_.comContact as comContact0_0_, organizati2_.comEmail as comEmail0_0_, organizati2_.comPhone as comPhone0_0_, organizati2_.deletionDate as deletion7_0_0_, organizati2_.name as name0_0_, organizati2_.techContact as techCont9_0_0_, organizati2_.techEmail as techEmail0_0_, organizati2_.techPhone as techPhone0_0_, organizati2_.address as address0_0_, organizati2_.cif as cif0_0_, organizati2_.DTYPE as DTYPE0_0_, projects3_.IDUSER as IDUSER1_9_, project4_.id as IDPROJECT9_, project4_.id as id3_1_, project4_.complianceRequestingReason as complian2_3_1_, project4_.complianceResolutionReason as complian3_3_1_, project4_.deletionDate as deletion4_3_1_, project4_.description as descript5_3_1_, project4_.expedientNo as expedien6_3_1_, project4_.finishDate as finishDate3_1_, project4_.lastVersionForCompliance_id as lastVer12_3_1_, project4_.name as name3_1_, project4_.IDORGANIZATION as IDORGAN13_3_1_, project4_.IDPOLICY as IDPOLICY3_1_, project4_.startDate as startDate3_1_, project4_.state as state3_1_, project4_.tentativeFinishDate as tentati11_3_1_, version5_.id as id8_2_, version5_.classes as classes8_2_, version5_.CREATORID as CREATORID8_2_, version5_.description as descript3_8_2_, version5_.errorReport as errorRep4_8_2_, version5_.functions as functions8_2_, version5_.highSeverityErrorCount as highSeve6_8_2_, version5_.internalFileName as internal7_8_2_, version5_.javadocs as javadocs8_2_, version5_.javadocsLines as javadocs9_8_2_, version5_.lineCount as lineCount8_2_, version5_.lowSeverityErrorCount as lowSeve11_8_2_, version5_.mediumSeverityErrorCount as mediumS12_8_2_, version5_.multipleComment as multipl13_8_2_, version5_.name as name8_2_, version5_.observations as observa15_8_2_, version5_.packages as packages8_2_, version5_.PROJECTID as PROJECTID8_2_, version5_.reviewDate as reviewDate8_2_, version5_.singleComment as singleC18_8_2_, version5_.state as state8_2_, pacouser6_.id as id1_3_, pacouser6_.deletionDate as deletion2_1_3_, pacouser6_.email as email1_3_, pacouser6_.lastNames as lastNames1_3_, pacouser6_.name as name1_3_, pacouser6_.newPasswordRequested as newPassw6_1_3_, pacouser6_.IDORGANIZATION as IDORGAN10_1_3_, pacouser6_.password as password1_3_, pacouser6_.role as role1_3_, pacouser6_.userName as userName1_3_, project7_.id as id3_4_, project7_.complianceRequestingReason as complian2_3_4_, project7_.complianceResolutionReason as complian3_3_4_, project7_.deletionDate as deletion4_3_4_, project7_.description as descript5_3_4_, project7_.expedientNo as expedien6_3_4_, project7_.finishDate as finishDate3_4_, project7_.lastVersionForCompliance_id as lastVer12_3_4_, project7_.name as name3_4_, project7_.IDORGANIZATION as IDORGAN13_3_4_, project7_.IDPOLICY as IDPOLICY3_4_, project7_.startDate as startDate3_4_, project7_.state as state3_4_, project7_.tentativeFinishDate as tentati11_3_4_, organizati8_.id as id0_5_, organizati8_.certifications as certific3_0_5_, organizati8_.comContact as comContact0_5_, organizati8_.comEmail as comEmail0_5_, organizati8_.comPhone as comPhone0_5_, organizati8_.deletionDate as deletion7_0_5_, organizati8_.name as name0_5_, organizati8_.techContact as techCont9_0_5_, organizati8_.techEmail as techEmail0_5_, organizati8_.techPhone as techPhone0_5_, organizati8_.address as address0_5_, organizati8_.cif as cif0_5_, organizati8_.DTYPE as DTYPE0_5_, policy9_.id as id2_6_, policy9_.criticalViolations as critical2_2_6_, policy9_.deletionDate as deletion3_2_6_, policy9_.description as descript4_2_6_, policy9_.majorViolations as majorVio5_2_6_, policy9_.minorViolations as minorVio6_2_6_, policy9_.name as name2_6_ from PacoUser this_ left outer join Organization organizati2_ on this_.IDORGANIZATION=organizati2_.id left outer join USERPROJECTS projects3_ on this_.id=projects3_.IDUSER left outer join Project project4_ on projects3_.IDPROJECT=project4_.id and ( project4_.DELETIONDATE is null) left outer join Version version5_ on project4_.lastVersionForCompliance_id=version5_.id left outer join PacoUser pacouser6_ on version5_.CREATORID=pacouser6_.id left outer join Project project7_ on version5_.PROJECTID=project7_.id left outer join Organization organizati8_ on project7_.IDORGANIZATION=organizati8_.id left outer join Policy policy9_ on project7_.IDPOLICY=policy9_.id where this_.deletionDate is null and this_.id in (?)
errorCode
17041
java.sql.SQLException

Falta el parámetro IN o OUT en el índice:: 1 -- Das heisst: In oder OUT Parameter sind im index 1 vermisst.

Kann mir jemand helfen? Was habe ich falsch gemacht?

Dankesehr!!


Top
 Profile  
 
 Post subject: Re: Criteria mit Many to Many Beziehung
PostPosted: Tue Nov 15, 2011 11:15 am 
Newbie

Joined: Fri Nov 11, 2011 4:44 am
Posts: 4
Ich habe die Lösung gefunden:

Criteria criteria = session.createCriteria(User.class);
criteria.add(Restrictions.isNull(COLUMN_DELETIONDATE));

criteria.add(Restrictions. ......);

....

criteria.createCriteria("projects", Criteria.INNER_JOIN).add(Restrictions.in("id",ids));

und "ids" ist ein Long[] mit den ids der Projeckten


Top
 Profile  
 
Display posts from previous:  Sort by  
Forum locked This topic is locked, you cannot edit posts or make further replies.  [ 2 posts ] 

All times are UTC - 5 hours [ DST ]


You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum

Search for:
© Copyright 2014, Red Hat Inc. All rights reserved. JBoss and Hibernate are registered trademarks and servicemarks of Red Hat, Inc.