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  |
Eclipse User |
|
|
|
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 #429010 is a reply to message #429007] |
Mon, 06 April 2009 15:26   |
Eclipse User |
|
|
|
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 #429021 is a reply to message #429018] |
Mon, 06 April 2009 16:03   |
Eclipse User |
|
|
|
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  |
Eclipse User |
|
|
|
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.
>>>
>>>
>
>
|
|
|
Goto Forum:
Current Time: Wed Nov 05 10:51:45 EST 2025
Powered by FUDForum. Page generated in 0.04576 seconds
|