-->
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.  [ 6 posts ] 
Author Message
 Post subject: Cannot save composite ID object.
PostPosted: Tue Jul 10, 2007 3:59 am 
Newbie

Joined: Tue Mar 27, 2007 11:34 pm
Posts: 13
Suppose I had the following resources:
Quote:
A.hbm.xml

Code:
<hibernate-mapping xmlns="urn:nhibernate-mapping-2.2">
   <class name="A, Date" table="A" lazy="false">
      <id name="ID" column="ID" type="Int32" unsaved-value="0">
         <generator class="native"/>
      </id>
      <set name="Bs" lazy="true" cascade="save-update" inverse="true">
         <key column="AID"/>
         <one-to-many class="B, Date"/>
      </set>
   </class>
</hibernate-mapping>


Quote:
B.hbm.xml

Code:
<hibernate-mapping xmlns="urn:nhibernate-mapping-2.2">
   <class name="B, Date" table="B" lazy="false">
      <composite-id>
         <key-many-to-one name="A" column="AID" class="A, Date"/>
         <key-property name="FromTime" column="`from`" type="DateTime"/>
      </composite-id>
   </class>
</hibernate-mapping>


After I save both a and b. Only a can be saved, I turn on the "show_sql" and I cannot find any insert statement to saving b object. Did I get any wrong?

Quote:
(PS: This problem not exists in NHibernate 1.0)


Top
 Profile  
 
 Post subject:
PostPosted: Thu Jul 12, 2007 1:52 am 
Newbie

Joined: Tue Mar 27, 2007 11:34 pm
Posts: 13
Did anyone know what's going on?


Top
 Profile  
 
 Post subject:
PostPosted: Thu Jul 12, 2007 3:04 pm 
Newbie

Joined: Wed May 02, 2007 9:32 am
Posts: 17
Try adding insert=true update=true to this line

<set name="Bs" lazy="true" cascade="save-update" inverse="true">


Top
 Profile  
 
 Post subject:
PostPosted: Fri Jul 13, 2007 8:11 am 
Senior
Senior

Joined: Thu Feb 09, 2006 1:30 pm
Posts: 172
If you provide the code you used to test these objects we may be able to provide additional assistance. Maybe there is a reason why nhibernate is not saving B. Maybe it was being saved as part of an earlier process, and we are just missing it. Please provide an entire test that shows the issue.


Top
 Profile  
 
 Post subject:
PostPosted: Mon Jul 16, 2007 5:02 am 
Newbie

Joined: Tue Mar 27, 2007 11:34 pm
Posts: 13
Here is the simple application for produce the problem:
http://jira.nhibernate.org/secure/attachment/12144/CompositeID.zip


Top
 Profile  
 
 Post subject:
PostPosted: Mon Jul 16, 2007 5:07 am 
Newbie

Joined: Tue Mar 27, 2007 11:34 pm
Posts: 13
joejoejoe wrote:
Try adding insert=true update=true to this line

<set name="Bs" lazy="true" cascade="save-update" inverse="true">


Seems insert is not a valid of the nhib 1.2 schema:
NHibernate.MappingException: The 'insert' attribute is not declared. ---> System

.Xml.Schema.XmlSchemaException: The 'insert' attribute is not declared.

at NHibernate.Cfg.Configuration.ValidationHandler(Object o, ValidationEventAr

gs args)

at System.Xml.Schema.BaseValidator.SendValidationEvent(XmlSchemaException e,

XmlSeverityType severity)

at System.Xml.Schema.XsdValidator.ValidateStartElement()

at System.Xml.Schema.XsdValidator.ProcessElement(Object particle)


Top
 Profile  
 
Display posts from previous:  Sort by  
Forum locked This topic is locked, you cannot edit posts or make further replies.  [ 6 posts ] 

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.