This week's book giveaway is in the Agile and other Processes forum.
We're giving away four copies of The Mikado Method and have Ola Ellnestam and Daniel Brolund on-line!
See this thread for details.
The moose likes Object Relational Mapping and the fly likes No proxy with session.load() instead it does a database hit - Why? Big Moose Saloon
  Search | Java FAQ | Recent Topics
Register / Login


Win a copy of The Mikado Method this week in the Agile and other Processes forum!
JavaRanch » Java Forums » Databases » Object Relational Mapping
Reply Bookmark "No proxy with session.load() instead it does a database hit - Why?" Watch "No proxy with session.load() instead it does a database hit - Why?" New topic
Author

No proxy with session.load() instead it does a database hit - Why?

Darya Akbari
Ranch Hand

Joined: Aug 21, 2004
Posts: 1855
Hi,

I recently recognized that calling session.load() like does not create a proxy as described by Hibernate's Java Persistence with Hibernate on p.564

Instead it creates a database hit, just the thing that the Hibernate guys want to avoid for performance reason.

I use Hibernate 3.2. Has anyone made similar experience

My hibernate mapping file says lazy="true", so why on earth does session.load() hit the database with a SELECT instead of giving me a proxy


Regards,
Darya
[ September 12, 2007: Message edited by: Darya Akbari ]

SCJP, SCJD, SCWCD, SCBCD
Darya Akbari
Ranch Hand

Joined: Aug 21, 2004
Posts: 1855
Maybe it's a bug and I'm the first who encountered it
Darya Akbari
Ranch Hand

Joined: Aug 21, 2004
Posts: 1855
The database I use is Oracle.
Darya Akbari
Ranch Hand

Joined: Aug 21, 2004
Posts: 1855
Got it ,

The problem was that I didn't have a proxy="my pojo class" set in my hibernate mapping file due to the description in the book.

Anyway I have my proxy now

Regards,
Darya
Darya Akbari
Ranch Hand

Joined: Aug 21, 2004
Posts: 1855
... finally, take care that the proxy stuff only works with concrete POJOs.

Polymorphy is not supported by it
 
I agree. Here's the link: http://zeroturnaround.com/jrebel - it saves me about five hours per week
 
subject: No proxy with session.load() instead it does a database hit - Why?
 
Similar Threads
Loading proxy without hitting database
Optimizing fetching with Hibernate - How do I get my ID?
Using hibernate delete
is better to load instance before delete it?
Hibernate lazy collections: What about the collection elements - are they lazy too?