Hi Pinaki,

Thanks a lot for your answer. 
Yes, you are right. The YPDatabaseItem is the superclass of YPInstanceItem,
YPEntityClass and YPParameter

here the Java Class for YPInstance ITem:

public class YPInstanceItem extends YPDatabaseItem
{
  public static final YPInstanceItem NONE = new YPInstanceItem();

  private short categoryTypeId;
  private short instanceTypeId;
  private String instanceKey;
  private String name;
  private String uniqueId;
  private String description;

  private Map<String, YPEntityClass> entities = new LinkedHashMap<String,
YPEntityClass>();

  private YPInstanceItem instanceParent;
  private boolean resolved = false;
  private boolean hidden = false;

  public YPInstanceItem()
  {
    this("", "", "", YPInstanceType.VARIANT, YPCategoryType.NOT_DEFINED);
  }

  public YPInstanceItem(String uniqueId,
                          String name,
                          String instanceKey,
                          YPInstanceType instanceType,
                          YPCategoryType categoryType)
  {
    this.uniqueId = uniqueId;
    this.name = name;
    this.instanceKey = instanceKey;
    this.instanceTypeId = instanceType.getType();
    this.categoryTypeId = categoryType.getType();
  }
.
.
.
  public YPInstanceItem getInstanceParent()
  {
    return instanceParent;
  }

  public void setInstanceParent(YPInstanceItem instanceParent)
  {
    this.instanceParent = instanceParent;
  }
.
.
.
}

As you can see, the YPInstanceItem extends the YPDatabaseItem.

public abstract class YPDatabaseItem
{
  private final Logger logger = Logger.getLogger(this.getClass());

  private int id;
  private int dbVer;

  public void setId(int id)  {
    this.id = id;
  }
  
  public int getId()  {
    return this.id;
  }

  public int getDbVer()  {
    return dbVer;
  }

  public void setDbVer(int dbVer)  {
    this.dbVer = dbVer;
  }

  public abstract String getUniqueConstraintQueryString();
  @Override
  public abstract boolean equals(Object otherItem);
  public abstract <T extends YPDatabaseItem> boolean similarInstance(T
otherItem);

  final protected Logger getLogger()
  {
    return logger;
  }
}

The YPDatabaseItem only has 2 persistent fields: id and dbVer. The
Superclass is mapped like this:
<mapped-superclass class="com.adva.yp.api.model.core.YPDatabaseItem"
metadata-complete="true">
    <attributes>
        <id name="id">
          <generated-value strategy="IDENTITY"/>
        </id>
        <version name="dbVer"/>
        <transient name="logger"/>
    </attributes>
</mapped-superclass>

the ID is mapped in every derived class like this (example for
YPInstanceITem): 
    <attribute-override name="id">
      <column name="YP_INSTANCE_ID"/>
    </attribute-override>

and here is the table for YPInstanceItem:

delimiter $$

CREATE TABLE `yp_instance` (
  `YP_INSTANCE_ID` int(11) NOT NULL auto_increment,
  `DBVER` bigint(20) default NULL,
  `YP_INSTANCE_TYPE_ID` int(11) default NULL,
  `YP_INSTANCE_UNIQUE_ID` varchar(255) default NULL,
  `YP_INSTANCE_KEY` varchar(255) default NULL,
  `YP_CATEGORY_TYPE_ID` int(11) default NULL,
  `YP_INSTANCE_RESOLVED` tinyint(1) default '0',
  `YP_INSTANCE_DESCRIPTION` varchar(1000) default NULL,
  `YP_INSTANCE_HIDDEN` tinyint(1) default '0',
  `YP_INSTANCE_NAME` varchar(255) default NULL,
  `YP_INSTANCE_ID_PARENT` int(11) default NULL,
  PRIMARY KEY  (`YP_INSTANCE_ID`),
  UNIQUE KEY `UNQ_yp_instance_0` (`YP_INSTANCE_UNIQUE_ID`),
  KEY `FK_yp_instance_YP_INSTANCE_ID_PARENT` (`YP_INSTANCE_ID_PARENT`),
  KEY `YP_INSTANCE_IDX0`
(`YP_INSTANCE_TYPE_ID`,`YP_CATEGORY_TYPE_ID`,`YP_INSTANCE_HIDDEN`),
  CONSTRAINT `FK_yp_instance_YP_INSTANCE_ID_PARENT` FOREIGN KEY
(`YP_INSTANCE_ID_PARENT`) REFERENCES `yp_instance` (`YP_INSTANCE_ID`)
) ENGINE=InnoDB AUTO_INCREMENT=0 DEFAULT CHARSET=latin1$$

i am not sure if i could answer to all of your questions. i don't know
exactly what you mean by "inheritance reflected in mapping descriptors" and
"Java domain class definitions". but i am sure i could satisfy your needs
with the parent relations of YPInstanceItem ;-)

maybe i need to add that comment: the entity manager is open for the
lifetime of the program and the problem occurs very quick (after 10 minutes
or ca. 100 selects).

Cheers

Gerald



-- 
View this message in context: 
http://openjpa.208410.n2.nabble.com/Parent-reference-is-loaded-but-disappears-while-working-with-the-object-tp5728025p5739938.html
Sent from the OpenJPA Users mailing list archive at Nabble.com.

Reply via email to