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: Parent/child with composite ids insert, update en delete
PostPosted: Wed Oct 14, 2009 8:30 am 
Newbie

Joined: Tue Sep 29, 2009 10:37 am
Posts: 2
Hello,

I have a table that exist of composite ids. A have two grids one displays the parent table en the other the child table. I need to update, insert and delete data in the grids. When I click save both grids date need to be saved. How do I do that with composite ids?

This is the mapping:
Code:
<?xml version="1.0" encoding="utf-8" ?>
<hibernate-mapping xmlns="urn:nhibernate-mapping-2.2">
  <class name="Domain.Parent,Domain" table="PARENT" lazy="true">
    <id name="Id" type="int" column="ID" unsaved-value="0" access="nosetter.camelcase-underscore">
      <generator class="native"/>
    </id>   
    <property name="TsCreate" column="TS_CREATE"/>
    <property name="TsMaint" column="TS_MAINT"/>
    <property name="UsCreate" column="US_CREATE"/>
    <property name="UsMaint" column="US_MAINT"/>
    <bag name="ChildList" inverse="true" lazy="true" cascade="all">
      <key column="IdParent" />
      <one-to-many class="Domain.Child,Domain" />
    </bag>
  </class>
</hibernate-mapping>

<?xml version="1.0" encoding="utf-8" ?>
<hibernate-mapping xmlns="urn:nhibernate-mapping-2.2">
  <class name="Domain.Child,Domain" table="CHILD" lazy="true">
    <composite-id>
      <key-property name="Year" column="YEAR"/>     
      <key-many-to-one name="IdParent"  column="ID_PARENT"/>
    </composite-id>     
    <property name="TsCreate" column="TS_CREATE"/>   
    <property name="UsCreate" column="US_CREATE"/>
    <property name="TsMaint" column="TS_MAINT"/>
    <property name="UsMaint" column="US_MAINT"/>   
  </class>
</hibernate-mapping>

Thanks in advance

Nyh


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.