The orm.xml looks like this,

    <access>PROPERTY</access>

    <mapped-superclass class="UserModelBaseImpl">
        <attributes>
            <id name="id">
                <generated-value strategy="IDENTITY"/>
            </id>
            <basic name="name"> 
                <column name="firstName" />
            </basic>
            <basic name="lastName"/>
            <basic name="age"/>
            <basic name="wages"/>
            <basic name="active">
                <column name="ACTIVE_"/>
            </basic>
            <transient name="new"/>
        </attributes>
    </mapped-superclass>

    <entity class="UserModelImpl">
        <table name="User"/>
    </entity>

Entity class is defined like this,

public class UserModelImpl extends UserModelBaseImpl {

        public String getName() {
                return super.getName();
        }

        public void setName(String name) {
                super.setName(name);
        }

}

The mapped-superclass UserModelBaseImpl also has getter/setter getName and
setName (in addition to other accessors).

The reason for having overriding accessors in the entity, although it may
not be apparent from this simple test case, is that the value object is
conditionally manipulated.

This fails with an exception,
<openjpa-1.2.1-r752877:753278 fatal user error>
org.apache.openjpa.util.MetaDataException: Fields
"com.example.model.impl.UserModelImpl.name" are not a default persistent
type, and do not have any annotations indicating their persistence strategy. 
If you do not want these fields to be persisted, annotate them with
@Transient.

It works when name is declared as transient in the entity as shown below,
<entity class="UserModelImpl">
    <table name="User"/>
    <attributes>
        <transient name="name"/>
    </attributes>
</entity>

But now EclipseLink does not work and returns the UserModelImpl objects with
name field blank.

So now I am in a situation where this test case works either with OpenJPA or
with EclipseLink, but not both.
Would like to know whose bug is it?

-- 
View this message in context: 
http://n2.nabble.com/overriding-accesors-in-entity-need-tranisent-declaration-tp3363414p3363414.html
Sent from the OpenJPA Users mailing list archive at Nabble.com.

Reply via email to