Hi @all,

i have a Model of 3 Classes:

InstanceItem, EntityClass and Parameter.

an InstanceItem has a reference to its parent InstanceItem and a Map to its
EntityClasses.
An EntityClass has a Reference to its InstanceItem and to a Collection of
Parameters.
Parameters have no references to anything, they just have some values.

My Problem:
The InstanceItem Reference to its parent gets lost somehow.
I have a breakpoint that stops when i load an InstanceItem without a parent
(i don't load the head elements).
I also have a breakpoint when the parent is accessed and it is null.
for checking that the programm does not change the InstanceItem, i added
Break points to the accessors for the parent InstanceItem and a breakpoint
for a field change to null. 

I only hit the second breakpoint always... so somewhere the parent reference
disappears. 

maybe there is too much data in the openJPA cache so that it throws away
something? i don't know what could happen there.

i add my mapping.xml file and my persistence.xml

if you need more info, please don't hesitate to ask.

would be nice to get that problem solved quickly.

MAPPING:
<?xml version="1.0" encoding="Cp1252" ?>
<entity-mappings xmlns="http://java.sun.com/xml/ns/persistence/orm";
                 xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance";
                
xsi:schemaLocation="http://java.sun.com/xml/ns/persistence/orm
http://java.sun.com/xml/ns/persistence/orm_1_0.xsd";
                 version="1.0">

  <persistence-unit-metadata>
    <xml-mapping-metadata-complete/>
    <!--<persistence-unit-defaults>
      <schema>yp</schema>
    </persistence-unit-defaults>-->
  </persistence-unit-metadata>
<mapped-superclass class="com.adva.yp.api.model.YPDatabaseItem"
metadata-complete="true"><!--
    <entity-listeners>
      <entity-listener
class="com.adva.yp.api.data_accessor.database_accessor.entity_listener.YPDatabaseItemEntityListener"/>
    </entity-listeners>-->
    <attributes>
        <id name="id">
          <generated-value strategy="IDENTITY"/>
        </id>
        <version name="dbVer"/>
        <transient name="logger"/>
    </attributes>
</mapped-superclass>
    
<!-- YPInstanceItem <-> YP_INSTANCE -->
  <entity class="com.adva.yp.api.model.YPInstanceItem">
    <table name="yp_instance"> <!-- schema="yp"> -->
        <unique-constraint>
            <column-name>YP_INSTANCE_UNIQUE_ID</column-name>
        </unique-constraint>
    </table>
<!-- Primary Key -->
    <attribute-override name="id">
      <column name="YP_INSTANCE_ID"/>
    </attribute-override>
    <attributes>
<!-- Basic mappings -->
      <basic name="uniqueId"><column name="YP_INSTANCE_UNIQUE_ID" /></basic>
      <basic name="name"><column name="YP_INSTANCE_NAME"/></basic>
      <basic name="instanceKey"><column name="YP_INSTANCE_KEY"/></basic>
      <basic name="categoryTypeId"><column
name="YP_CATEGORY_TYPE_ID"/></basic>
      <basic name="instanceTypeId"><column
name="YP_INSTANCE_TYPE_ID"/></basic>
      <basic name="description"><column name="YP_INSTANCE_DESCRIPTION"
column-definition="VARCHAR(1000)"/></basic>
      <basic name="resolved"><column name="YP_INSTANCE_RESOLVED"/></basic>
      <basic name="hidden"><column name="YP_INSTANCE_HIDDEN"/></basic>

<!-- Hierarchy Mapping to parent and child instance items -->
      <many-to-one name="instanceParent"
target-entity="com.adva.yp.api.model.YPInstanceItem" fetch="EAGER">
<!--optional="true" fetch="LAZY">-->
        <join-column name="YP_INSTANCE_ID_PARENT"/>
        <cascade>  <cascade-persist/> <cascade-merge/> <cascade-refresh/>
</cascade>
      </many-to-one>

<!-- All Entities -->
      <one-to-many name="entities"
target-entity="com.adva.yp.api.model.YPEntityClass"
mapped-by="referencedInstanceItem" fetch="LAZY">
        <map-key name="name" />
        <cascade> <cascade-all/> </cascade>
      </one-to-many>
<!--
      <one-to-many name="childInstanceItems"
target-entity="com.adva.yp.api.model.YPInstanceItem" fetch="LAZY"
mapped-by="instanceParent">
        <cascade>  <cascade-remove/>  </cascade>
      </one-to-many>
-->
      <!--<transient name="logger" />-->
    </attributes>
  </entity>

<!-- YPEntityClass <-> YP_ENTITY -->
  <entity class="com.adva.yp.api.model.YPEntityClass"
metadata-complete="true">
    <table name="yp_entity_fast"> <!-- schema="yp"> -->
        <unique-constraint>
            <column-name>YP_ENTITY_TYPE_ID</column-name>
            <column-name>YP_INSTANCE_ID</column-name>
        </unique-constraint>
      </table>
<!-- Primary Key -->
      <attribute-override name="id">
          <column name="YP_ENTITY_ID"/>
      </attribute-override>
    <attributes>
<!-- Basic mappings -->
      <basic name="name"><column name="YP_ENTITY_NAME"/></basic>
      <basic name="entityClassTypeId"><column
name="YP_ENTITY_TYPE_ID"/></basic>
      <!--<basic name="referencedInstanceItemId"><column
name="YP_INSTANCE_ID"/></basic>-->

<!-- referenced YPInstanceItem -->
      <many-to-one name="referencedInstanceItem"
target-entity="com.adva.yp.api.model.YPInstanceItem" optional="false">
        <join-column name="YP_INSTANCE_ID" nullable="false"/>
        <cascade>  <cascade-persist/> <cascade-merge/> <cascade-refresh/>
</cascade>
      </many-to-one>

<!-- All Parameters -->
      <many-to-many name="params"
target-entity="com.adva.yp.api.model.YPParameter" fetch="LAZY">
        <join-table name="yp_entity_parameter_fast">
          <join-column name="YP_ENTITY_ID"/>
          <inverse-join-column name="YP_PARAMETER_ID"/>
          <unique-constraint>
            <column-name>YP_ENTITY_ID</column-name>
            <column-name>YP_PARAMETER_ID</column-name>
          </unique-constraint><!-- -->
        </join-table>
        <cascade>  <cascade-persist/> <cascade-merge/> <cascade-refresh/>
</cascade>
      </many-to-many>

      <!--<transient name="logger" />-->
    </attributes>
  </entity>

<!-- YPParameter <-> YP_PARAMETER -->
  <entity class="com.adva.yp.api.model.YPParameter">
    <table name="yp_parameter"> <!-- schema="yp"> -->
      <unique-constraint>
        <column-name>YP_PARAMETER_TYPE_ID</column-name>
        <column-name>YP_PARAMETER_VALUE_STRING</column-name>
      </unique-constraint>
    </table>
<!-- Primary Key -->
      <attribute-override name="id">
          <column name="YP_PARAMETER_ID"/>
      </attribute-override>
    <attributes>
      <basic name="parameterTypeId"><column
name="YP_PARAMETER_TYPE_ID"/></basic>
      <basic name="parameterName"><column name="YP_PARAMETER_NAME"/></basic>
      <basic name="doubleValue"><column
name="YP_PARAMETER_VALUE_DOUBLE"/></basic>
      <basic name="longValue"><column
name="YP_PARAMETER_VALUE_LONG"/></basic>
      <basic name="stringValue"><column
name="YP_PARAMETER_VALUE_STRING"/></basic>
      <basic name="rangeMin"><column
name="YP_PARAMETER_VALUE_RMIN"/></basic>
      <basic name="rangeMax"><column
name="YP_PARAMETER_VALUE_RMAX"/></basic>

      <!--<transient name="logger" />  -->
    </attributes>
  </entity>

    <entity
class="com.adva.yp.api.data_accessor.database_accessor.util.YPParameterRankingTupel">
        <table name="yp_parameter_ranking"/>
        <attributes>
            <id name="id"><column name="PRIM_KEY"/><generated-value
strategy="IDENTITY"/></id>
            <basic name="type"><column name="YP_PARAMETER_NAME"/></basic>
<!--nsertable="false" updatable="false" nullable="false"/></basic>-->
            <basic name="rankingValue"><column name="YP_PARAMETER_AVG_HIT"
insertable="false" updatable="false" nullable="false"/></basic>
        </attributes>
    </entity>

    <entity class="com.adva.yp.api.data_cache.YPCacheObject">
        <table name="yp_cache"/>
        <attribute-override name="id">
          <column name="YP_CACHE_PK"/>
        </attribute-override>
        <attributes>
            <basic name="headKey"><column name="YP_CACHE_HEAD"/></basic>
            <basic name="positiveKey"><column name="YP_CACHE_POS"/></basic>
            <basic name="negativeKey"><column name="YP_CACHE_NEG"/></basic>
            <basic name="hitCount"><column
name="YP_CACHE_HITCOUNT"/></basic>
            <basic name="instanceItemUniqueId"><column
name="YP_INSTANCE_UNIQUE_ID"/></basic>

            <one-to-one name="instanceItem"
target-entity="com.adva.yp.api.model.YPInstanceItem" fetch="EAGER">
                    <join-column name="YP_INSTANCE_ID"/>
                    <cascade>  <!--<cascade-persist/> <cascade-merge/>-->
<cascade-refresh/> </cascade>
            </one-to-one>
        </attributes>
    </entity>
</entity-mappings>



PERSISTENCE (Connection String is set by Properties):
<?xml version="1.0"?>
<persistence xmlns="http://java.sun.com/xml/ns/persistence"; version="1.0">
    <persistence-unit name="FastAccessYPAPI">
       
<provider>org.apache.openjpa.persistence.PersistenceProviderImpl</provider>
       
<mapping-file>com/adva/yp/api/data_accessor/database_accessor/orm/orm_mysql_fast_access.xml</mapping-file>
        <class>com.adva.yp.api.model.YPDatabaseItem</class>
        <class>com.adva.yp.api.model.YPInstanceItem</class>
        <class>com.adva.yp.api.model.YPParameter</class>
        <class>com.adva.yp.api.model.YPEntityClass</class>
        <properties>
                  <!--Apache OpenJPA doesn't have a built-in connection pool.
                  Apache DB connection pooling services are used. -->
                  <property name="openjpa.ConnectionDriverName"
value="org.apache.commons.dbcp.BasicDataSource"/>
                  <!--The connection properties (URL, user etc) are set
internally./-->

            <property name="openjpa.Log" value="DefaultLevel=WARN"/>
            <property name="openjpa.MetaDataFactory" value="jpa"/>

                  <property name="openjpa.jdbc.SchemaFactory"
value="native(ForeignKeys=true)"/>
                  <property name="openjpa.IgnoreChanges" value="true"/>
                  <property name="openjpa.Multithreaded" value="true"/>
                  <property name="openjpa.NontransactionalRead" value="true"/>
                  <property name="openjpa.NontransactionalWrite" value="false"/>
                  <property name="openjpa.Optimistic" value="true"/>

            <property name="openjpa.jdbc.DBDictionary"
value="TableType=innodb"/>

        </properties>
    </persistence-unit>
</persistence>

It runs on MySQL 5.0.

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

Reply via email to