-->
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: cache problem with lightweight/normal/proxy...
PostPosted: Wed Jan 21, 2004 7:33 am 
Beginner
Beginner

Joined: Thu Oct 02, 2003 5:06 am
Posts: 26
Location: Budapest, Hungary
here's the problem. Within a session, if an instance of Object1 is loaded and used, and then another Object2 is loaded, which has an Object1LightWeight, or Object1Proxy element, then the cache is hit and the original Object1 is found and assumed to be the right object. however, when it tries to return that object as either of the LightWeight, or Proxy classes, then it throws a classcast exception.

Code:
2004-01-20 16:00:01,820 DEBUG [net.sf.hibernate.impl.SessionImpl] resolved object in session cache [com.tibbett.controlling.hibernate.ProfitcenterLightWeight#3]
2004-01-20 16:00:02,387 ERROR [STDERR] java.lang.ClassCastException
        at com.tibbett.controlling.hibernate.KeyPCSelectedListLightWeightMetaClass18.setPropertyValues(<generated>)
        at net.sf.hibernate.persister.AbstractEntityPersister.setPropertyValues(AbstractEntityPersister.java:162)
        at net.sf.hibernate.impl.SessionImpl.initializeEntity(SessionImpl.java:1961)


is this normal behavior? should hibernate not notice that these are different object types and go get the matching object?
We are using hibernate 2.0.2 on Jboss.
(if this has been fixed in a later version of hibernate.. that would be great :)))
Thnx
A.


Top
 Profile  
 
 Post subject:
PostPosted: Wed Jan 21, 2004 2:43 pm 
Hibernate Team
Hibernate Team

Joined: Tue Aug 26, 2003 12:50 pm
Posts: 5130
Location: Melbourne, Australia
This is normal and correct. You often need judicious use of evict() with the lightweight pattern.


Top
 Profile  
 
 Post subject: thnx.
PostPosted: Thu Jan 22, 2004 4:42 am 
Beginner
Beginner

Joined: Thu Oct 02, 2003 5:06 am
Posts: 26
Location: Budapest, Hungary
thanks for the quick answer.. we rewrote the server side to use proxy classes rather then trying to keep track of what was loaded/where :)
Cheers
Ati.


Top
 Profile  
 
 Post subject: proxy vs normal..
PostPosted: Thu Jan 22, 2004 4:37 pm 
Beginner
Beginner

Joined: Thu Oct 02, 2003 5:06 am
Posts: 26
Location: Budapest, Hungary
is is possible for proxy and normal objects to conflict in the same way az with lightweight??
I had assumed that proxy would be the name as a full class except that a relationship is not loaded until accessed.. but we seem to be having mismatches between proxy/normal.

we are using hibernate 2.0.2... should we upgrade? have there been any changes in this behaviour since then?
Thnx


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.