Help coderanch get a
new server
by contributing to the fundraiser
  • Post Reply Bookmark Topic Watch Topic
  • New Topic
programming forums Java Mobile Certification Databases Caching Books Engineering Micro Controllers OS Languages Paradigms IDEs Build Tools Frameworks Application Servers Open Source This Site Careers Other Pie Elite all forums
this forum made possible by our volunteer staff, including ...
Marshals:
  • Campbell Ritchie
  • Ron McLeod
  • Paul Clapham
  • Devaka Cooray
  • Liutauras Vilda
Sheriffs:
  • Jeanne Boyarsky
  • paul wheaton
  • Henry Wong
Saloon Keepers:
  • Stephan van Hulst
  • Tim Holloway
  • Tim Moores
  • Carey Brown
  • Mikalai Zaikin
Bartenders:
  • Lou Hamers
  • Piet Souris
  • Frits Walraven

Hibernate Criteria object - how to... ?

 
Ranch Hand
Posts: 43
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • 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..
 
ranger
Posts: 17347
11
Mac IntelliJ IDE Spring
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
So why are you using a DetachedCriteria object in this case?

Mark
 
Somak Dalui
Ranch Hand
Posts: 43
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • 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
Posts: 17347
11
Mac IntelliJ IDE Spring
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • 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
 
Ranch Hand
Posts: 57
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • 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
Posts: 17347
11
Mac IntelliJ IDE Spring
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • 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: 43
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Thank you Mark.
 
reply
    Bookmark Topic Watch Topic
  • New Topic