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

Using Hibernate Criteria with an List within my domain object

 
Greenhorn
Posts: 20
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
I have a domain object Order, which has an List of OrderLine objects withing OrderLine, I have another object called Product which has fields I need to be able to search on.

I currently have Hibernate set up to pull all the Product and OrderLine data, when an Order is requested. I like this. However, when using criteria I thought I should be able to set this up like,

but I get an Exception: org.hibernate.QueryException: could not resolve property: orderLines.product.customerProductId of: com....domain.Order



Is my notation wrong? If I just do a search on the poNum (which resides on the Order object), the search works fine. It only has problems when I go down to the OrderLine and Product level.

Thanks for the help.
 
Ranch Hand
Posts: 100
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
you can't go through properties like that, hibernate only "hydrates" one-to-one mapping for models, to go beyond that depth, you have to do something like:



or something in those lines.

Trilochan.
 
Craig Dumolien
Greenhorn
Posts: 20
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Thanks for the input. That fixed it. The code I actually used is below. After getting the OrderLine, every other object I need to reference is one-to-one.

 
reply
    Bookmark Topic Watch Topic
  • New Topic