-->
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.  [ 3 posts ] 
Author Message
 Post subject: Javassisted entity lost changes made in it
PostPosted: Fri Oct 09, 2015 5:15 am 
Newbie

Joined: Fri Oct 09, 2015 4:43 am
Posts: 1
I use Hibernate 3 and javassisted lazy entities.
Group.hbm.xml has field "flag"
...
<class lazy="true" name="Group" polymorphism="explicit" table="groups">
...
<!-- Bitfield flag for conditions -->
<property column="flags" name="flags" type="integer"/>

The problem is - I made changes to field indirectly via method not called "setFlag"
but setSkipProcessingDta(boolean shouldSkip) in class Group which in turns call "setFlag"

public void setSkipProcessingDta(boolean skip) {
if (skip) {
setFlag(SKIP_DTA);
nextDate = SKT_DATE;
nextReviewDate = SKT_DATE;
} else {
if (isSkipDta ()) {
recalculateDates();
}
clearFlag(SKIP_DTA);
}
}


But javassist wrapper object dont reflect changes.
When I return from javassist wrapper calls - flag still has value 0.
How could I specify that this method (setSkipProcessingDta) changes field?


Top
 Profile  
 
 Post subject: Re: Javassisted entity lost changes made in it
PostPosted: Mon Oct 19, 2015 1:12 pm 
Regular
Regular

Joined: Mon Oct 19, 2015 7:49 am
Posts: 61
Location: ChengDu China
I'm not very sure, but I can guess the reason.

In hibernate-proxy, one-entity, two objects
(1) The proxy object whose byte code has been modified by javassist. Becareful, all the fields are not used!
(2) The real target object(If it is loaded), it's wraped by the proxy object.

Javassists overrides all the methods (include "setSkipProcessingData") to inovke the corresponding methods (include "setSkipProcessingData") of real target objects, that why the field of wrapper object will never be changed.

If it can't resolve your problem, keep touch(Note: I'm in China, time range is diff so maybe the reply will be delayed)

__________________________________
By the way: Help me to let more friends know: https://github.com/babyfish-ct/babyfish


Top
 Profile  
 
 Post subject: Re: Javassisted entity lost changes made in it
PostPosted: Wed Oct 21, 2015 2:09 am 
Newbie

Joined: Thu Oct 15, 2015 11:05 pm
Posts: 4
Thanks for the tip. I had the same issue with hibernate-release-4.3.8.Final and I solved it by downgrading to hibernate-release-4.0.0.Final.


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