Skip to main content



      Home
Home » Modeling » EMF » [teneo] org.hibernate.PropertyValueException when saving resource
[teneo] org.hibernate.PropertyValueException when saving resource [message #428997] Mon, 06 April 2009 12:54 Go to next message
Eclipse UserFriend
I am running the lastest ganymede Eclipse/EMF/Teneo on linux. Using
mysql 5.1.

I have a simple containment relationship where A contains B. When I
create A, add to resource, then create B and set A as the container via
setB(A) call in EMF I get the following exception:

org.hibernate.PropertyValueException: not-null property references a
null or transient value: NamedEquipmentList.facility
at org.hibernate.engine.Nullability.checkNullability(Nullabilit y.java:95)
at
org.hibernate.event.def.AbstractSaveEventListener.performSav eOrReplicate(AbstractSaveEventListener.java:313)
at
org.hibernate.event.def.AbstractSaveEventListener.performSav e(AbstractSaveEventListener.java:204)
at
org.hibernate.event.def.AbstractSaveEventListener.saveWithGe neratedId(AbstractSaveEventListener.java:130)
at
org.hibernate.event.def.DefaultSaveOrUpdateEventListener.sav eWithGeneratedOrRequestedId(DefaultSaveOrUpdateEventListener .java:210)
at
org.hibernate.event.def.DefaultSaveOrUpdateEventListener.ent ityIsTransient(DefaultSaveOrUpdateEventListener.java:195)
at
org.hibernate.event.def.DefaultSaveOrUpdateEventListener.per formSaveOrUpdate(DefaultSaveOrUpdateEventListener.java:117)
....more

I have explicitly added B to the list of B's in A and set all attributes
in both objects with no luck.

A may contain 1-many B BTW.

Thanks,
Mark.
Re: [teneo] org.hibernate.PropertyValueException when saving resource [message #429007 is a reply to message #428997] Mon, 06 April 2009 15:20 Go to previous messageGo to next message
Eclipse UserFriend
Hi Mark,
A==NamedEquipmentList and B==NamedEquipmentList.facility?

If not and facility is a non-containment then probably there is no cascade set on that association. You can either set a
cascade annotation on it or use the persistence options:
SET_DEFAULT_CASCADE_ON_NON_CONTAINMENT
CASCADE_POLICY_ON_NON_CONTAINMENT

gr. Martin

Mark Geib wrote:
> I am running the lastest ganymede Eclipse/EMF/Teneo on linux. Using
> mysql 5.1.
>
> I have a simple containment relationship where A contains B. When I
> create A, add to resource, then create B and set A as the container via
> setB(A) call in EMF I get the following exception:
>
> org.hibernate.PropertyValueException: not-null property references a
> null or transient value: NamedEquipmentList.facility
> at
> org.hibernate.engine.Nullability.checkNullability(Nullabilit y.java:95)
> at
> org.hibernate.event.def.AbstractSaveEventListener.performSav eOrReplicate(AbstractSaveEventListener.java:313)
>
> at
> org.hibernate.event.def.AbstractSaveEventListener.performSav e(AbstractSaveEventListener.java:204)
>
> at
> org.hibernate.event.def.AbstractSaveEventListener.saveWithGe neratedId(AbstractSaveEventListener.java:130)
>
> at
> org.hibernate.event.def.DefaultSaveOrUpdateEventListener.sav eWithGeneratedOrRequestedId(DefaultSaveOrUpdateEventListener .java:210)
>
> at
> org.hibernate.event.def.DefaultSaveOrUpdateEventListener.ent ityIsTransient(DefaultSaveOrUpdateEventListener.java:195)
>
> at
> org.hibernate.event.def.DefaultSaveOrUpdateEventListener.per formSaveOrUpdate(DefaultSaveOrUpdateEventListener.java:117)
>
> ....more
>
> I have explicitly added B to the list of B's in A and set all attributes
> in both objects with no luck.
>
> A may contain 1-many B BTW.
>
> Thanks,
> Mark.


--

With Regards, Martin Taal

Springsite/Elver.org
Office: Hardwareweg 4, 3821 BV Amersfoort
Postal: Nassaulaan 7, 3941 EC Doorn
The Netherlands
Cell: +31 (0)6 288 48 943
Tel: +31 (0)84 420 2397
Fax: +31 (0)84 225 9307
Mail: mtaal@springsite.com - mtaal@elver.org
Web: www.springsite.com - www.elver.org
Re: [teneo] org.hibernate.PropertyValueException when saving resource [message #429010 is a reply to message #429007] Mon, 06 April 2009 15:26 Go to previous messageGo to next message
Eclipse UserFriend
Hi Mark,
As an extra: here is also some background info for this type of exception. This type of exception occurs because there
is a reference to another object which is not yet persisted (known to hibernate).
There are two solutions:
1) first persist the refered-to object. Although this can sound impractical many times (in case of many-to-one
relations) the business logic works this way already, i.e. master data is persisted/created before creating/entering
transactional data.
2) If the association has specific cascade annotations set then hibernate will traverse the association and persist the
refered-to object (no exception in that case) before persisting the refering object.
For setting cascade annotations see my previous post.

gr. Martin

Martin Taal wrote:
> Hi Mark,
> A==NamedEquipmentList and B==NamedEquipmentList.facility?
>
> If not and facility is a non-containment then probably there is no
> cascade set on that association. You can either set a cascade annotation
> on it or use the persistence options:
> SET_DEFAULT_CASCADE_ON_NON_CONTAINMENT
> CASCADE_POLICY_ON_NON_CONTAINMENT
>
> gr. Martin
>
> Mark Geib wrote:
>> I am running the lastest ganymede Eclipse/EMF/Teneo on linux. Using
>> mysql 5.1.
>>
>> I have a simple containment relationship where A contains B. When I
>> create A, add to resource, then create B and set A as the container
>> via setB(A) call in EMF I get the following exception:
>>
>> org.hibernate.PropertyValueException: not-null property references a
>> null or transient value: NamedEquipmentList.facility
>> at
>> org.hibernate.engine.Nullability.checkNullability(Nullabilit y.java:95)
>> at
>> org.hibernate.event.def.AbstractSaveEventListener.performSav eOrReplicate(AbstractSaveEventListener.java:313)
>>
>> at
>> org.hibernate.event.def.AbstractSaveEventListener.performSav e(AbstractSaveEventListener.java:204)
>>
>> at
>> org.hibernate.event.def.AbstractSaveEventListener.saveWithGe neratedId(AbstractSaveEventListener.java:130)
>>
>> at
>> org.hibernate.event.def.DefaultSaveOrUpdateEventListener.sav eWithGeneratedOrRequestedId(DefaultSaveOrUpdateEventListener .java:210)
>>
>> at
>> org.hibernate.event.def.DefaultSaveOrUpdateEventListener.ent ityIsTransient(DefaultSaveOrUpdateEventListener.java:195)
>>
>> at
>> org.hibernate.event.def.DefaultSaveOrUpdateEventListener.per formSaveOrUpdate(DefaultSaveOrUpdateEventListener.java:117)
>>
>> ....more
>>
>> I have explicitly added B to the list of B's in A and set all
>> attributes in both objects with no luck.
>>
>> A may contain 1-many B BTW.
>>
>> Thanks,
>> Mark.
>
>


--

With Regards, Martin Taal

Springsite/Elver.org
Office: Hardwareweg 4, 3821 BV Amersfoort
Postal: Nassaulaan 7, 3941 EC Doorn
The Netherlands
Cell: +31 (0)6 288 48 943
Tel: +31 (0)84 420 2397
Fax: +31 (0)84 225 9307
Mail: mtaal@springsite.com - mtaal@elver.org
Web: www.springsite.com - www.elver.org
Re: [teneo] org.hibernate.PropertyValueException when saving resource [message #429015 is a reply to message #429007] Mon, 06 April 2009 15:46 Go to previous messageGo to next message
Eclipse UserFriend
Martin,

Sorry, no A is a Facility and B is a NamedEquipmentList.

Facility contains one and only one NamedEquipmentList,
NamedEquipmentList has a one and only one relatioship to the Facility
that contains it.

Mark.

Martin Taal wrote:
> Hi Mark,
> A==NamedEquipmentList and B==NamedEquipmentList.facility?
>
> If not and facility is a non-containment then probably there is no
> cascade set on that association. You can either set a cascade annotation
> on it or use the persistence options:
> SET_DEFAULT_CASCADE_ON_NON_CONTAINMENT
> CASCADE_POLICY_ON_NON_CONTAINMENT
>
> gr. Martin
>
> Mark Geib wrote:
>> I am running the lastest ganymede Eclipse/EMF/Teneo on linux. Using
>> mysql 5.1.
>>
>> I have a simple containment relationship where A contains B. When I
>> create A, add to resource, then create B and set A as the container
>> via setB(A) call in EMF I get the following exception:
>>
>> org.hibernate.PropertyValueException: not-null property references a
>> null or transient value: NamedEquipmentList.facility
>> at
>> org.hibernate.engine.Nullability.checkNullability(Nullabilit y.java:95)
>> at
>> org.hibernate.event.def.AbstractSaveEventListener.performSav eOrReplicate(AbstractSaveEventListener.java:313)
>>
>> at
>> org.hibernate.event.def.AbstractSaveEventListener.performSav e(AbstractSaveEventListener.java:204)
>>
>> at
>> org.hibernate.event.def.AbstractSaveEventListener.saveWithGe neratedId(AbstractSaveEventListener.java:130)
>>
>> at
>> org.hibernate.event.def.DefaultSaveOrUpdateEventListener.sav eWithGeneratedOrRequestedId(DefaultSaveOrUpdateEventListener .java:210)
>>
>> at
>> org.hibernate.event.def.DefaultSaveOrUpdateEventListener.ent ityIsTransient(DefaultSaveOrUpdateEventListener.java:195)
>>
>> at
>> org.hibernate.event.def.DefaultSaveOrUpdateEventListener.per formSaveOrUpdate(DefaultSaveOrUpdateEventListener.java:117)
>>
>> ....more
>>
>> I have explicitly added B to the list of B's in A and set all
>> attributes in both objects with no luck.
>>
>> A may contain 1-many B BTW.
>>
>> Thanks,
>> Mark.
>
>
Re: [teneo] org.hibernate.PropertyValueException when saving resource [message #429018 is a reply to message #429007] Mon, 06 April 2009 15:47 Go to previous messageGo to next message
Eclipse UserFriend
Martin,

Sorry, to quick on the send button.

Where do I set these options, in the ehb file.??

Mark.

Martin Taal wrote:
> Hi Mark,
> A==NamedEquipmentList and B==NamedEquipmentList.facility?
>
> If not and facility is a non-containment then probably there is no
> cascade set on that association. You can either set a cascade annotation
> on it or use the persistence options:
> SET_DEFAULT_CASCADE_ON_NON_CONTAINMENT
> CASCADE_POLICY_ON_NON_CONTAINMENT
>
> gr. Martin
>
> Mark Geib wrote:
>> I am running the lastest ganymede Eclipse/EMF/Teneo on linux. Using
>> mysql 5.1.
>>
>> I have a simple containment relationship where A contains B. When I
>> create A, add to resource, then create B and set A as the container
>> via setB(A) call in EMF I get the following exception:
>>
>> org.hibernate.PropertyValueException: not-null property references a
>> null or transient value: NamedEquipmentList.facility
>> at
>> org.hibernate.engine.Nullability.checkNullability(Nullabilit y.java:95)
>> at
>> org.hibernate.event.def.AbstractSaveEventListener.performSav eOrReplicate(AbstractSaveEventListener.java:313)
>>
>> at
>> org.hibernate.event.def.AbstractSaveEventListener.performSav e(AbstractSaveEventListener.java:204)
>>
>> at
>> org.hibernate.event.def.AbstractSaveEventListener.saveWithGe neratedId(AbstractSaveEventListener.java:130)
>>
>> at
>> org.hibernate.event.def.DefaultSaveOrUpdateEventListener.sav eWithGeneratedOrRequestedId(DefaultSaveOrUpdateEventListener .java:210)

>>
>> at
>> org.hibernate.event.def.DefaultSaveOrUpdateEventListener.ent ityIsTransient(DefaultSaveOrUpdateEventListener.java:195)
>>
>> at
>> org.hibernate.event.def.DefaultSaveOrUpdateEventListener.per formSaveOrUpdate(DefaultSaveOrUpdateEventListener.java:117)
>>
>> ....more
>>
>> I have explicitly added B to the list of B's in A and set all
>> attributes in both objects with no luck.
>>
>> A may contain 1-many B BTW.
>>
>> Thanks,
>> Mark.
>
>
Re: [teneo] org.hibernate.PropertyValueException when saving resource [message #429021 is a reply to message #429018] Mon, 06 April 2009 16:03 Go to previous messageGo to next message
Eclipse UserFriend
Mark,
You can pass them to the datastore, the class PersistenceOptions has constants with the correct name of the options. See
here for a complete set of the options:
http://www.elver.org/hibernate/options.html

Or you can annotate the NamedEquipmentList.facility efeature with a ManyToOne with cascade options set.

Hmm, the only strange thing to me is the point when you get this exception, exactly when doing setB(A)? And the
NamedEquipmentList was already persisted/saved (you have called resource.save before doing setB(A))?

gr. Martin

Mark Geib wrote:
> Martin,
>
> Sorry, to quick on the send button.
>
> Where do I set these options, in the ehb file.??
>
> Mark.
>
> Martin Taal wrote:
>> Hi Mark,
>> A==NamedEquipmentList and B==NamedEquipmentList.facility?
>>
>> If not and facility is a non-containment then probably there is no
>> cascade set on that association. You can either set a cascade
>> annotation on it or use the persistence options:
>> SET_DEFAULT_CASCADE_ON_NON_CONTAINMENT
>> CASCADE_POLICY_ON_NON_CONTAINMENT
>>
>> gr. Martin
>>
>> Mark Geib wrote:
>>> I am running the lastest ganymede Eclipse/EMF/Teneo on linux. Using
>>> mysql 5.1.
>>>
>>> I have a simple containment relationship where A contains B. When I
>>> create A, add to resource, then create B and set A as the container
>>> via setB(A) call in EMF I get the following exception:
>>>
>>> org.hibernate.PropertyValueException: not-null property references a
>>> null or transient value: NamedEquipmentList.facility
>>> at
>>> org.hibernate.engine.Nullability.checkNullability(Nullabilit y.java:95)
>>> at
>>> org.hibernate.event.def.AbstractSaveEventListener.performSav eOrReplicate(AbstractSaveEventListener.java:313)
>>>
>>> at
>>> org.hibernate.event.def.AbstractSaveEventListener.performSav e(AbstractSaveEventListener.java:204)
>>>
>>> at
>>> org.hibernate.event.def.AbstractSaveEventListener.saveWithGe neratedId(AbstractSaveEventListener.java:130)
>>>
>>> at
>>> org.hibernate.event.def.DefaultSaveOrUpdateEventListener.sav eWithGeneratedOrRequestedId(DefaultSaveOrUpdateEventListener .java:210)
>
>
>>>
>>> at
>>> org.hibernate.event.def.DefaultSaveOrUpdateEventListener.ent ityIsTransient(DefaultSaveOrUpdateEventListener.java:195)
>>>
>>> at
>>> org.hibernate.event.def.DefaultSaveOrUpdateEventListener.per formSaveOrUpdate(DefaultSaveOrUpdateEventListener.java:117)
>>>
>>> ....more
>>>
>>> I have explicitly added B to the list of B's in A and set all
>>> attributes in both objects with no luck.
>>>
>>> A may contain 1-many B BTW.
>>>
>>> Thanks,
>>> Mark.
>>
>>


--

With Regards, Martin Taal

Springsite/Elver.org
Office: Hardwareweg 4, 3821 BV Amersfoort
Postal: Nassaulaan 7, 3941 EC Doorn
The Netherlands
Cell: +31 (0)6 288 48 943
Tel: +31 (0)84 420 2397
Fax: +31 (0)84 225 9307
Mail: mtaal@springsite.com - mtaal@elver.org
Web: www.springsite.com - www.elver.org
Re: [teneo] org.hibernate.PropertyValueException when saving resource [message #429031 is a reply to message #429021] Mon, 06 April 2009 16:59 Go to previous message
Eclipse UserFriend
Martin,

Thanks.

No, the exception is on the first call to save the resource. The objects
are created and populated and all the references set, then save is
called. The db is empty, so all the objects in this case are created at
one time.

Mark.



Martin Taal wrote:
> Mark,
> You can pass them to the datastore, the class PersistenceOptions has
> constants with the correct name of the options. See here for a complete
> set of the options:
> http://www.elver.org/hibernate/options.html
>
> Or you can annotate the NamedEquipmentList.facility efeature with a
> ManyToOne with cascade options set.
>
> Hmm, the only strange thing to me is the point when you get this
> exception, exactly when doing setB(A)? And the NamedEquipmentList was
> already persisted/saved (you have called resource.save before doing
> setB(A))?
>
> gr. Martin
>
> Mark Geib wrote:
>> Martin,
>>
>> Sorry, to quick on the send button.
>>
>> Where do I set these options, in the ehb file.??
>>
>> Mark.
>>
>> Martin Taal wrote:
>>> Hi Mark,
>>> A==NamedEquipmentList and B==NamedEquipmentList.facility?
>>>
>>> If not and facility is a non-containment then probably there is no
>>> cascade set on that association. You can either set a cascade
>>> annotation on it or use the persistence options:
>>> SET_DEFAULT_CASCADE_ON_NON_CONTAINMENT
>>> CASCADE_POLICY_ON_NON_CONTAINMENT
>>>
>>> gr. Martin
>>>
>>> Mark Geib wrote:
>>>> I am running the lastest ganymede Eclipse/EMF/Teneo on linux. Using
>>>> mysql 5.1.
>>>>
>>>> I have a simple containment relationship where A contains B. When I
>>>> create A, add to resource, then create B and set A as the container
>>>> via setB(A) call in EMF I get the following exception:
>>>>
>>>> org.hibernate.PropertyValueException: not-null property references a
>>>> null or transient value: NamedEquipmentList.facility
>>>> at
>>>> org.hibernate.engine.Nullability.checkNullability(Nullabilit y.java:95)
>>>> at
>>>> org.hibernate.event.def.AbstractSaveEventListener.performSav eOrReplicate(AbstractSaveEventListener.java:313)
>>>>
>>>> at
>>>> org.hibernate.event.def.AbstractSaveEventListener.performSav e(AbstractSaveEventListener.java:204)
>>>>
>>>> at
>>>> org.hibernate.event.def.AbstractSaveEventListener.saveWithGe neratedId(AbstractSaveEventListener.java:130)
>>>>
>>>> at
>>>> org.hibernate.event.def.DefaultSaveOrUpdateEventListener.sav eWithGeneratedOrRequestedId(DefaultSaveOrUpdateEventListener .java:210)
>>
>>
>>
>>>>
>>>> at
>>>> org.hibernate.event.def.DefaultSaveOrUpdateEventListener.ent ityIsTransient(DefaultSaveOrUpdateEventListener.java:195)
>>>>
>>>> at
>>>> org.hibernate.event.def.DefaultSaveOrUpdateEventListener.per formSaveOrUpdate(DefaultSaveOrUpdateEventListener.java:117)
>>>>
>>>> ....more
>>>>
>>>> I have explicitly added B to the list of B's in A and set all
>>>> attributes in both objects with no luck.
>>>>
>>>> A may contain 1-many B BTW.
>>>>
>>>> Thanks,
>>>> Mark.
>>>
>>>
>
>
Previous Topic:Importing and referecing metamodels
Next Topic:[CDO] Query API
Goto Forum:
  


Current Time: Wed Nov 05 10:50:18 EST 2025

Powered by FUDForum. Page generated in 0.24723 seconds
.:: Contact :: Home ::.

Powered by: FUDforum 3.0.2.
Copyright ©2001-2010 FUDforum Bulletin Board Software

Back to the top