-->
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: Direction of the cascade causing not-null violation
PostPosted: Wed Jun 29, 2005 11:12 am 
Newbie

Joined: Wed Jun 29, 2005 11:00 am
Posts: 2
The error looks like this:

----> NHibernate.HibernateException : not-null property references a null or transient value: EmployeePayment, Payroll
at NHibernate.Impl.SessionImpl.SaveWithGeneratedIdentifier(Object obj, CascadingAction action, Object anything)

The offending property is in a many to one relationship, Many payments to one payroll. This worked in .71 but with .84 I get the above error. In this case, the payroll and associated payments are all created outside of a session, then the session saveorupdate is called on the payroll (parent) instance. I have verified the payment has a reference to the correct payroll, and that the payroll has the correct unsaved value for id. It seems that the code is trying to save the payment before the parent payroll is saved. Suggestions?

The payment def (employee payment is a subclass)
Code:
<class name="PayrollDomain.Payroll.Payment, PayrollDomain" table="Payment">
      <id name="Id" access="nosetter.camelcase-underscore" column="Id" type="Int32" unsaved-value="0">
         <generator class="identity" />
      </id>
      
      <discriminator column="PaymentType" type="String" />
      
      <many-to-one name="Payroll" class="PayrollDomain.Payroll.Payroll, PayrollDomain" column="PayrollId"
         cascade="none" not-null="true" />


The payroll def
Code:
<class name="PayrollDomain.Payroll.Payroll, PayrollDomain" table="Payroll">
      <id name="Id" access="nosetter.camelcase-underscore" column="Id" type="Int32" unsaved-value="0">
         <generator class="identity" />
      </id>
      <snip>      
      
      <bag name="_employeePayments" access="field" cascade="all" inverse="true">
         <key column="PayrollId" />
         <one-to-many class="PayrollDomain.Payroll.EmployeePayment, PayrollDomain" />
      </bag>


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.