-->
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: Problem with user type and 2nd level cache
PostPosted: Wed Sep 14, 2005 5:54 am 
Newbie

Joined: Thu Dec 16, 2004 7:11 am
Posts: 7
Hibernate version: 3.0.5

I'm using the enum pattern described in http://hibernate.org/172.html and recently found this problem. I can store an entity having an attribute of an enumerated type and I can retrieve it alright, but only the first time, if the entity is cached in the 2nd level cache. All subsequent session.get return an entity that has "null" for the value of the enumerated attribute. In other words: the first session.get hits the database and returns a fully populated entity. All subsequent queries hit the cache (as I can see by turning on SQL logging) and return an incomplete entity.

I am using EHCache as my 2nd level cache.

Is this a known bug?


Top
 Profile  
 
 Post subject:
PostPosted: Wed Sep 14, 2005 12:24 pm 
Hibernate Team
Hibernate Team

Joined: Tue Aug 26, 2003 12:50 pm
Posts: 5130
Location: Melbourne, Australia
Obviously you have a bug in your assemble() or disassemble() methods.


Top
 Profile  
 
 Post subject:
PostPosted: Wed Sep 14, 2005 4:55 pm 
Newbie

Joined: Thu Dec 16, 2004 7:11 am
Posts: 7
I see no mention of assemble/disassemble methods in the solution whose URL I posted ( http://hibernate.org/172.html which, by the way, is the same code that appears on "Hibernate in Action") and I have no assemble/disassemble in my code, so there's obviously no bug there, unless you count not having assemble/disassemble as a bug, in which case I'd like to know where I should put them and how are they supposed to behave.

Thanks.


Top
 Profile  
 
 Post subject:
PostPosted: Wed Sep 14, 2005 5:02 pm 
Hibernate Team
Hibernate Team

Joined: Tue Aug 26, 2003 12:50 pm
Posts: 5130
Location: Melbourne, Australia
You stated that your HB version is 3.0.5.

If you have no assemble() / disassemble() methods on your UserType, your code will not even compile.

Are you lying about the version of Hibernate you are using :)


Top
 Profile  
 
 Post subject:
PostPosted: Wed Sep 14, 2005 5:18 pm 
Newbie

Joined: Thu Dec 16, 2004 7:11 am
Posts: 7
Oops, sorry, you are right. I am using 3.0.5 and I *do* have assemble/disassemble methods in my subclass. They were filled in by my IDE to satisfy the UserType interface contract and I forgot about them. They also return null, which is probably not correct.

Now, since the javadocs say "At the very least this method should perform a deep copy if the type is mutable." and my user type is not mutable, is it enough to return a reference to the original value instead of copying it?

I also think we should correct the page with the correct solution for 3.0.5. If you like, I can do that as soon as I get my code to work.


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.