File APIs for Java Developers
Manipulate DOC, XLS, PPT, PDF and many others from your application.
http://aspose.com/file-tools
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic

Hibernate Criteria object - how to... ?

 
Somak Dalui
Ranch Hand
Posts: 41
  • 0
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
I have to execute a query like : Select * from Application a where a.appNum in (select appNum from Deal d where d.appNum = a.appNum); I tried this :

criteria.list() gives an error com.sybase.jdbc2.jdbc.SybSQLException: Incorrect syntax near ','.. The hibernate query generated is
select this_.appNum as y0_ from Application this_ where this_.appNum in (select this0__.appNum as y0_ from Deal this0__)
. I am using Sybase DB and Hibernate 3. Please help..
 
Mark Spritzler
ranger
Sheriff
Posts: 17276
6
IntelliJ IDE Mac Spring
  • 0
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
So why are you using a DetachedCriteria object in this case?

Mark
 
Somak Dalui
Ranch Hand
Posts: 41
  • 0
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
oh ! ok So what am I missing here ? To fire a subquery what can I do instead of DetachedQuery ?
 
Mark Spritzler
ranger
Sheriff
Posts: 17276
6
IntelliJ IDE Mac Spring
  • 0
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
add a Criteria object to the Criteria object. A Detached is for creating an object outside of a Session, and later on setting the session on the detached object, then executing the detached criteria.

Mark
 
Halcon Guatemala
Ranch Hand
Posts: 57
  • 0
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Hi to @ll, Mark, could you illustrate it? Could We nest distinct queries attaching criterias repeteadly?

Thanks in advance
 
Mark Spritzler
ranger
Sheriff
Posts: 17276
6
IntelliJ IDE Mac Spring
  • 0
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Sort of, it is more subqueries that you are adding to the main query in the Criteria object. You can do a search at hibernate's web site to see more

http://www.hibernate.org/hib_docs/v3/reference/en/html_single/#querycriteria

Mark
 
Somak Dalui
Ranch Hand
Posts: 41
  • 0
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Thank you Mark.
 
With a little knowledge, a cast iron skillet is non-stick and lasts a lifetime.
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic