-->
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: strange problem
PostPosted: Tue Dec 27, 2005 4:06 am 
Newbie

Joined: Thu Dec 22, 2005 11:15 pm
Posts: 13
Hi,

I realized a parent/child relationship with following:
Code:
    <class name="com.wish.network_mgr.gdwPersistence.data.mainData.TopoLink" table="TOPO_LINK" schema="GDW2">
   ...
        <map name="topoLinkTerminations" cascade="all" inverse="true" fetch="join">
           <key>
              <column name="TOPO_LINK_CODE" precision="38" scale="0"
                 not-null="true" />
           </key>
           <composite-map-key class="com.wish.network_mgr.gdwPersistence.data.mainData.CMapKeyForTopoLinkTerm">
              <key-property name="propName" column="PROP_NAME"></key-property>
              <key-property name="AZType" column="A_Z_TYPE"></key-property>
           </composite-map-key>
           <one-to-many
              class="com.wish.network_mgr.gdwPersistence.data.mainData.TopoLinkTermination" />
        </map>
    </class>

In my program, I do the following:

Code:
1)create TopoLink instance(topoLink);
2)create TopoLinkTermination instance(topoLinkTermination);
3)       topoLinkTermination.setTopoLink(topoLink);
       topoLink.getTopoLinkTerminations().put(
               new CMapKeyForTopoLinkTerm(topoLinkTermination.getId().getPropName(),
                                          topoLinkTermination.getId().getAZType()),
               topoLinkTermination);
4) save topoLink within a transaction.

When I run the program, the console prints following:

Code:
Hibernate:
    /* insert com.wish.network_mgr.gdwPersistence.data.mainData.TopoLink
        */ insert
        into
            GDW2.TOPO_LINK
            (NET_CODE, TOPO_LINK_ID, USER_LABEL, NATIVE_NAME, OWNER, DIRECTION, TOPO_LINK_RATE, ADDITIONAL_INFO, TOPO_LINK_CODE)
        values
            (?, ?, ?, ?, ?, ?, ?, ?, ?)
Hibernate:
    /* insert com.wish.network_mgr.gdwPersistence.data.mainData.TopoLinkTermination
        */ insert
        into
            GDW2.TOPO_LINK_TERMINATION
            (PROP_VALUE, TOPO_LINK_CODE, PROP_NAME, A_Z_TYPE)
        values
            (?, ?, ?, ?)
13:46:49,479  WARN JDBCExceptionReporter:71 - SQL Error: 2291, SQLState: 23000
13:46:49,539 ERROR JDBCExceptionReporter:72 - ORA-02291: integrity constraint (GDW2.SYS_C007614) violated - parent key not found

But what strange is: when save the topoLink object first in a transaction,and then save topoLinkTermination in an another transaction as following:
Code:
1)create TopoLink instance(topoLink);
2) save topoLink;
3)create TopoLinkTermination instance(topoLinkTermination);
4)       topoLinkTermination.setTopoLink(topoLink);
       topoLink.getTopoLinkTerminations().put(
               new CMapKeyForTopoLinkTerm(topoLinkTermination.getId().getPropName(),
                                          topoLinkTermination.getId().getAZType()),
               topoLinkTermination);
5) save topoLinkTermination.

It goes well.

Could anyone tell me why first program is wrong?
Thanks.


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.