• 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
  • Paul Clapham
  • Ron McLeod
  • Jeanne Boyarsky
  • Tim Cooke
Sheriffs:
  • Liutauras Vilda
  • paul wheaton
  • Henry Wong
Saloon Keepers:
  • Tim Moores
  • Tim Holloway
  • Stephan van Hulst
  • Carey Brown
  • Frits Walraven
Bartenders:
  • Piet Souris
  • Himai Minh

last entry from one to many

 
Ranch Hand
Posts: 110
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Hi all,

First of all I am hibernate's greenhorn. I am solving a problem with displaying last PriceEntry from one to many association in hibernate. So I don't know if hibernate support this feature but I think it should.
I have e.g. House and PriceEntry (one-to-many) . Each house has thousands PriceEntries and I need use only last PriceEntry to be display somewhere. I have seen some solution with a hibernate's Filter but I think it filters data after their complete loading. So i cannot be good solution.
From performace reasons I prefer the way the each Hause load only last PriceEntry.

I have implemented this by adding one-to-one association to the last one PriceEntry to each Hause. But I think there can be some nicer solution via Hibernate without adding next columns into a database.
Could you advice me how it can be done.

Thanks

 
Ranch Hand
Posts: 122
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Hi,

Why don't you go for HQL or native sql Query to do that . Its better solution than adding new column on your database.

Regards.
Hemant
 
manu chaox
Ranch Hand
Posts: 110
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
what way do you think ? I have seen some topics where are written that the HQL doesn't support nested queries.
 
Hemant Thard
Ranch Hand
Posts: 122
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator

manu chaox wrote:what way do you think ? I have seen some topics where are written that the HQL doesn't support nested queries.
[/quote

Where did you see such topics .. ?

Here is an Example that shows you how to use nested query in hibernate.

 
We've gotta get close enough to that helmet to pull the choke on it's engine and flood his mind! Or, we could just read this tiny ad:
free, earth-friendly heat - a kickstarter for putting coin in your pocket while saving the earth
https://coderanch.com/t/751654/free-earth-friendly-heat-kickstarter
reply
    Bookmark Topic Watch Topic
  • New Topic