-->
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.load problem
PostPosted: Mon Apr 11, 2005 12:32 am 
Newbie

Joined: Thu Nov 13, 2003 5:08 am
Posts: 2
hi everyone,
I have a problem when load an entity and it's associations.
I have a PO named User which has a many-to-many association with another PO named Role. The id of User is username and the id of Role is rolename. There is one User instance identified by roy is stored which has two roles. When I load a User using session.load(User.class, "roy"), everything is fine, but when load using session.load(User.class, "Roy"), the User is loaded but the associated Role instances are missing! Anybody knows how this happen and how to solve it?

thanks in advance


Top
 Profile  
 
 Post subject:
PostPosted: Mon Apr 11, 2005 2:44 am 
Expert
Expert

Joined: Fri Nov 07, 2003 4:24 am
Posts: 315
Location: Cape Town, South Africa
Are you sure that you not just getting a proxy back in the latter case?

What happens if you use session.get(...)


Top
 Profile  
 
 Post subject:
PostPosted: Mon Apr 11, 2005 2:47 am 
Expert
Expert

Joined: Fri Nov 07, 2003 4:24 am
Posts: 315
Location: Cape Town, South Africa
What I mean by that is that
Code:
session.load(...)

assumes the instance exists whereas
Code:
session.get(...)

will return null if the instance is not present


Top
 Profile  
 
 Post subject:
PostPosted: Mon Apr 11, 2005 5:24 am 
Newbie

Joined: Thu Nov 13, 2003 5:08 am
Posts: 2
I use Hibernate 2.1 Console to test.

Code:
session.clear();
session.get(User.class, "roy");

every thing is ok, but
Code:
session.clear();
session.get(User.class, "Roy");

still can not get the roles.

besides, when get entity using roy, the property username of the resulting User instance is roy, but when using Roy, this property is Roy.

I use Hibernate 2.1.8 and MySQL 4.1 which is case-insensitive.


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.