• Post Reply Bookmark Topic Watch Topic
  • New Topic

Optimizing fetching with Hibernate - How do I get my ID?

 
Darya Akbari
Ranch Hand
Posts: 1855
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Hi,

One topic of Hibernate is to minimize the database hits when working with Hibernate and a domain model (POJOs). Hence Hibernate uses proxies based on the Hibenate Mappings instead of the real entity.

Look the next example from the book Java Persistence with Hibernate p.565:


The only database hit (INSERT) is at the last line in above example when doing save.

But where do I get my ID's (123, 1234) from? Wouldn't it be through a another database hit (SELECT) .

Aren't there other solutions for obtaining the IDs w/o touching the database? I mean at some point one had to insert Item(123) and Bid(1234).

Regards,
Darya
[ September 12, 2007: Message edited by: Darya Akbari ]
 
Gravity is a harsh mistress. But this tiny ad is pretty easy to deal with:
the new thread boost feature: great for the advertiser and smooth for the coderanch user
https://coderanch.com/t/674455/Thread-Boost-feature
  • Post Reply Bookmark Topic Watch Topic
  • New Topic
Boost this thread!