openjpa-users mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From pdd <pbar...@gmail.com>
Subject Re: overriding accesors in entity needs tranisent declaration
Date Sun, 02 Aug 2009 09:28:13 GMT

Digging further into this, there is a major difference in the way the entity
class is instantiated by EciplseLink versus OpenJPA. 
When using eclipselink w/o the transient declaration, the entity class's
overridden setters are called (which in turn call super).
While using OpenJPA with transient declaration for overridden accessors,
only the setters for the super class are called and the overridden setters
are never called. This causes the application to break which depends on the
initialization of non-persistent state in the entity class during the set*.

As an example, lets take the above simple test case. If I need to have a
non-persistent boolean field in UserModelImpl called adult and wrap it with
accessors as isAdult/setAdult. Then I can declare "adult" as a transient and
override the setAge/getAge such that the adult value can be set if the age
is more than 18, in UserModelImpl entity class.
public void setAge(int age) {
    if(age > 18) {
        adult = true;
    }
    super.setAge(age);
}
This will not work with OpenJPA.
-- 
View this message in context: http://n2.nabble.com/overriding-accesors-in-entity-need-tranisent-declaration-tp3363414p3372112.html
Sent from the OpenJPA Users mailing list archive at Nabble.com.

Mime
View raw message