-->
These old forums are deprecated now and set to read-only. We are waiting for you on our new forums!
More modern, Discourse-based and with GitHub/Google/Twitter authentication built-in.

All times are UTC - 5 hours [ DST ]



Forum locked This topic is locked, you cannot edit posts or make further replies.  [ 4 posts ] 
Author Message
 Post subject: session.get(clazz, key) returns Proxy?
PostPosted: Wed Dec 15, 2004 8:07 am 
Newbie

Joined: Wed Dec 15, 2004 7:59 am
Posts: 2
Hibernate version: 2.1.6

I call session.get(clazz, key) and in one case the proxy is returned and in another the persistent object.

After studying "Hibernate in Action" I still don't have a clue, why in one case the proxy is returned and in the other case the persistent object.

The proxy is an interface and my persistent object implements this interface.

Since I assumed that I would receive the persistent object when calling session.get in my code, I get a ClassCastException when the Proxy is returned instead.

Any ideas?

Manri


Top
 Profile  
 
 Post subject: hmmmm
PostPosted: Wed Dec 15, 2004 8:25 am 
Newbie

Joined: Wed Dec 15, 2004 7:59 am
Posts: 2
Well in my code prior to the session.get call I have a session.load method.

I changed load to get and receive the desired object now.

So if I "load" an object first and call "get" in the same session, I seem to be receiving the Proxy.

Can anybody clarify this to me or point me to a relevant page in the book?

Thanks,

manri


Top
 Profile  
 
 Post subject:
PostPosted: Wed Dec 15, 2004 9:00 am 
Hibernate Team
Hibernate Team

Joined: Thu Dec 18, 2003 9:55 am
Posts: 1977
Location: France
don't use load

_________________
Anthony,
Get value thanks to your skills: http://www.redhat.com/certification


Top
 Profile  
 
 Post subject:
PostPosted: Wed Dec 15, 2004 9:18 am 
Hibernate Team
Hibernate Team

Joined: Tue Aug 26, 2003 12:50 pm
Posts: 5130
Location: Melbourne, Australia
This is correct behavior, Hibernate enforces == as much as possible.


Top
 Profile  
 
Display posts from previous:  Sort by  
Forum locked This topic is locked, you cannot edit posts or make further replies.  [ 4 posts ] 

All times are UTC - 5 hours [ DST ]


You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum

Search for:
© Copyright 2014, Red Hat Inc. All rights reserved. JBoss and Hibernate are registered trademarks and servicemarks of Red Hat, Inc.