• 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

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

 
Ranch Hand
Posts: 1855
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • 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 ]
 
It's feeding time! Give me the food you were going to give to this tiny ad:
We need your help - Coderanch server fundraiser
https://coderanch.com/wiki/782867/Coderanch-server-fundraiser
reply
    Bookmark Topic Watch Topic
  • New Topic