Win a copy of 97 Things Every Java Programmer Should Know this week in the Java in General forum!
  • Post Reply Bookmark Topic Watch Topic
  • New Topic
programming forums Java Mobile Certification Databases Caching Books Engineering Micro Controllers OS Languages Paradigms IDEs Build Tools Frameworks Application Servers Open Source This Site Careers Other all forums
this forum made possible by our volunteer staff, including ...
Marshals:
  • Campbell Ritchie
  • Paul Clapham
  • Jeanne Boyarsky
  • Junilu Lacar
  • Henry Wong
Sheriffs:
  • Ron McLeod
  • Devaka Cooray
  • Tim Cooke
Saloon Keepers:
  • Tim Moores
  • Stephan van Hulst
  • Frits Walraven
  • Tim Holloway
  • Carey Brown
Bartenders:
  • Piet Souris
  • salvin francis
  • fred rosenberger

Not-null property references a null or transient value

 
Greenhorn
Posts: 5
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Hello all,

I'm virgin working on Hibernate.Can any one please help me out with the problem i'm having.

Problem-

I have Three tables -

Agreement ,Item,ItemCategories

Agreement has one -many relation with both Items and ItemCategories .

ItemCatogeries has one-many relation with Items.

When i create Agreement record ,i need to store n records in Both the other tables(Both has relation).


The problem i'm getting is exception in item table saying..Not-null property references a null or transient value for class Itemcategory in Item.

I'm having lot of files to attach.So if any one had this problem before and solved .........please help me out

Quick help would be Appreciated.

 
Ranch Hand
Posts: 65
Android Chrome Java
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Can i see your mapping files?
 
Ranch Hand
Posts: 317
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
A quick guess would be that the ItemCategory object is null and hence throws this exception. Proabably posting the code snippet here would be helpful.
 
Jaya Sasindra Kanneganti
Greenhorn
Posts: 5
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Agreement:-

<hibernate-mapping>
<class name="com.waynedalton.bcp.beans.releaseagreement.ReleaseAgreement" table="ReleaseAgreement">

<id name="id" column="releaseAgreementId" type="string">
<generator class="guid" />
</id>

<property name="revisionNumber" column="revisionNo" type="integer" />
<property name="locationName" type="string" />
<property name="startDate" type="date" />
<property name="endDate" type="date" />
<property name="dealerId" type="string" />
<property name="notes" type="string" />
<many-to-one name="contract" column="contractId" class="com.waynedalton.bcp.beans.contract.Contract" not-null="true" />
<!-- <many-to-one name="contractId" column="contractId" unique="true" not-null="true" cascade="all" />-->
<many-to-one name="multiplier" column="multiplierId" cascade="none" />
<many-to-one name="address" column="addressId" unique="true" />

<bag name="items" cascade="all-delete-orphan" inverse="true" order-by="releaseAgreementLineNo">
<key column="releaseAgreementId" not-null="true" />
<one-to-many class="com.waynedalton.bcp.beans.releaseagreementitem.ReleaseAgreementItem" />
</bag>
<bag name="categories" cascade="all-delete-orphan" inverse="true" lazy="true" order-by="[name]">
<key column="releaseAgreementId" not-null="true" />
<one-to-many class="com.waynedalton.bcp.beans.releaseagreementitem.ItemCategory" />
</bag>



<property name="updatedOn" column="lastUpdated" type="date" />
</class>
</hibernate-mapping>

Item Table:-

<hibernate-mapping>
<class name="com.waynedalton.bcp.beans.releaseagreementitem.ReleaseAgreementItem" table="ReleaseAgreementItem">
<id name="id" column="releaseAgreementItemId" type="string">
<generator class="guid" />
</id>
<property name="revisionNumber" column="revisionNo" type="integer" />
<property name="lineNumber" column="releaseAgreementLineNo" type="integer" />
<property name="quantityReleased" column="releaseQty" type="float" />
<property name="priceGoodUntil" type="date" />
<many-to-one name="contractItem" column="contractItemId" unique="true" not-null="true" cascade="none" />
<many-to-one name="category" column="releaseAgreementItemCategoryId" class="com.waynedalton.bcp.beans.releaseagreementitem.ItemCategory" not-null="true" />
<property name="updatedOn" column="lastUpdated" type="date" />

<many-to-one name="releaseAgreement" column="releaseAgreementId" class="com.waynedalton.bcp.beans.releaseagreement.ReleaseAgreement" not-null="true" />

</class>
</hibernate-mapping>


ItemCategory:-

<hibernate-mapping>
<class name="com.waynedalton.bcp.beans.releaseagreementitem.ItemCategory" table="ReleaseAgreementItemCategory">
<id name="id" column="releaseAgreementItemCategoryId" type="string">
<generator class="guid" />
</id>
<property name="name" type="string" />
<property name="description" type="string" />
<property name="maxQty" type="float" />
<property name="systemCategory" type="boolean" />
<property name="updatedOn" column="lastUpdated" type="date" />

<many-to-one name="releaseAgreement" column="releaseAgreementId" class="com.waynedalton.bcp.beans.releaseagreement.ReleaseAgreement" not-null="true" />
<set name="agreementItems" cascade="all-delete-orphan" inverse="true">
<key column="releaseAgreementItemCategoryId" not-null="true" />
<one-to-many class="com.waynedalton.bcp.beans.releaseagreementitem.ReleaseAgreementItem" />
</set>

</class>
</hibernate-mapping>


Thats what i have from mapping side...can an one provide an example to store info in these three tables at a time..
 
This is awkward. I've grown a second evil head. I'm going to need a machete and a tiny ad ...
Devious Experiments for a Truly Passive Greenhouse!
https://www.kickstarter.com/projects/paulwheaton/greenhouse-1
    Bookmark Topic Watch Topic
  • New Topic