Win a copy of The Little Book of Impediments (e-book only) this week in the Agile and Other Processes forum!
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic

last entry from one to many

 
manu chaox
Ranch Hand
Posts: 110
  • Mark post as helpful
  • send pies
  • 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

 
Hemant Thard
Ranch Hand
Posts: 122
  • Mark post as helpful
  • send pies
  • 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
  • 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
  • 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.

 
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic