-->
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.  [ 1 post ] 
Author Message
 Post subject: Access to transient fields not intercepted with field access
PostPosted: Fri Sep 29, 2006 5:27 am 
Newbie

Joined: Thu Jul 21, 2005 5:30 am
Posts: 5
Access to transient fields as member variables appears not to be intercepted, unlike for persistent fields when using field access (declaring annotations on fields, not on getters). As a consequence, the value of a transient field that is not accessed through getters/setters becomes de-synchronized across multiple proxies for one and the same entity within a transaction.

Example

@Entity
public class LowLevel {

@Id
int id;

@Transient
public int counter1=0;

@Transient
public int counter2=0;

public int getCounter1() { return this.counter1; }
public void setCounter1(int counter1) { this.counter1=counter1; }
}

@Entity
public class HighLevel extends LowLevel {

public void doSomething() {
setCounter1(1);
this.counter2 = 1;
}
}


Now assume that you have a persistent instance of HighLevel, and somehow obtain two proxies P1 and P2, where P1 references the instance as a LowLevel (that's how you'd end up with two different proxies, as I understand).

From our observations, the following will happen:

P2.doSomething();
=> P1.getCounter1() == 1
=> P1.counter2 == 0


Is this observation correct and is this behavior intended?


Top
 Profile  
 
Display posts from previous:  Sort by  
Forum locked This topic is locked, you cannot edit posts or make further replies.  [ 1 post ] 

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.