-->
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.  [ 5 posts ] 
Author Message
 Post subject: session get by object method?
PostPosted: Mon Jan 12, 2004 8:08 am 
Newbie

Joined: Thu Aug 28, 2003 7:14 am
Posts: 18
Is there a reason there is no get(obj, id) method in the Session API, although there is load(...) like this.

The thing is, I made some wrapping API around hibernate and I need the same semantics for load() and get().

Any suggestions (I need a load by object behavior for get())

thanks.

Michael.


Top
 Profile  
 
 Post subject:
PostPosted: Mon Jan 12, 2004 8:34 am 
Hibernate Team
Hibernate Team

Joined: Tue Sep 09, 2003 2:10 pm
Posts: 3246
Location: Passau, Germany
load() assumes the row exists in the DB, and so can fill the object you pass to it with the data loaded and throw an exception when the row is not found. What should get() do when the row is not found?


Top
 Profile  
 
 Post subject:
PostPosted: Mon Jan 12, 2004 8:46 am 
Newbie

Joined: Thu Aug 28, 2003 7:14 am
Posts: 18
I guess get(_obj, id) should do the same as get(Class, id) does, but instead of returning the Object that found in session it should fill the given _obj with the proper content.
it just cleaner to have the same semantics for load and get, unless it is fundamentally different?

Michael.


Top
 Profile  
 
 Post subject:
PostPosted: Mon Jan 12, 2004 8:49 am 
Hibernate Team
Hibernate Team

Joined: Tue Sep 09, 2003 2:10 pm
Posts: 3246
Location: Passau, Germany
But what if there is no row in the database for the id? get normally returns null in this case, but it really cant if you pass it an object.

If you have a wrapper anyway, well if you want the same behaviour just delegate your call to load()


Top
 Profile  
 
 Post subject:
PostPosted: Mon Jan 12, 2004 8:58 am 
Newbie

Joined: Thu Aug 28, 2003 7:14 am
Posts: 18
but this is exactly my problem:

wrapper read(...) gets object ref to some POJO then it tries to load() but sometimes it is done in the same session and I get "identical objects exception" from load, I thought I could call get and if it fails call load. This way I isolate the user from knowing if he runs in the same or different sessions.

Now back since I have a ref to the POJO using existing API I can not do it transparently?


Top
 Profile  
 
Display posts from previous:  Sort by  
Forum locked This topic is locked, you cannot edit posts or make further replies.  [ 5 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.