The "One Laptop Per Child" project has a great device ready to ship, but there's no Java on there. Let's think about working together to put Java on OLPC!
[Teneo] containment changes - problems with resaving
At 5:07 PM
on Aug 1, 2008,
Otto
wrote:
Hi guys,
I'm experiencing some problems when changing the containment position
inside the containment tree (drag-n-drop in a treeview) and then try to
resave it with teneo. When moving a element from one to another
container i get 1 of 2 different exceptions, it depends on the case, but
i couldn't distinquish yet when which case is triggered.
#1
te.exception.ConstraintViolationException: could not delete: [Milestone#18]
[...]
java.sql.SQLException: Cannot delete or update a parent row: a foreign
key constraint fails (`model/annotation_annotatedmodelelements`,
CONSTRAINT `annotation_annotatedmodelelements` FOREIGN KEY
(`modelelement_e_id`) REFERENCES `modelelement`
(`identifiableelement_e_id`))
#2
deleted object would be re-saved by cascade, remove deleted object from
associations
I found http://www.elver.org/hibernate/hibernate_details.html#cutpaste on the teneo page. I tried setting this globaloption
PersistenceOptions.SET_CASCADE_ALL_ON_CONTAINMENT and didn't work and
threw more exceptions. The second solution to set an annotation for
every sing containment reference isnt really handy because we have quite
some different containment references.
I'm new to this and these erros don't tell me that much, so I would
really appreciate if you could give me some hints or even solutions.
Isn't there a easy way, i mean, changing containment is a common usecase?!
Re: [Teneo] containment changes - problems with resaving
Hi Otto,
Yes, cust-past (move) between containers does now work nicely with hibernate's orphan-delete.
What exceptions do you get when you set the PersistenceOptions.SET_CASCADE_ALL_ON_CONTAINMENT option?
gr. Martin
Otto wrote:
> Hi guys,
>
> I'm experiencing some problems when changing the containment position
> inside the containment tree (drag-n-drop in a treeview) and then try to
> resave it with teneo. When moving a element from one to another
> container i get 1 of 2 different exceptions, it depends on the case, but
> i couldn't distinquish yet when which case is triggered.
> #1
> te.exception.ConstraintViolationException: could not delete: [Milestone#18]
> [...]
> java.sql.SQLException: Cannot delete or update a parent row: a foreign
> key constraint fails (`model/annotation_annotatedmodelelements`,
> CONSTRAINT `annotation_annotatedmodelelements` FOREIGN KEY
> (`modelelement_e_id`) REFERENCES `modelelement`
> (`identifiableelement_e_id`))
>
> #2
> deleted object would be re-saved by cascade, remove deleted object from
> associations
>
> I found http://www.elver.org/hibernate/hibernate_details.html#cutpaste > on the teneo page. I tried setting this globaloption
> PersistenceOptions.SET_CASCADE_ALL_ON_CONTAINMENT and didn't work and
> threw more exceptions. The second solution to set an annotation for
> every sing containment reference isnt really handy because we have quite
> some different containment references.
>
> I'm new to this and these erros don't tell me that much, so I would
> really appreciate if you could give me some hints or even solutions.
> Isn't there a easy way, i mean, changing containment is a common usecase?!
>
> Thanks in advance.
>
> Greetings,
> Otto
ibernate.TransientObjectException: object references an unsaved
transient instance - save the transient instance before flushing:
ProjectHistory
at
org.hibernate.engine.ForeignKeys.getEntityIdentifierIfNotUnsaved(ForeignKeys.java:219)
But on http://www.elver.org/hibernate/options.html I read that you have
to set it to true in order to enable orphan-delete. I tried that too.
Saving the first time didn't make any problems (as without the option).
but then i moved a object and got:
org.hibernate.ObjectDeletedException: deleted object would be re-saved
by cascade (remove deleted object from associations): [MergingSolution#26]
at org.hibernate.impl.SessionImpl.forceFlush(SessionImpl.java:1014)
at
org.hibernate.event.def.DefaultSaveOrUpdateEventListener.entityIsTransient(DefaultSaveOrUpdateEventListener.java:165)
at
org.hibernate.event.def.DefaultSaveOrUpdateEventListener.performSaveOrUpdate(DefaultSaveOrUpdateEventListener.java:94)
at
org.hibernate.event.def.DefaultSaveOrUpdateEventListener.onSaveOrUpdate(DefaultSaveOrUpdateEventListener.java:70)
at org.hibernate.impl.SessionImpl.fireSaveOrUpdate(SessionImpl.java:507)
at org.hibernate.impl.SessionImpl.saveOrUpdate(SessionImpl.java:499)
at org.hibernate.engine.CascadingAction$5.cascade(CascadingAction.java:218)
at org.hibernate.engine.Cascade.cascadeToOne(Cascade.java:268)
at org.hibernate.engine.Cascade.cascadeAssociation(Cascade.java:216)
at org.hibernate.engine.Cascade.cascadeProperty(Cascade.java:169)
Does this say anthing to you?
Greetings,
Otto
Martin Taal schrieb:
> Hi Otto,
> Yes, cust-past (move) between containers does now work nicely with
> hibernate's orphan-delete.
>
> What exceptions do you get when you set the
> PersistenceOptions.SET_CASCADE_ALL_ON_CONTAINMENT option?
>
> gr. Martin
>
> Otto wrote:
>> Hi guys,
>>
>> I'm experiencing some problems when changing the containment position
>> inside the containment tree (drag-n-drop in a treeview) and then try
>> to resave it with teneo. When moving a element from one to another
>> container i get 1 of 2 different exceptions, it depends on the case,
>> but i couldn't distinquish yet when which case is triggered.
>> #1
>> te.exception.ConstraintViolationException: could not delete:
>> [Milestone#18]
>> [...]
>> java.sql.SQLException: Cannot delete or update a parent row: a foreign
>> key constraint fails (`model/annotation_annotatedmodelelements`,
>> CONSTRAINT `annotation_annotatedmodelelements` FOREIGN KEY
>> (`modelelement_e_id`) REFERENCES `modelelement`
>> (`identifiableelement_e_id`))
>>
>> #2
>> deleted object would be re-saved by cascade, remove deleted object
>> from associations
>>
>> I found http://www.elver.org/hibernate/hibernate_details.html#cutpaste >> on the teneo page. I tried setting this globaloption
>> PersistenceOptions.SET_CASCADE_ALL_ON_CONTAINMENT and didn't work and
>> threw more exceptions. The second solution to set an annotation for
>> every sing containment reference isnt really handy because we have
>> quite some different containment references.
>>
>> I'm new to this and these erros don't tell me that much, so I would
>> really appreciate if you could give me some hints or even solutions.
>> Isn't there a easy way, i mean, changing containment is a common
>> usecase?!
>>
>> Thanks in advance.
>>
>> Greetings,
>> Otto
>
>
Re: [Teneo] containment changes - problems with resaving
Hi Otto,
Hmm, another approach is the following, can you use the following combination of options:
CASCADE_POLICY_ON_CONTAINMENT to REMOVE,REFRESH,PERSIST,MERGE
SET_CASCADE_ALL_ON_CONTAINMENT to false
gr. Martin
Otto wrote:
> Hi Martin,
>
> thanks for your quick answer! As described on
> http://www.elver.org/hibernate/hibernate_details.html#cutpaste i set
> PersistenceOptions.SET_CASCADE_ALL_ON_CONTAINMENT to false, but then i
> couldn't even save the first time:
>
> ibernate.TransientObjectException: object references an unsaved
> transient instance - save the transient instance before flushing:
> ProjectHistory
> at
> org.hibernate.engine.ForeignKeys.getEntityIdentifierIfNotUnsaved(ForeignKeys.java:219)
>
>
> But on http://www.elver.org/hibernate/options.html I read that you have
> to set it to true in order to enable orphan-delete. I tried that too.
> Saving the first time didn't make any problems (as without the option).
> but then i moved a object and got:
>
> org.hibernate.ObjectDeletedException: deleted object would be re-saved
> by cascade (remove deleted object from associations): [MergingSolution#26]
> at org.hibernate.impl.SessionImpl.forceFlush(SessionImpl.java:1014)
> at
> org.hibernate.event.def.DefaultSaveOrUpdateEventListener.entityIsTransient(DefaultSaveOrUpdateEventListener.java:165)
>
> at
> org.hibernate.event.def.DefaultSaveOrUpdateEventListener.performSaveOrUpdate(DefaultSaveOrUpdateEventListener.java:94)
>
> at
> org.hibernate.event.def.DefaultSaveOrUpdateEventListener.onSaveOrUpdate(DefaultSaveOrUpdateEventListener.java:70)
>
> at
> org.hibernate.impl.SessionImpl.fireSaveOrUpdate(SessionImpl.java:507)
> at org.hibernate.impl.SessionImpl.saveOrUpdate(SessionImpl.java:499)
> at
> org.hibernate.engine.CascadingAction$5.cascade(CascadingAction.java:218)
> at org.hibernate.engine.Cascade.cascadeToOne(Cascade.java:268)
> at org.hibernate.engine.Cascade.cascadeAssociation(Cascade.java:216)
> at org.hibernate.engine.Cascade.cascadeProperty(Cascade.java:169)
>
> Does this say anthing to you?
>
> Greetings,
> Otto
>
> Martin Taal schrieb:
>> Hi Otto,
>> Yes, cust-past (move) between containers does now work nicely with
>> hibernate's orphan-delete.
>>
>> What exceptions do you get when you set the
>> PersistenceOptions.SET_CASCADE_ALL_ON_CONTAINMENT option?
>>
>> gr. Martin
>>
>> Otto wrote:
>>> Hi guys,
>>>
>>> I'm experiencing some problems when changing the containment position
>>> inside the containment tree (drag-n-drop in a treeview) and then try
>>> to resave it with teneo. When moving a element from one to another
>>> container i get 1 of 2 different exceptions, it depends on the case,
>>> but i couldn't distinquish yet when which case is triggered.
>>> #1
>>> te.exception.ConstraintViolationException: could not delete:
>>> [Milestone#18]
>>> [...]
>>> java.sql.SQLException: Cannot delete or update a parent row: a
>>> foreign key constraint fails
>>> (`model/annotation_annotatedmodelelements`, CONSTRAINT
>>> `annotation_annotatedmodelelements` FOREIGN KEY (`modelelement_e_id`)
>>> REFERENCES `modelelement` (`identifiableelement_e_id`))
>>>
>>> #2
>>> deleted object would be re-saved by cascade, remove deleted object
>>> from associations
>>>
>>> I found
>>> http://www.elver.org/hibernate/hibernate_details.html#cutpaste on the
>>> teneo page. I tried setting this globaloption
>>> PersistenceOptions.SET_CASCADE_ALL_ON_CONTAINMENT and didn't work and
>>> threw more exceptions. The second solution to set an annotation for
>>> every sing containment reference isnt really handy because we have
>>> quite some different containment references.
>>>
>>> I'm new to this and these erros don't tell me that much, so I would
>>> really appreciate if you could give me some hints or even solutions.
>>> Isn't there a easy way, i mean, changing containment is a common
>>> usecase?!
>>>
>>> Thanks in advance.
>>>
>>> Greetings,
>>> Otto
>>
>>
Re: [Teneo] containment changes - problems with resaving
Hi,
I tried that, setting SET_CASCADE_ALL_ON_CONTAINMENT to false (and
CASCADE_POLICY...) lead to the same problems as allready explained. And
setting CASCADE_POLICY_ON_CONTAINMENT to REMOVE,REFRESH,PERSIST,MERGE
alone allows to save but, still when you move a object and save i get a
Caused by: org.hibernate.ObjectDeletedException: deleted object would be
re-saved by cascade (remove deleted object from associations):
To be honest im fishing in the dark and just trying different setting
combinations.
Greetings,
Otto
Martin Taal schrieb:
> Hi Otto,
> Hmm, another approach is the following, can you use the following
> combination of options:
> CASCADE_POLICY_ON_CONTAINMENT to REMOVE,REFRESH,PERSIST,MERGE
> SET_CASCADE_ALL_ON_CONTAINMENT to false
>
> gr. Martin
>
> Otto wrote:
>> Hi Martin,
>>
>> thanks for your quick answer! As described on
>> http://www.elver.org/hibernate/hibernate_details.html#cutpaste i set
>> PersistenceOptions.SET_CASCADE_ALL_ON_CONTAINMENT to false, but then i
>> couldn't even save the first time:
>>
>> ibernate.TransientObjectException: object references an unsaved
>> transient instance - save the transient instance before flushing:
>> ProjectHistory
>> at
>> org.hibernate.engine.ForeignKeys.getEntityIdentifierIfNotUnsaved(ForeignKeys.java:219)
>>
>>
>> But on http://www.elver.org/hibernate/options.html I read that you
>> have to set it to true in order to enable orphan-delete. I tried that
>> too. Saving the first time didn't make any problems (as without the
>> option).
>> but then i moved a object and got:
>>
>> org.hibernate.ObjectDeletedException: deleted object would be re-saved
>> by cascade (remove deleted object from associations):
>> [MergingSolution#26]
>> at org.hibernate.impl.SessionImpl.forceFlush(SessionImpl.java:1014)
>> at
>> org.hibernate.event.def.DefaultSaveOrUpdateEventListener.entityIsTransient(DefaultSaveOrUpdateEventListener.java:165)
>>
>> at
>> org.hibernate.event.def.DefaultSaveOrUpdateEventListener.performSaveOrUpdate(DefaultSaveOrUpdateEventListener.java:94)
>>
>> at
>> org.hibernate.event.def.DefaultSaveOrUpdateEventListener.onSaveOrUpdate(DefaultSaveOrUpdateEventListener.java:70)
>>
>> at
>> org.hibernate.impl.SessionImpl.fireSaveOrUpdate(SessionImpl.java:507)
>> at org.hibernate.impl.SessionImpl.saveOrUpdate(SessionImpl.java:499)
>> at
>> org.hibernate.engine.CascadingAction$5.cascade(CascadingAction.java:218)
>> at org.hibernate.engine.Cascade.cascadeToOne(Cascade.java:268)
>> at org.hibernate.engine.Cascade.cascadeAssociation(Cascade.java:216)
>> at org.hibernate.engine.Cascade.cascadeProperty(Cascade.java:169)
>>
>> Does this say anthing to you?
>>
>> Greetings,
>> Otto
>>
>> Martin Taal schrieb:
>>> Hi Otto,
>>> Yes, cust-past (move) between containers does now work nicely with
>>> hibernate's orphan-delete.
>>>
>>> What exceptions do you get when you set the
>>> PersistenceOptions.SET_CASCADE_ALL_ON_CONTAINMENT option?
>>>
>>> gr. Martin
>>>
>>> Otto wrote:
>>>> Hi guys,
>>>>
>>>> I'm experiencing some problems when changing the containment
>>>> position inside the containment tree (drag-n-drop in a treeview) and
>>>> then try to resave it with teneo. When moving a element from one to
>>>> another container i get 1 of 2 different exceptions, it depends on
>>>> the case, but i couldn't distinquish yet when which case is triggered.
>>>> #1
>>>> te.exception.ConstraintViolationException: could not delete:
>>>> [Milestone#18]
>>>> [...]
>>>> java.sql.SQLException: Cannot delete or update a parent row: a
>>>> foreign key constraint fails
>>>> (`model/annotation_annotatedmodelelements`, CONSTRAINT
>>>> `annotation_annotatedmodelelements` FOREIGN KEY
>>>> (`modelelement_e_id`) REFERENCES `modelelement`
>>>> (`identifiableelement_e_id`))
>>>>
>>>> #2
>>>> deleted object would be re-saved by cascade, remove deleted object
>>>> from associations
>>>>
>>>> I found
>>>> http://www.elver.org/hibernate/hibernate_details.html#cutpaste on
>>>> the teneo page. I tried setting this globaloption
>>>> PersistenceOptions.SET_CASCADE_ALL_ON_CONTAINMENT and didn't work
>>>> and threw more exceptions. The second solution to set an annotation
>>>> for every sing containment reference isnt really handy because we
>>>> have quite some different containment references.
>>>>
>>>> I'm new to this and these erros don't tell me that much, so I would
>>>> really appreciate if you could give me some hints or even solutions.
>>>> Isn't there a easy way, i mean, changing containment is a common
>>>> usecase?!
>>>>
>>>> Thanks in advance.
>>>>
>>>> Greetings,
>>>> Otto
>>>
>>>
>
>
Re: [Teneo] containment changes - problems with resaving
Hi,
I still didn't manage to solve this issue. Can you maybe give me some
more hints where to look?
Thank you in advance,
Otto
Martin Taal schrieb:
> Hi Otto,
> Hmm, another approach is the following, can you use the following
> combination of options:
> CASCADE_POLICY_ON_CONTAINMENT to REMOVE,REFRESH,PERSIST,MERGE
> SET_CASCADE_ALL_ON_CONTAINMENT to false
>
> gr. Martin
>
> Otto wrote:
>> Hi Martin,
>>
>> thanks for your quick answer! As described on
>> http://www.elver.org/hibernate/hibernate_details.html#cutpaste i set
>> PersistenceOptions.SET_CASCADE_ALL_ON_CONTAINMENT to false, but then i
>> couldn't even save the first time:
>>
>> ibernate.TransientObjectException: object references an unsaved
>> transient instance - save the transient instance before flushing:
>> ProjectHistory
>> at
>> org.hibernate.engine.ForeignKeys.getEntityIdentifierIfNotUnsaved(ForeignKeys.java:219)
>>
>>
>> But on http://www.elver.org/hibernate/options.html I read that you
>> have to set it to true in order to enable orphan-delete. I tried that
>> too. Saving the first time didn't make any problems (as without the
>> option).
>> but then i moved a object and got:
>>
>> org.hibernate.ObjectDeletedException: deleted object would be re-saved
>> by cascade (remove deleted object from associations):
>> [MergingSolution#26]
>> at org.hibernate.impl.SessionImpl.forceFlush(SessionImpl.java:1014)
>> at
>> org.hibernate.event.def.DefaultSaveOrUpdateEventListener.entityIsTransient(DefaultSaveOrUpdateEventListener.java:165)
>>
>> at
>> org.hibernate.event.def.DefaultSaveOrUpdateEventListener.performSaveOrUpdate(DefaultSaveOrUpdateEventListener.java:94)
>>
>> at
>> org.hibernate.event.def.DefaultSaveOrUpdateEventListener.onSaveOrUpdate(DefaultSaveOrUpdateEventListener.java:70)
>>
>> at
>> org.hibernate.impl.SessionImpl.fireSaveOrUpdate(SessionImpl.java:507)
>> at org.hibernate.impl.SessionImpl.saveOrUpdate(SessionImpl.java:499)
>> at
>> org.hibernate.engine.CascadingAction$5.cascade(CascadingAction.java:218)
>> at org.hibernate.engine.Cascade.cascadeToOne(Cascade.java:268)
>> at org.hibernate.engine.Cascade.cascadeAssociation(Cascade.java:216)
>> at org.hibernate.engine.Cascade.cascadeProperty(Cascade.java:169)
>>
>> Does this say anthing to you?
>>
>> Greetings,
>> Otto
>>
>> Martin Taal schrieb:
>>> Hi Otto,
>>> Yes, cust-past (move) between containers does now work nicely with
>>> hibernate's orphan-delete.
>>>
>>> What exceptions do you get when you set the
>>> PersistenceOptions.SET_CASCADE_ALL_ON_CONTAINMENT option?
>>>
>>> gr. Martin
>>>
>>> Otto wrote:
>>>> Hi guys,
>>>>
>>>> I'm experiencing some problems when changing the containment
>>>> position inside the containment tree (drag-n-drop in a treeview) and
>>>> then try to resave it with teneo. When moving a element from one to
>>>> another container i get 1 of 2 different exceptions, it depends on
>>>> the case, but i couldn't distinquish yet when which case is triggered.
>>>> #1
>>>> te.exception.ConstraintViolationException: could not delete:
>>>> [Milestone#18]
>>>> [...]
>>>> java.sql.SQLException: Cannot delete or update a parent row: a
>>>> foreign key constraint fails
>>>> (`model/annotation_annotatedmodelelements`, CONSTRAINT
>>>> `annotation_annotatedmodelelements` FOREIGN KEY
>>>> (`modelelement_e_id`) REFERENCES `modelelement`
>>>> (`identifiableelement_e_id`))
>>>>
>>>> #2
>>>> deleted object would be re-saved by cascade, remove deleted object
>>>> from associations
>>>>
>>>> I found
>>>> http://www.elver.org/hibernate/hibernate_details.html#cutpaste on
>>>> the teneo page. I tried setting this globaloption
>>>> PersistenceOptions.SET_CASCADE_ALL_ON_CONTAINMENT and didn't work
>>>> and threw more exceptions. The second solution to set an annotation
>>>> for every sing containment reference isnt really handy because we
>>>> have quite some different containment references.
>>>>
>>>> I'm new to this and these erros don't tell me that much, so I would
>>>> really appreciate if you could give me some hints or even solutions.
>>>> Isn't there a easy way, i mean, changing containment is a common
>>>> usecase?!
>>>>
>>>> Thanks in advance.
>>>>
>>>> Greetings,
>>>> Otto
>>>
>>>
>
>
Re: [Teneo] containment changes - problems with resaving
With these latest settings what's the stacktrace you are seeing?
Are the source and target container in the same resource?
gr. Martin
Otto wrote:
> Hi,
>
> I still didn't manage to solve this issue. Can you maybe give me some
> more hints where to look?
>
> Thank you in advance,
> Otto
>
> Martin Taal schrieb:
>> Hi Otto,
>> Hmm, another approach is the following, can you use the following
>> combination of options:
>> CASCADE_POLICY_ON_CONTAINMENT to REMOVE,REFRESH,PERSIST,MERGE
>> SET_CASCADE_ALL_ON_CONTAINMENT to false
>>
>> gr. Martin
>>
>> Otto wrote:
>>> Hi Martin,
>>>
>>> thanks for your quick answer! As described on
>>> http://www.elver.org/hibernate/hibernate_details.html#cutpaste i set
>>> PersistenceOptions.SET_CASCADE_ALL_ON_CONTAINMENT to false, but then
>>> i couldn't even save the first time:
>>>
>>> ibernate.TransientObjectException: object references an unsaved
>>> transient instance - save the transient instance before flushing:
>>> ProjectHistory
>>> at
>>> org.hibernate.engine.ForeignKeys.getEntityIdentifierIfNotUnsaved(ForeignKeys.java:219)
>>>
>>>
>>> But on http://www.elver.org/hibernate/options.html I read that you
>>> have to set it to true in order to enable orphan-delete. I tried that
>>> too. Saving the first time didn't make any problems (as without the
>>> option).
>>> but then i moved a object and got:
>>>
>>> org.hibernate.ObjectDeletedException: deleted object would be
>>> re-saved by cascade (remove deleted object from associations):
>>> [MergingSolution#26]
>>> at org.hibernate.impl.SessionImpl.forceFlush(SessionImpl.java:1014)
>>> at
>>> org.hibernate.event.def.DefaultSaveOrUpdateEventListener.entityIsTransient(DefaultSaveOrUpdateEventListener.java:165)
>>>
>>> at
>>> org.hibernate.event.def.DefaultSaveOrUpdateEventListener.performSaveOrUpdate(DefaultSaveOrUpdateEventListener.java:94)
>>>
>>> at
>>> org.hibernate.event.def.DefaultSaveOrUpdateEventListener.onSaveOrUpdate(DefaultSaveOrUpdateEventListener.java:70)
>>>
>>> at
>>> org.hibernate.impl.SessionImpl.fireSaveOrUpdate(SessionImpl.java:507)
>>> at org.hibernate.impl.SessionImpl.saveOrUpdate(SessionImpl.java:499)
>>> at
>>> org.hibernate.engine.CascadingAction$5.cascade(CascadingAction.java:218)
>>> at org.hibernate.engine.Cascade.cascadeToOne(Cascade.java:268)
>>> at org.hibernate.engine.Cascade.cascadeAssociation(Cascade.java:216)
>>> at org.hibernate.engine.Cascade.cascadeProperty(Cascade.java:169)
>>>
>>> Does this say anthing to you?
>>>
>>> Greetings,
>>> Otto
>>>
>>> Martin Taal schrieb:
>>>> Hi Otto,
>>>> Yes, cust-past (move) between containers does now work nicely with
>>>> hibernate's orphan-delete.
>>>>
>>>> What exceptions do you get when you set the
>>>> PersistenceOptions.SET_CASCADE_ALL_ON_CONTAINMENT option?
>>>>
>>>> gr. Martin
>>>>
>>>> Otto wrote:
>>>>> Hi guys,
>>>>>
>>>>> I'm experiencing some problems when changing the containment
>>>>> position inside the containment tree (drag-n-drop in a treeview)
>>>>> and then try to resave it with teneo. When moving a element from
>>>>> one to another container i get 1 of 2 different exceptions, it
>>>>> depends on the case, but i couldn't distinquish yet when which
>>>>> case is triggered.
>>>>> #1
>>>>> te.exception.ConstraintViolationException: could not delete:
>>>>> [Milestone#18]
>>>>> [...]
>>>>> java.sql.SQLException: Cannot delete or update a parent row: a
>>>>> foreign key constraint fails
>>>>> (`model/annotation_annotatedmodelelements`, CONSTRAINT
>>>>> `annotation_annotatedmodelelements` FOREIGN KEY
>>>>> (`modelelement_e_id`) REFERENCES `modelelement`
>>>>> (`identifiableelement_e_id`))
>>>>>
>>>>> #2
>>>>> deleted object would be re-saved by cascade, remove deleted object
>>>>> from associations
>>>>>
>>>>> I found
>>>>> http://www.elver.org/hibernate/hibernate_details.html#cutpaste on
>>>>> the teneo page. I tried setting this globaloption
>>>>> PersistenceOptions.SET_CASCADE_ALL_ON_CONTAINMENT and didn't work
>>>>> and threw more exceptions. The second solution to set an annotation
>>>>> for every sing containment reference isnt really handy because we
>>>>> have quite some different containment references.
>>>>>
>>>>> I'm new to this and these erros don't tell me that much, so I would
>>>>> really appreciate if you could give me some hints or even
>>>>> solutions. Isn't there a easy way, i mean, changing containment is
>>>>> a common usecase?!
>>>>>
>>>>> Thanks in advance.
>>>>>
>>>>> Greetings,
>>>>> Otto
>>>>
>>>>
>>
>>
Re: [Teneo] containment changes - problems with resaving
Hi Martin,
I love your quick answers Current setting is
CASCADE_POLICY_ON_NON_CONTAINMENT = "REMOVE,REFRESH,PERSIST,MERGE" and
SET_CASCADE_ALL_ON_CONTAINMENT is not set at all. With this combination
saving works, but moving an element throws the exception. The container
are in the same resource.
org.eclipse.emf.teneo.hibernate.HbMapperException: Exception when saving
resource modelStore
at
org.eclipse.emf.teneo.hibernate.resource.HibernateResource.saveResource(HibernateResource.java:369)
at
org.eclipse.emf.teneo.resource.StoreResource.save(StoreResource.java:404)
at
org.unicase.emfstore.esmodel.impl.ServerSpaceImpl.save(ServerSpaceImpl.java:268)
at org.unicase.emfstore.EmfStoreImpl.save(EmfStoreImpl.java:332)
at org.unicase.emfstore.EmfStoreImpl.createVersion(EmfStoreImpl.java:110)
at
org.unicase.emfstore.connection.rmi.RMIEmfStoreFacadeImpl.createVersion(RMIEmfStoreFacadeImpl.java:89)
at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
at sun.reflect.NativeMethodAccessorImpl.invoke(Unknown Source)
at sun.reflect.DelegatingMethodAccessorImpl.invoke(Unknown Source)
at java.lang.reflect.Method.invoke(Unknown Source)
at sun.rmi.server.UnicastServerRef.dispatch(Unknown Source)
at sun.rmi.transport.Transport$1.run(Unknown Source)
at java.security.AccessController.doPrivileged(Native Method)
at sun.rmi.transport.Transport.serviceCall(Unknown Source)
at sun.rmi.transport.tcp.TCPTransport.handleMessages(Unknown Source)
at sun.rmi.transport.tcp.TCPTransport$ConnectionHandler.run0(Unknown
Source)
at sun.rmi.transport.tcp.TCPTransport$ConnectionHandler.run(Unknown Source)
at java.util.concurrent.ThreadPoolExecutor$Worker.runTask(Unknown Source)
at java.util.concurrent.ThreadPoolExecutor$Worker.run(Unknown Source)
at java.lang.Thread.run(Unknown Source)
Caused by: org.hibernate.ObjectDeletedException: deleted object would be
re-saved by cascade (remove deleted object from associations):
[LeafSection#630]
at org.hibernate.impl.SessionImpl.forceFlush(SessionImpl.java:1014)
at
org.hibernate.event.def.DefaultSaveOrUpdateEventListener.entityIsTransient(DefaultSaveOrUpdateEventListener.java:165)
at
org.hibernate.event.def.DefaultSaveOrUpdateEventListener.performSaveOrUpdate(DefaultSaveOrUpdateEventListener.java:94)
at
org.hibernate.event.def.DefaultSaveOrUpdateEventListener.onSaveOrUpdate(DefaultSaveOrUpdateEventListener.java:70)
at org.hibernate.impl.SessionImpl.fireSaveOrUpdate(SessionImpl.java:507)
at org.hibernate.impl.SessionImpl.saveOrUpdate(SessionImpl.java:499)
at org.hibernate.engine.CascadingAction$5.cascade(CascadingAction.java:218)
at org.hibernate.engine.Cascade.cascadeToOne(Cascade.java:268)
at org.hibernate.engine.Cascade.cascadeAssociation(Cascade.java:216)
at org.hibernate.engine.Cascade.cascadeProperty(Cascade.java:169)
at org.hibernate.engine.Cascade.cascadeCollectionElements(Cascade.java:296)
at org.hibernate.engine.Cascade.cascadeCollection(Cascade.java:242)
at org.hibernate.engine.Cascade.cascadeAssociation(Cascade.java:219)
at org.hibernate.engine.Cascade.cascadeProperty(Cascade.java:169)
at org.hibernate.engine.Cascade.cascade(Cascade.java:130)
at
org.hibernate.event.def.AbstractFlushingEventListener.cascadeOnFlush(AbstractFlushingEventListener.java:131)
at
org.hibernate.event.def.AbstractFlushingEventListener.prepareEntityFlushes(AbstractFlushingEventListener.java:122)
at
org.hibernate.event.def.AbstractFlushingEventListener.flushEverythingToExecutions(AbstractFlushingEventListener.java:65)
at
org.hibernate.event.def.DefaultFlushEventListener.onFlush(DefaultFlushEventListener.java:26)
at org.hibernate.impl.SessionImpl.flush(SessionImpl.java:1000)
at
org.eclipse.emf.teneo.hibernate.HbSessionWrapper.flush(HbSessionWrapper.java:171)
at
org.eclipse.emf.teneo.hibernate.resource.HibernateResource.saveResource(HibernateResource.java:363)
... 19 more
Martin Taal schrieb:
> With these latest settings what's the stacktrace you are seeing?
>
> Are the source and target container in the same resource?
>
> gr. Martin
>
> Otto wrote:
>> Hi,
>>
>> I still didn't manage to solve this issue. Can you maybe give me some
>> more hints where to look?
>>
>> Thank you in advance,
>> Otto
>>
>> Martin Taal schrieb:
>>> Hi Otto,
>>> Hmm, another approach is the following, can you use the following
>>> combination of options:
>>> CASCADE_POLICY_ON_CONTAINMENT to REMOVE,REFRESH,PERSIST,MERGE
>>> SET_CASCADE_ALL_ON_CONTAINMENT to false
>>>
>>> gr. Martin
>>>
>>> Otto wrote:
>>>> Hi Martin,
>>>>
>>>> thanks for your quick answer! As described on
>>>> http://www.elver.org/hibernate/hibernate_details.html#cutpaste i set
>>>> PersistenceOptions.SET_CASCADE_ALL_ON_CONTAINMENT to false, but then
>>>> i couldn't even save the first time:
>>>>
>>>> ibernate.TransientObjectException: object references an unsaved
>>>> transient instance - save the transient instance before flushing:
>>>> ProjectHistory
>>>> at
>>>> org.hibernate.engine.ForeignKeys.getEntityIdentifierIfNotUnsaved(ForeignKeys.java:219)
>>>>
>>>>
>>>> But on http://www.elver.org/hibernate/options.html I read that you
>>>> have to set it to true in order to enable orphan-delete. I tried
>>>> that too. Saving the first time didn't make any problems (as without
>>>> the option).
>>>> but then i moved a object and got:
>>>>
>>>> org.hibernate.ObjectDeletedException: deleted object would be
>>>> re-saved by cascade (remove deleted object from associations):
>>>> [MergingSolution#26]
>>>> at org.hibernate.impl.SessionImpl.forceFlush(SessionImpl.java:1014)
>>>> at
>>>> org.hibernate.event.def.DefaultSaveOrUpdateEventListener.entityIsTransient(DefaultSaveOrUpdateEventListener.java:165)
>>>>
>>>> at
>>>> org.hibernate.event.def.DefaultSaveOrUpdateEventListener.performSaveOrUpdate(DefaultSaveOrUpdateEventListener.java:94)
>>>>
>>>> at
>>>> org.hibernate.event.def.DefaultSaveOrUpdateEventListener.onSaveOrUpdate(DefaultSaveOrUpdateEventListener.java:70)
>>>>
>>>> at
>>>> org.hibernate.impl.SessionImpl.fireSaveOrUpdate(SessionImpl.java:507)
>>>> at
>>>> org.hibernate.impl.SessionImpl.saveOrUpdate(SessionImpl.java:499)
>>>> at
>>>> org.hibernate.engine.CascadingAction$5.cascade(CascadingAction.java:218)
>>>>
>>>> at org.hibernate.engine.Cascade.cascadeToOne(Cascade.java:268)
>>>> at
>>>> org.hibernate.engine.Cascade.cascadeAssociation(Cascade.java:216)
>>>> at org.hibernate.engine.Cascade.cascadeProperty(Cascade.java:169)
>>>>
>>>> Does this say anthing to you?
>>>>
>>>> Greetings,
>>>> Otto
>>>>
>>>> Martin Taal schrieb:
>>>>> Hi Otto,
>>>>> Yes, cust-past (move) between containers does now work nicely with
>>>>> hibernate's orphan-delete.
>>>>>
>>>>> What exceptions do you get when you set the
>>>>> PersistenceOptions.SET_CASCADE_ALL_ON_CONTAINMENT option?
>>>>>
>>>>> gr. Martin
>>>>>
>>>>> Otto wrote:
>>>>>> Hi guys,
>>>>>>
>>>>>> I'm experiencing some problems when changing the containment
>>>>>> position inside the containment tree (drag-n-drop in a treeview)
>>>>>> and then try to resave it with teneo. When moving a element from
>>>>>> one to another container i get 1 of 2 different exceptions, it
>>>>>> depends on the case, but i couldn't distinquish yet when which
>>>>>> case is triggered.
>>>>>> #1
>>>>>> te.exception.ConstraintViolationException: could not delete:
>>>>>> [Milestone#18]
>>>>>> [...]
>>>>>> java.sql.SQLException: Cannot delete or update a parent row: a
>>>>>> foreign key constraint fails
>>>>>> (`model/annotation_annotatedmodelelements`, CONSTRAINT
>>>>>> `annotation_annotatedmodelelements` FOREIGN KEY
>>>>>> (`modelelement_e_id`) REFERENCES `modelelement`
>>>>>> (`identifiableelement_e_id`))
>>>>>>
>>>>>> #2
>>>>>> deleted object would be re-saved by cascade, remove deleted object
>>>>>> from associations
>>>>>>
>>>>>> I found
>>>>>> http://www.elver.org/hibernate/hibernate_details.html#cutpaste on
>>>>>> the teneo page. I tried setting this globaloption
>>>>>> PersistenceOptions.SET_CASCADE_ALL_ON_CONTAINMENT and didn't work
>>>>>> and threw more exceptions. The second solution to set an
>>>>>> annotation for every sing containment reference isnt really handy
>>>>>> because we have quite some different containment references.
>>>>>>
>>>>>> I'm new to this and these erros don't tell me that much, so I
>>>>>> would really appreciate if you could give me some hints or even
>>>>>> solutions. Isn't there a easy way, i mean, changing containment is
>>>>>> a common usecase?!
>>>>>>
>>>>>> Thanks in advance.
>>>>>>
>>>>>> Greetings,
>>>>>> Otto
>>>>>
>>>>>
>>>
>>>
>
>
Re: [Teneo] containment changes - problems with resaving
Hi Otto,
Maybe what happens is when the object is removed from its container that it is placed in the
removedObjects list of the hibernateresource. Then when it is put in the other container it is not
removed from the removedObjects list.
Can you put a breakpoint in the saveResource method in the HibernateResource. There is a separate
section there which removes each object. You can also see if your object is present in the
removedEObjects at that point.
gr. Martin
Otto wrote:
> Hi Martin,
>
> I love your quick answers Current setting is
> CASCADE_POLICY_ON_NON_CONTAINMENT = "REMOVE,REFRESH,PERSIST,MERGE" and
> SET_CASCADE_ALL_ON_CONTAINMENT is not set at all. With this combination
> saving works, but moving an element throws the exception. The container
> are in the same resource.
>
>
> org.eclipse.emf.teneo.hibernate.HbMapperException: Exception when saving
> resource modelStore
> at
> org.eclipse.emf.teneo.hibernate.resource.HibernateResource.saveResource(HibernateResource.java:369)
>
> at
> org.eclipse.emf.teneo.resource.StoreResource.save(StoreResource.java:404)
> at
> org.unicase.emfstore.esmodel.impl.ServerSpaceImpl.save(ServerSpaceImpl.java:268)
>
> at org.unicase.emfstore.EmfStoreImpl.save(EmfStoreImpl.java:332)
> at
> org.unicase.emfstore.EmfStoreImpl.createVersion(EmfStoreImpl.java:110)
> at
> org.unicase.emfstore.connection.rmi.RMIEmfStoreFacadeImpl.createVersion(RMIEmfStoreFacadeImpl.java:89)
>
> at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
> at sun.reflect.NativeMethodAccessorImpl.invoke(Unknown Source)
> at sun.reflect.DelegatingMethodAccessorImpl.invoke(Unknown Source)
> at java.lang.reflect.Method.invoke(Unknown Source)
> at sun.rmi.server.UnicastServerRef.dispatch(Unknown Source)
> at sun.rmi.transport.Transport$1.run(Unknown Source)
> at java.security.AccessController.doPrivileged(Native Method)
> at sun.rmi.transport.Transport.serviceCall(Unknown Source)
> at sun.rmi.transport.tcp.TCPTransport.handleMessages(Unknown Source)
> at sun.rmi.transport.tcp.TCPTransport$ConnectionHandler.run0(Unknown
> Source)
> at sun.rmi.transport.tcp.TCPTransport$ConnectionHandler.run(Unknown
> Source)
> at java.util.concurrent.ThreadPoolExecutor$Worker.runTask(Unknown
> Source)
> at java.util.concurrent.ThreadPoolExecutor$Worker.run(Unknown Source)
> at java.lang.Thread.run(Unknown Source)
> Caused by: org.hibernate.ObjectDeletedException: deleted object would be
> re-saved by cascade (remove deleted object from associations):
> [LeafSection#630]
> at org.hibernate.impl.SessionImpl.forceFlush(SessionImpl.java:1014)
> at
> org.hibernate.event.def.DefaultSaveOrUpdateEventListener.entityIsTransient(DefaultSaveOrUpdateEventListener.java:165)
>
> at
> org.hibernate.event.def.DefaultSaveOrUpdateEventListener.performSaveOrUpdate(DefaultSaveOrUpdateEventListener.java:94)
>
> at
> org.hibernate.event.def.DefaultSaveOrUpdateEventListener.onSaveOrUpdate(DefaultSaveOrUpdateEventListener.java:70)
>
> at
> org.hibernate.impl.SessionImpl.fireSaveOrUpdate(SessionImpl.java:507)
> at org.hibernate.impl.SessionImpl.saveOrUpdate(SessionImpl.java:499)
> at
> org.hibernate.engine.CascadingAction$5.cascade(CascadingAction.java:218)
> at org.hibernate.engine.Cascade.cascadeToOne(Cascade.java:268)
> at org.hibernate.engine.Cascade.cascadeAssociation(Cascade.java:216)
> at org.hibernate.engine.Cascade.cascadeProperty(Cascade.java:169)
> at
> org.hibernate.engine.Cascade.cascadeCollectionElements(Cascade.java:296)
> at org.hibernate.engine.Cascade.cascadeCollection(Cascade.java:242)
> at org.hibernate.engine.Cascade.cascadeAssociation(Cascade.java:219)
> at org.hibernate.engine.Cascade.cascadeProperty(Cascade.java:169)
> at org.hibernate.engine.Cascade.cascade(Cascade.java:130)
> at
> org.hibernate.event.def.AbstractFlushingEventListener.cascadeOnFlush(AbstractFlushingEventListener.java:131)
>
> at
> org.hibernate.event.def.AbstractFlushingEventListener.prepareEntityFlushes(AbstractFlushingEventListener.java:122)
>
> at
> org.hibernate.event.def.AbstractFlushingEventListener.flushEverythingToExecutions(AbstractFlushingEventListener.java:65)
>
> at
> org.hibernate.event.def.DefaultFlushEventListener.onFlush(DefaultFlushEventListener.java:26)
>
> at org.hibernate.impl.SessionImpl.flush(SessionImpl.java:1000)
> at
> org.eclipse.emf.teneo.hibernate.HbSessionWrapper.flush(HbSessionWrapper.java:171)
>
> at
> org.eclipse.emf.teneo.hibernate.resource.HibernateResource.saveResource(HibernateResource.java:363)
>
> ... 19 more
>
> Martin Taal schrieb:
>> With these latest settings what's the stacktrace you are seeing?
>>
>> Are the source and target container in the same resource?
>>
>> gr. Martin
>>
>> Otto wrote:
>>> Hi,
>>>
>>> I still didn't manage to solve this issue. Can you maybe give me some
>>> more hints where to look?
>>>
>>> Thank you in advance,
>>> Otto
>>>
>>> Martin Taal schrieb:
>>>> Hi Otto,
>>>> Hmm, another approach is the following, can you use the following
>>>> combination of options:
>>>> CASCADE_POLICY_ON_CONTAINMENT to REMOVE,REFRESH,PERSIST,MERGE
>>>> SET_CASCADE_ALL_ON_CONTAINMENT to false
>>>>
>>>> gr. Martin
>>>>
>>>> Otto wrote:
>>>>> Hi Martin,
>>>>>
>>>>> thanks for your quick answer! As described on
>>>>> http://www.elver.org/hibernate/hibernate_details.html#cutpaste i
>>>>> set PersistenceOptions.SET_CASCADE_ALL_ON_CONTAINMENT to false, but
>>>>> then i couldn't even save the first time:
>>>>>
>>>>> ibernate.TransientObjectException: object references an unsaved
>>>>> transient instance - save the transient instance before flushing:
>>>>> ProjectHistory
>>>>> at
>>>>> org.hibernate.engine.ForeignKeys.getEntityIdentifierIfNotUnsaved(ForeignKeys.java:219)
>>>>>
>>>>>
>>>>> But on http://www.elver.org/hibernate/options.html I read that you
>>>>> have to set it to true in order to enable orphan-delete. I tried
>>>>> that too. Saving the first time didn't make any problems (as
>>>>> without the option).
>>>>> but then i moved a object and got:
>>>>>
>>>>> org.hibernate.ObjectDeletedException: deleted object would be
>>>>> re-saved by cascade (remove deleted object from associations):
>>>>> [MergingSolution#26]
>>>>> at
>>>>> org.hibernate.impl.SessionImpl.forceFlush(SessionImpl.java:1014)
>>>>> at
>>>>> org.hibernate.event.def.DefaultSaveOrUpdateEventListener.entityIsTransient(DefaultSaveOrUpdateEventListener.java:165)
>>>>>
>>>>> at
>>>>> org.hibernate.event.def.DefaultSaveOrUpdateEventListener.performSaveOrUpdate(DefaultSaveOrUpdateEventListener.java:94)
>>>>>
>>>>> at
>>>>> org.hibernate.event.def.DefaultSaveOrUpdateEventListener.onSaveOrUpdate(DefaultSaveOrUpdateEventListener.java:70)
>>>>>
>>>>> at
>>>>> org.hibernate.impl.SessionImpl.fireSaveOrUpdate(SessionImpl.java:507)
>>>>> at
>>>>> org.hibernate.impl.SessionImpl.saveOrUpdate(SessionImpl.java:499)
>>>>> at
>>>>> org.hibernate.engine.CascadingAction$5.cascade(CascadingAction.java:218)
>>>>>
>>>>> at org.hibernate.engine.Cascade.cascadeToOne(Cascade.java:268)
>>>>> at
>>>>> org.hibernate.engine.Cascade.cascadeAssociation(Cascade.java:216)
>>>>> at org.hibernate.engine.Cascade.cascadeProperty(Cascade.java:169)
>>>>>
>>>>> Does this say anthing to you?
>>>>>
>>>>> Greetings,
>>>>> Otto
>>>>>
>>>>> Martin Taal schrieb:
>>>>>> Hi Otto,
>>>>>> Yes, cust-past (move) between containers does now work nicely with
>>>>>> hibernate's orphan-delete.
>>>>>>
>>>>>> What exceptions do you get when you set the
>>>>>> PersistenceOptions.SET_CASCADE_ALL_ON_CONTAINMENT option?
>>>>>>
>>>>>> gr. Martin
>>>>>>
>>>>>> Otto wrote:
>>>>>>> Hi guys,
>>>>>>>
>>>>>>> I'm experiencing some problems when changing the containment
>>>>>>> position inside the containment tree (drag-n-drop in a treeview)
>>>>>>> and then try to resave it with teneo. When moving a element from
>>>>>>> one to another container i get 1 of 2 different exceptions, it
>>>>>>> depends on the case, but i couldn't distinquish yet when which
>>>>>>> case is triggered.
>>>>>>> #1
>>>>>>> te.exception.ConstraintViolationException: could not delete:
>>>>>>> [Milestone#18]
>>>>>>> [...]
>>>>>>> java.sql.SQLException: Cannot delete or update a parent row: a
>>>>>>> foreign key constraint fails
>>>>>>> (`model/annotation_annotatedmodelelements`, CONSTRAINT
>>>>>>> `annotation_annotatedmodelelements` FOREIGN KEY
>>>>>>> (`modelelement_e_id`) REFERENCES `modelelement`
>>>>>>> (`identifiableelement_e_id`))
>>>>>>>
>>>>>>> #2
>>>>>>> deleted object would be re-saved by cascade, remove deleted
>>>>>>> object from associations
>>>>>>>
>>>>>>> I found
>>>>>>> http://www.elver.org/hibernate/hibernate_details.html#cutpaste on
>>>>>>> the teneo page. I tried setting this globaloption
>>>>>>> PersistenceOptions.SET_CASCADE_ALL_ON_CONTAINMENT and didn't work
>>>>>>> and threw more exceptions. The second solution to set an
>>>>>>> annotation for every sing containment reference isnt really handy
>>>>>>> because we have quite some different containment references.
>>>>>>>
>>>>>>> I'm new to this and these erros don't tell me that much, so I
>>>>>>> would really appreciate if you could give me some hints or even
>>>>>>> solutions. Isn't there a easy way, i mean, changing containment
>>>>>>> is a common usecase?!
>>>>>>>
>>>>>>> Thanks in advance.
>>>>>>>
>>>>>>> Greetings,
>>>>>>> Otto
>>>>>>
>>>>>>
>>>>
>>>>
>>
>>
Re: [Teneo] containment changes - problems with resaving
And can you post the part of the hbm which covers the containment relation, to be sure that the
delete-orphan is indeed not present.
gr. Martin
Otto wrote:
> Hi Martin,
>
> I love your quick answers Current setting is
> CASCADE_POLICY_ON_NON_CONTAINMENT = "REMOVE,REFRESH,PERSIST,MERGE" and
> SET_CASCADE_ALL_ON_CONTAINMENT is not set at all. With this combination
> saving works, but moving an element throws the exception. The container
> are in the same resource.
>
>
> org.eclipse.emf.teneo.hibernate.HbMapperException: Exception when saving
> resource modelStore
> at
> org.eclipse.emf.teneo.hibernate.resource.HibernateResource.saveResource(HibernateResource.java:369)
>
> at
> org.eclipse.emf.teneo.resource.StoreResource.save(StoreResource.java:404)
> at
> org.unicase.emfstore.esmodel.impl.ServerSpaceImpl.save(ServerSpaceImpl.java:268)
>
> at org.unicase.emfstore.EmfStoreImpl.save(EmfStoreImpl.java:332)
> at
> org.unicase.emfstore.EmfStoreImpl.createVersion(EmfStoreImpl.java:110)
> at
> org.unicase.emfstore.connection.rmi.RMIEmfStoreFacadeImpl.createVersion(RMIEmfStoreFacadeImpl.java:89)
>
> at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
> at sun.reflect.NativeMethodAccessorImpl.invoke(Unknown Source)
> at sun.reflect.DelegatingMethodAccessorImpl.invoke(Unknown Source)
> at java.lang.reflect.Method.invoke(Unknown Source)
> at sun.rmi.server.UnicastServerRef.dispatch(Unknown Source)
> at sun.rmi.transport.Transport$1.run(Unknown Source)
> at java.security.AccessController.doPrivileged(Native Method)
> at sun.rmi.transport.Transport.serviceCall(Unknown Source)
> at sun.rmi.transport.tcp.TCPTransport.handleMessages(Unknown Source)
> at sun.rmi.transport.tcp.TCPTransport$ConnectionHandler.run0(Unknown
> Source)
> at sun.rmi.transport.tcp.TCPTransport$ConnectionHandler.run(Unknown
> Source)
> at java.util.concurrent.ThreadPoolExecutor$Worker.runTask(Unknown
> Source)
> at java.util.concurrent.ThreadPoolExecutor$Worker.run(Unknown Source)
> at java.lang.Thread.run(Unknown Source)
> Caused by: org.hibernate.ObjectDeletedException: deleted object would be
> re-saved by cascade (remove deleted object from associations):
> [LeafSection#630]
> at org.hibernate.impl.SessionImpl.forceFlush(SessionImpl.java:1014)
> at
> org.hibernate.event.def.DefaultSaveOrUpdateEventListener.entityIsTransient(DefaultSaveOrUpdateEventListener.java:165)
>
> at
> org.hibernate.event.def.DefaultSaveOrUpdateEventListener.performSaveOrUpdate(DefaultSaveOrUpdateEventListener.java:94)
>
> at
> org.hibernate.event.def.DefaultSaveOrUpdateEventListener.onSaveOrUpdate(DefaultSaveOrUpdateEventListener.java:70)
>
> at
> org.hibernate.impl.SessionImpl.fireSaveOrUpdate(SessionImpl.java:507)
> at org.hibernate.impl.SessionImpl.saveOrUpdate(SessionImpl.java:499)
> at
> org.hibernate.engine.CascadingAction$5.cascade(CascadingAction.java:218)
> at org.hibernate.engine.Cascade.cascadeToOne(Cascade.java:268)
> at org.hibernate.engine.Cascade.cascadeAssociation(Cascade.java:216)
> at org.hibernate.engine.Cascade.cascadeProperty(Cascade.java:169)
> at
> org.hibernate.engine.Cascade.cascadeCollectionElements(Cascade.java:296)
> at org.hibernate.engine.Cascade.cascadeCollection(Cascade.java:242)
> at org.hibernate.engine.Cascade.cascadeAssociation(Cascade.java:219)
> at org.hibernate.engine.Cascade.cascadeProperty(Cascade.java:169)
> at org.hibernate.engine.Cascade.cascade(Cascade.java:130)
> at
> org.hibernate.event.def.AbstractFlushingEventListener.cascadeOnFlush(AbstractFlushingEventListener.java:131)
>
> at
> org.hibernate.event.def.AbstractFlushingEventListener.prepareEntityFlushes(AbstractFlushingEventListener.java:122)
>
> at
> org.hibernate.event.def.AbstractFlushingEventListener.flushEverythingToExecutions(AbstractFlushingEventListener.java:65)
>
> at
> org.hibernate.event.def.DefaultFlushEventListener.onFlush(DefaultFlushEventListener.java:26)
>
> at org.hibernate.impl.SessionImpl.flush(SessionImpl.java:1000)
> at
> org.eclipse.emf.teneo.hibernate.HbSessionWrapper.flush(HbSessionWrapper.java:171)
>
> at
> org.eclipse.emf.teneo.hibernate.resource.HibernateResource.saveResource(HibernateResource.java:363)
>
> ... 19 more
>
> Martin Taal schrieb:
>> With these latest settings what's the stacktrace you are seeing?
>>
>> Are the source and target container in the same resource?
>>
>> gr. Martin
>>
>> Otto wrote:
>>> Hi,
>>>
>>> I still didn't manage to solve this issue. Can you maybe give me some
>>> more hints where to look?
>>>
>>> Thank you in advance,
>>> Otto
>>>
>>> Martin Taal schrieb:
>>>> Hi Otto,
>>>> Hmm, another approach is the following, can you use the following
>>>> combination of options:
>>>> CASCADE_POLICY_ON_CONTAINMENT to REMOVE,REFRESH,PERSIST,MERGE
>>>> SET_CASCADE_ALL_ON_CONTAINMENT to false
>>>>
>>>> gr. Martin
>>>>
>>>> Otto wrote:
>>>>> Hi Martin,
>>>>>
>>>>> thanks for your quick answer! As described on
>>>>> http://www.elver.org/hibernate/hibernate_details.html#cutpaste i
>>>>> set PersistenceOptions.SET_CASCADE_ALL_ON_CONTAINMENT to false, but
>>>>> then i couldn't even save the first time:
>>>>>
>>>>> ibernate.TransientObjectException: object references an unsaved
>>>>> transient instance - save the transient instance before flushing:
>>>>> ProjectHistory
>>>>> at
>>>>> org.hibernate.engine.ForeignKeys.getEntityIdentifierIfNotUnsaved(ForeignKeys.java:219)
>>>>>
>>>>>
>>>>> But on http://www.elver.org/hibernate/options.html I read that you
>>>>> have to set it to true in order to enable orphan-delete. I tried
>>>>> that too. Saving the first time didn't make any problems (as
>>>>> without the option).
>>>>> but then i moved a object and got:
>>>>>
>>>>> org.hibernate.ObjectDeletedException: deleted object would be
>>>>> re-saved by cascade (remove deleted object from associations):
>>>>> [MergingSolution#26]
>>>>> at
>>>>> org.hibernate.impl.SessionImpl.forceFlush(SessionImpl.java:1014)
>>>>> at
>>>>> org.hibernate.event.def.DefaultSaveOrUpdateEventListener.entityIsTransient(DefaultSaveOrUpdateEventListener.java:165)
>>>>>
>>>>> at
>>>>> org.hibernate.event.def.DefaultSaveOrUpdateEventListener.performSaveOrUpdate(DefaultSaveOrUpdateEventListener.java:94)
>>>>>
>>>>> at
>>>>> org.hibernate.event.def.DefaultSaveOrUpdateEventListener.onSaveOrUpdate(DefaultSaveOrUpdateEventListener.java:70)
>>>>>
>>>>> at
>>>>> org.hibernate.impl.SessionImpl.fireSaveOrUpdate(SessionImpl.java:507)
>>>>> at
>>>>> org.hibernate.impl.SessionImpl.saveOrUpdate(SessionImpl.java:499)
>>>>> at
>>>>> org.hibernate.engine.CascadingAction$5.cascade(CascadingAction.java:218)
>>>>>
>>>>> at org.hibernate.engine.Cascade.cascadeToOne(Cascade.java:268)
>>>>> at
>>>>> org.hibernate.engine.Cascade.cascadeAssociation(Cascade.java:216)
>>>>> at org.hibernate.engine.Cascade.cascadeProperty(Cascade.java:169)
>>>>>
>>>>> Does this say anthing to you?
>>>>>
>>>>> Greetings,
>>>>> Otto
>>>>>
>>>>> Martin Taal schrieb:
>>>>>> Hi Otto,
>>>>>> Yes, cust-past (move) between containers does now work nicely with
>>>>>> hibernate's orphan-delete.
>>>>>>
>>>>>> What exceptions do you get when you set the
>>>>>> PersistenceOptions.SET_CASCADE_ALL_ON_CONTAINMENT option?
>>>>>>
>>>>>> gr. Martin
>>>>>>
>>>>>> Otto wrote:
>>>>>>> Hi guys,
>>>>>>>
>>>>>>> I'm experiencing some problems when changing the containment
>>>>>>> position inside the containment tree (drag-n-drop in a treeview)
>>>>>>> and then try to resave it with teneo. When moving a element from
>>>>>>> one to another container i get 1 of 2 different exceptions, it
>>>>>>> depends on the case, but i couldn't distinquish yet when which
>>>>>>> case is triggered.
>>>>>>> #1
>>>>>>> te.exception.ConstraintViolationException: could not delete:
>>>>>>> [Milestone#18]
>>>>>>> [...]
>>>>>>> java.sql.SQLException: Cannot delete or update a parent row: a
>>>>>>> foreign key constraint fails
>>>>>>> (`model/annotation_annotatedmodelelements`, CONSTRAINT
>>>>>>> `annotation_annotatedmodelelements` FOREIGN KEY
>>>>>>> (`modelelement_e_id`) REFERENCES `modelelement`
>>>>>>> (`identifiableelement_e_id`))
>>>>>>>
>>>>>>> #2
>>>>>>> deleted object would be re-saved by cascade, remove deleted
>>>>>>> object from associations
>>>>>>>
>>>>>>> I found
>>>>>>> http://www.elver.org/hibernate/hibernate_details.html#cutpaste on
>>>>>>> the teneo page. I tried setting this globaloption
>>>>>>> PersistenceOptions.SET_CASCADE_ALL_ON_CONTAINMENT and didn't work
>>>>>>> and threw more exceptions. The second solution to set an
>>>>>>> annotation for every sing containment reference isnt really handy
>>>>>>> because we have quite some different containment references.
>>>>>>>
>>>>>>> I'm new to this and th
[Teneo] containment changes - problems with resaving
At 5:07 PM on Aug 1, 2008, Otto wrote:
I'm experiencing some problems when changing the containment position
inside the containment tree (drag-n-drop in a treeview) and then try to
resave it with teneo. When moving a element from one to another
container i get 1 of 2 different exceptions, it depends on the case, but
i couldn't distinquish yet when which case is triggered.
#1
te.exception.ConstraintViolationException: could not delete: [Milestone#18]
[...]
java.sql.SQLException: Cannot delete or update a parent row: a foreign
key constraint fails (`model/annotation_annotatedmodelelements`,
CONSTRAINT `annotation_annotatedmodelelements` FOREIGN KEY
(`modelelement_e_id`) REFERENCES `modelelement`
(`identifiableelement_e_id`))
#2
deleted object would be re-saved by cascade, remove deleted object from
associations
I found http://www.elver.org/hibernate/hibernate_details.html#cutpaste
on the teneo page. I tried setting this globaloption
PersistenceOptions.SET_CASCADE_ALL_ON_CONTAINMENT and didn't work and
threw more exceptions. The second solution to set an annotation for
every sing containment reference isnt really handy because we have quite
some different containment references.
I'm new to this and these erros don't tell me that much, so I would
really appreciate if you could give me some hints or even solutions.
Isn't there a easy way, i mean, changing containment is a common usecase?!
Thanks in advance.
Greetings,
Otto
14 replies so far (
Post your own)
Re: [Teneo] containment changes - problems with resaving
Hi Otto,Yes, cust-past (move) between containers does now work nicely with hibernate's orphan-delete.
What exceptions do you get when you set the PersistenceOptions.SET_CASCADE_ALL_ON_CONTAINMENT option?
gr. Martin
Otto wrote:
> Hi guys,
>
> I'm experiencing some problems when changing the containment position
> inside the containment tree (drag-n-drop in a treeview) and then try to
> resave it with teneo. When moving a element from one to another
> container i get 1 of 2 different exceptions, it depends on the case, but
> i couldn't distinquish yet when which case is triggered.
> #1
> te.exception.ConstraintViolationException: could not delete: [Milestone#18]
> [...]
> java.sql.SQLException: Cannot delete or update a parent row: a foreign
> key constraint fails (`model/annotation_annotatedmodelelements`,
> CONSTRAINT `annotation_annotatedmodelelements` FOREIGN KEY
> (`modelelement_e_id`) REFERENCES `modelelement`
> (`identifiableelement_e_id`))
>
> #2
> deleted object would be re-saved by cascade, remove deleted object from
> associations
>
> I found http://www.elver.org/hibernate/hibernate_details.html#cutpaste
> on the teneo page. I tried setting this globaloption
> PersistenceOptions.SET_CASCADE_ALL_ON_CONTAINMENT and didn't work and
> threw more exceptions. The second solution to set an annotation for
> every sing containment reference isnt really handy because we have quite
> some different containment references.
>
> I'm new to this and these erros don't tell me that much, so I would
> really appreciate if you could give me some hints or even solutions.
> Isn't there a easy way, i mean, changing containment is a common usecase?!
>
> Thanks in advance.
>
> Greetings,
> Otto
--
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 at springsite dot com - mtaal at elver dot org
Web: www.springsite.com - www.elver.org
Re: [Teneo] containment changes - problems with resaving
Hi Martin,thanks for your quick answer! As described on
http://www.elver.org/hibernate/hibernate_details.html#cutpaste i set
PersistenceOptions.SET_CASCADE_ALL_ON_CONTAINMENT to false, but then i
couldn't even save the first time:
ibernate.TransientObjectException: object references an unsaved
transient instance - save the transient instance before flushing:
ProjectHistory
at
org.hibernate.engine.ForeignKeys.getEntityIdentifierIfNotUnsaved(ForeignKeys.java:219)
But on http://www.elver.org/hibernate/options.html I read that you have
to set it to true in order to enable orphan-delete. I tried that too.
Saving the first time didn't make any problems (as without the option).
but then i moved a object and got:
org.hibernate.ObjectDeletedException: deleted object would be re-saved
by cascade (remove deleted object from associations): [MergingSolution#26]
at org.hibernate.impl.SessionImpl.forceFlush(SessionImpl.java:1014)
at
org.hibernate.event.def.DefaultSaveOrUpdateEventListener.entityIsTransient(DefaultSaveOrUpdateEventListener.java:165)
at
org.hibernate.event.def.DefaultSaveOrUpdateEventListener.performSaveOrUpdate(DefaultSaveOrUpdateEventListener.java:94)
at
org.hibernate.event.def.DefaultSaveOrUpdateEventListener.onSaveOrUpdate(DefaultSaveOrUpdateEventListener.java:70)
at org.hibernate.impl.SessionImpl.fireSaveOrUpdate(SessionImpl.java:507)
at org.hibernate.impl.SessionImpl.saveOrUpdate(SessionImpl.java:499)
at org.hibernate.engine.CascadingAction$5.cascade(CascadingAction.java:218)
at org.hibernate.engine.Cascade.cascadeToOne(Cascade.java:268)
at org.hibernate.engine.Cascade.cascadeAssociation(Cascade.java:216)
at org.hibernate.engine.Cascade.cascadeProperty(Cascade.java:169)
Does this say anthing to you?
Greetings,
Otto
Martin Taal schrieb:
> Hi Otto,
> Yes, cust-past (move) between containers does now work nicely with
> hibernate's orphan-delete.
>
> What exceptions do you get when you set the
> PersistenceOptions.SET_CASCADE_ALL_ON_CONTAINMENT option?
>
> gr. Martin
>
> Otto wrote:
>> Hi guys,
>>
>> I'm experiencing some problems when changing the containment position
>> inside the containment tree (drag-n-drop in a treeview) and then try
>> to resave it with teneo. When moving a element from one to another
>> container i get 1 of 2 different exceptions, it depends on the case,
>> but i couldn't distinquish yet when which case is triggered.
>> #1
>> te.exception.ConstraintViolationException: could not delete:
>> [Milestone#18]
>> [...]
>> java.sql.SQLException: Cannot delete or update a parent row: a foreign
>> key constraint fails (`model/annotation_annotatedmodelelements`,
>> CONSTRAINT `annotation_annotatedmodelelements` FOREIGN KEY
>> (`modelelement_e_id`) REFERENCES `modelelement`
>> (`identifiableelement_e_id`))
>>
>> #2
>> deleted object would be re-saved by cascade, remove deleted object
>> from associations
>>
>> I found http://www.elver.org/hibernate/hibernate_details.html#cutpaste
>> on the teneo page. I tried setting this globaloption
>> PersistenceOptions.SET_CASCADE_ALL_ON_CONTAINMENT and didn't work and
>> threw more exceptions. The second solution to set an annotation for
>> every sing containment reference isnt really handy because we have
>> quite some different containment references.
>>
>> I'm new to this and these erros don't tell me that much, so I would
>> really appreciate if you could give me some hints or even solutions.
>> Isn't there a easy way, i mean, changing containment is a common
>> usecase?!
>>
>> Thanks in advance.
>>
>> Greetings,
>> Otto
>
>
Re: [Teneo] containment changes - problems with resaving
Hi Otto,Hmm, another approach is the following, can you use the following combination of options:
CASCADE_POLICY_ON_CONTAINMENT to REMOVE,REFRESH,PERSIST,MERGE
SET_CASCADE_ALL_ON_CONTAINMENT to false
gr. Martin
Otto wrote:
> Hi Martin,
>
> thanks for your quick answer! As described on
> http://www.elver.org/hibernate/hibernate_details.html#cutpaste i set
> PersistenceOptions.SET_CASCADE_ALL_ON_CONTAINMENT to false, but then i
> couldn't even save the first time:
>
> ibernate.TransientObjectException: object references an unsaved
> transient instance - save the transient instance before flushing:
> ProjectHistory
> at
> org.hibernate.engine.ForeignKeys.getEntityIdentifierIfNotUnsaved(ForeignKeys.java:219)
>
>
> But on http://www.elver.org/hibernate/options.html I read that you have
> to set it to true in order to enable orphan-delete. I tried that too.
> Saving the first time didn't make any problems (as without the option).
> but then i moved a object and got:
>
> org.hibernate.ObjectDeletedException: deleted object would be re-saved
> by cascade (remove deleted object from associations): [MergingSolution#26]
> at org.hibernate.impl.SessionImpl.forceFlush(SessionImpl.java:1014)
> at
> org.hibernate.event.def.DefaultSaveOrUpdateEventListener.entityIsTransient(DefaultSaveOrUpdateEventListener.java:165)
>
> at
> org.hibernate.event.def.DefaultSaveOrUpdateEventListener.performSaveOrUpdate(DefaultSaveOrUpdateEventListener.java:94)
>
> at
> org.hibernate.event.def.DefaultSaveOrUpdateEventListener.onSaveOrUpdate(DefaultSaveOrUpdateEventListener.java:70)
>
> at
> org.hibernate.impl.SessionImpl.fireSaveOrUpdate(SessionImpl.java:507)
> at org.hibernate.impl.SessionImpl.saveOrUpdate(SessionImpl.java:499)
> at
> org.hibernate.engine.CascadingAction$5.cascade(CascadingAction.java:218)
> at org.hibernate.engine.Cascade.cascadeToOne(Cascade.java:268)
> at org.hibernate.engine.Cascade.cascadeAssociation(Cascade.java:216)
> at org.hibernate.engine.Cascade.cascadeProperty(Cascade.java:169)
>
> Does this say anthing to you?
>
> Greetings,
> Otto
>
> Martin Taal schrieb:
>> Hi Otto,
>> Yes, cust-past (move) between containers does now work nicely with
>> hibernate's orphan-delete.
>>
>> What exceptions do you get when you set the
>> PersistenceOptions.SET_CASCADE_ALL_ON_CONTAINMENT option?
>>
>> gr. Martin
>>
>> Otto wrote:
>>> Hi guys,
>>>
>>> I'm experiencing some problems when changing the containment position
>>> inside the containment tree (drag-n-drop in a treeview) and then try
>>> to resave it with teneo. When moving a element from one to another
>>> container i get 1 of 2 different exceptions, it depends on the case,
>>> but i couldn't distinquish yet when which case is triggered.
>>> #1
>>> te.exception.ConstraintViolationException: could not delete:
>>> [Milestone#18]
>>> [...]
>>> java.sql.SQLException: Cannot delete or update a parent row: a
>>> foreign key constraint fails
>>> (`model/annotation_annotatedmodelelements`, CONSTRAINT
>>> `annotation_annotatedmodelelements` FOREIGN KEY (`modelelement_e_id`)
>>> REFERENCES `modelelement` (`identifiableelement_e_id`))
>>>
>>> #2
>>> deleted object would be re-saved by cascade, remove deleted object
>>> from associations
>>>
>>> I found
>>> http://www.elver.org/hibernate/hibernate_details.html#cutpaste on the
>>> teneo page. I tried setting this globaloption
>>> PersistenceOptions.SET_CASCADE_ALL_ON_CONTAINMENT and didn't work and
>>> threw more exceptions. The second solution to set an annotation for
>>> every sing containment reference isnt really handy because we have
>>> quite some different containment references.
>>>
>>> I'm new to this and these erros don't tell me that much, so I would
>>> really appreciate if you could give me some hints or even solutions.
>>> Isn't there a easy way, i mean, changing containment is a common
>>> usecase?!
>>>
>>> Thanks in advance.
>>>
>>> Greetings,
>>> Otto
>>
>>
--
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 at springsite dot com - mtaal at elver dot org
Web: www.springsite.com - www.elver.org
Re: [Teneo] containment changes - problems with resaving
Hi,I tried that, setting SET_CASCADE_ALL_ON_CONTAINMENT to false (and
CASCADE_POLICY...) lead to the same problems as allready explained. And
setting CASCADE_POLICY_ON_CONTAINMENT to REMOVE,REFRESH,PERSIST,MERGE
alone allows to save but, still when you move a object and save i get a
Caused by: org.hibernate.ObjectDeletedException: deleted object would be
re-saved by cascade (remove deleted object from associations):
To be honest im fishing in the dark and just trying different setting
combinations.
Greetings,
Otto
Martin Taal schrieb:
> Hi Otto,
> Hmm, another approach is the following, can you use the following
> combination of options:
> CASCADE_POLICY_ON_CONTAINMENT to REMOVE,REFRESH,PERSIST,MERGE
> SET_CASCADE_ALL_ON_CONTAINMENT to false
>
> gr. Martin
>
> Otto wrote:
>> Hi Martin,
>>
>> thanks for your quick answer! As described on
>> http://www.elver.org/hibernate/hibernate_details.html#cutpaste i set
>> PersistenceOptions.SET_CASCADE_ALL_ON_CONTAINMENT to false, but then i
>> couldn't even save the first time:
>>
>> ibernate.TransientObjectException: object references an unsaved
>> transient instance - save the transient instance before flushing:
>> ProjectHistory
>> at
>> org.hibernate.engine.ForeignKeys.getEntityIdentifierIfNotUnsaved(ForeignKeys.java:219)
>>
>>
>> But on http://www.elver.org/hibernate/options.html I read that you
>> have to set it to true in order to enable orphan-delete. I tried that
>> too. Saving the first time didn't make any problems (as without the
>> option).
>> but then i moved a object and got:
>>
>> org.hibernate.ObjectDeletedException: deleted object would be re-saved
>> by cascade (remove deleted object from associations):
>> [MergingSolution#26]
>> at org.hibernate.impl.SessionImpl.forceFlush(SessionImpl.java:1014)
>> at
>> org.hibernate.event.def.DefaultSaveOrUpdateEventListener.entityIsTransient(DefaultSaveOrUpdateEventListener.java:165)
>>
>> at
>> org.hibernate.event.def.DefaultSaveOrUpdateEventListener.performSaveOrUpdate(DefaultSaveOrUpdateEventListener.java:94)
>>
>> at
>> org.hibernate.event.def.DefaultSaveOrUpdateEventListener.onSaveOrUpdate(DefaultSaveOrUpdateEventListener.java:70)
>>
>> at
>> org.hibernate.impl.SessionImpl.fireSaveOrUpdate(SessionImpl.java:507)
>> at org.hibernate.impl.SessionImpl.saveOrUpdate(SessionImpl.java:499)
>> at
>> org.hibernate.engine.CascadingAction$5.cascade(CascadingAction.java:218)
>> at org.hibernate.engine.Cascade.cascadeToOne(Cascade.java:268)
>> at org.hibernate.engine.Cascade.cascadeAssociation(Cascade.java:216)
>> at org.hibernate.engine.Cascade.cascadeProperty(Cascade.java:169)
>>
>> Does this say anthing to you?
>>
>> Greetings,
>> Otto
>>
>> Martin Taal schrieb:
>>> Hi Otto,
>>> Yes, cust-past (move) between containers does now work nicely with
>>> hibernate's orphan-delete.
>>>
>>> What exceptions do you get when you set the
>>> PersistenceOptions.SET_CASCADE_ALL_ON_CONTAINMENT option?
>>>
>>> gr. Martin
>>>
>>> Otto wrote:
>>>> Hi guys,
>>>>
>>>> I'm experiencing some problems when changing the containment
>>>> position inside the containment tree (drag-n-drop in a treeview) and
>>>> then try to resave it with teneo. When moving a element from one to
>>>> another container i get 1 of 2 different exceptions, it depends on
>>>> the case, but i couldn't distinquish yet when which case is triggered.
>>>> #1
>>>> te.exception.ConstraintViolationException: could not delete:
>>>> [Milestone#18]
>>>> [...]
>>>> java.sql.SQLException: Cannot delete or update a parent row: a
>>>> foreign key constraint fails
>>>> (`model/annotation_annotatedmodelelements`, CONSTRAINT
>>>> `annotation_annotatedmodelelements` FOREIGN KEY
>>>> (`modelelement_e_id`) REFERENCES `modelelement`
>>>> (`identifiableelement_e_id`))
>>>>
>>>> #2
>>>> deleted object would be re-saved by cascade, remove deleted object
>>>> from associations
>>>>
>>>> I found
>>>> http://www.elver.org/hibernate/hibernate_details.html#cutpaste on
>>>> the teneo page. I tried setting this globaloption
>>>> PersistenceOptions.SET_CASCADE_ALL_ON_CONTAINMENT and didn't work
>>>> and threw more exceptions. The second solution to set an annotation
>>>> for every sing containment reference isnt really handy because we
>>>> have quite some different containment references.
>>>>
>>>> I'm new to this and these erros don't tell me that much, so I would
>>>> really appreciate if you could give me some hints or even solutions.
>>>> Isn't there a easy way, i mean, changing containment is a common
>>>> usecase?!
>>>>
>>>> Thanks in advance.
>>>>
>>>> Greetings,
>>>> Otto
>>>
>>>
>
>
Re: [Teneo] containment changes - problems with resaving
Hi,I still didn't manage to solve this issue. Can you maybe give me some
more hints where to look?
Thank you in advance,
Otto
Martin Taal schrieb:
> Hi Otto,
> Hmm, another approach is the following, can you use the following
> combination of options:
> CASCADE_POLICY_ON_CONTAINMENT to REMOVE,REFRESH,PERSIST,MERGE
> SET_CASCADE_ALL_ON_CONTAINMENT to false
>
> gr. Martin
>
> Otto wrote:
>> Hi Martin,
>>
>> thanks for your quick answer! As described on
>> http://www.elver.org/hibernate/hibernate_details.html#cutpaste i set
>> PersistenceOptions.SET_CASCADE_ALL_ON_CONTAINMENT to false, but then i
>> couldn't even save the first time:
>>
>> ibernate.TransientObjectException: object references an unsaved
>> transient instance - save the transient instance before flushing:
>> ProjectHistory
>> at
>> org.hibernate.engine.ForeignKeys.getEntityIdentifierIfNotUnsaved(ForeignKeys.java:219)
>>
>>
>> But on http://www.elver.org/hibernate/options.html I read that you
>> have to set it to true in order to enable orphan-delete. I tried that
>> too. Saving the first time didn't make any problems (as without the
>> option).
>> but then i moved a object and got:
>>
>> org.hibernate.ObjectDeletedException: deleted object would be re-saved
>> by cascade (remove deleted object from associations):
>> [MergingSolution#26]
>> at org.hibernate.impl.SessionImpl.forceFlush(SessionImpl.java:1014)
>> at
>> org.hibernate.event.def.DefaultSaveOrUpdateEventListener.entityIsTransient(DefaultSaveOrUpdateEventListener.java:165)
>>
>> at
>> org.hibernate.event.def.DefaultSaveOrUpdateEventListener.performSaveOrUpdate(DefaultSaveOrUpdateEventListener.java:94)
>>
>> at
>> org.hibernate.event.def.DefaultSaveOrUpdateEventListener.onSaveOrUpdate(DefaultSaveOrUpdateEventListener.java:70)
>>
>> at
>> org.hibernate.impl.SessionImpl.fireSaveOrUpdate(SessionImpl.java:507)
>> at org.hibernate.impl.SessionImpl.saveOrUpdate(SessionImpl.java:499)
>> at
>> org.hibernate.engine.CascadingAction$5.cascade(CascadingAction.java:218)
>> at org.hibernate.engine.Cascade.cascadeToOne(Cascade.java:268)
>> at org.hibernate.engine.Cascade.cascadeAssociation(Cascade.java:216)
>> at org.hibernate.engine.Cascade.cascadeProperty(Cascade.java:169)
>>
>> Does this say anthing to you?
>>
>> Greetings,
>> Otto
>>
>> Martin Taal schrieb:
>>> Hi Otto,
>>> Yes, cust-past (move) between containers does now work nicely with
>>> hibernate's orphan-delete.
>>>
>>> What exceptions do you get when you set the
>>> PersistenceOptions.SET_CASCADE_ALL_ON_CONTAINMENT option?
>>>
>>> gr. Martin
>>>
>>> Otto wrote:
>>>> Hi guys,
>>>>
>>>> I'm experiencing some problems when changing the containment
>>>> position inside the containment tree (drag-n-drop in a treeview) and
>>>> then try to resave it with teneo. When moving a element from one to
>>>> another container i get 1 of 2 different exceptions, it depends on
>>>> the case, but i couldn't distinquish yet when which case is triggered.
>>>> #1
>>>> te.exception.ConstraintViolationException: could not delete:
>>>> [Milestone#18]
>>>> [...]
>>>> java.sql.SQLException: Cannot delete or update a parent row: a
>>>> foreign key constraint fails
>>>> (`model/annotation_annotatedmodelelements`, CONSTRAINT
>>>> `annotation_annotatedmodelelements` FOREIGN KEY
>>>> (`modelelement_e_id`) REFERENCES `modelelement`
>>>> (`identifiableelement_e_id`))
>>>>
>>>> #2
>>>> deleted object would be re-saved by cascade, remove deleted object
>>>> from associations
>>>>
>>>> I found
>>>> http://www.elver.org/hibernate/hibernate_details.html#cutpaste on
>>>> the teneo page. I tried setting this globaloption
>>>> PersistenceOptions.SET_CASCADE_ALL_ON_CONTAINMENT and didn't work
>>>> and threw more exceptions. The second solution to set an annotation
>>>> for every sing containment reference isnt really handy because we
>>>> have quite some different containment references.
>>>>
>>>> I'm new to this and these erros don't tell me that much, so I would
>>>> really appreciate if you could give me some hints or even solutions.
>>>> Isn't there a easy way, i mean, changing containment is a common
>>>> usecase?!
>>>>
>>>> Thanks in advance.
>>>>
>>>> Greetings,
>>>> Otto
>>>
>>>
>
>
Re: [Teneo] containment changes - problems with resaving
With these latest settings what's the stacktrace you are seeing?Are the source and target container in the same resource?
gr. Martin
Otto wrote:
> Hi,
>
> I still didn't manage to solve this issue. Can you maybe give me some
> more hints where to look?
>
> Thank you in advance,
> Otto
>
> Martin Taal schrieb:
>> Hi Otto,
>> Hmm, another approach is the following, can you use the following
>> combination of options:
>> CASCADE_POLICY_ON_CONTAINMENT to REMOVE,REFRESH,PERSIST,MERGE
>> SET_CASCADE_ALL_ON_CONTAINMENT to false
>>
>> gr. Martin
>>
>> Otto wrote:
>>> Hi Martin,
>>>
>>> thanks for your quick answer! As described on
>>> http://www.elver.org/hibernate/hibernate_details.html#cutpaste i set
>>> PersistenceOptions.SET_CASCADE_ALL_ON_CONTAINMENT to false, but then
>>> i couldn't even save the first time:
>>>
>>> ibernate.TransientObjectException: object references an unsaved
>>> transient instance - save the transient instance before flushing:
>>> ProjectHistory
>>> at
>>> org.hibernate.engine.ForeignKeys.getEntityIdentifierIfNotUnsaved(ForeignKeys.java:219)
>>>
>>>
>>> But on http://www.elver.org/hibernate/options.html I read that you
>>> have to set it to true in order to enable orphan-delete. I tried that
>>> too. Saving the first time didn't make any problems (as without the
>>> option).
>>> but then i moved a object and got:
>>>
>>> org.hibernate.ObjectDeletedException: deleted object would be
>>> re-saved by cascade (remove deleted object from associations):
>>> [MergingSolution#26]
>>> at org.hibernate.impl.SessionImpl.forceFlush(SessionImpl.java:1014)
>>> at
>>> org.hibernate.event.def.DefaultSaveOrUpdateEventListener.entityIsTransient(DefaultSaveOrUpdateEventListener.java:165)
>>>
>>> at
>>> org.hibernate.event.def.DefaultSaveOrUpdateEventListener.performSaveOrUpdate(DefaultSaveOrUpdateEventListener.java:94)
>>>
>>> at
>>> org.hibernate.event.def.DefaultSaveOrUpdateEventListener.onSaveOrUpdate(DefaultSaveOrUpdateEventListener.java:70)
>>>
>>> at
>>> org.hibernate.impl.SessionImpl.fireSaveOrUpdate(SessionImpl.java:507)
>>> at org.hibernate.impl.SessionImpl.saveOrUpdate(SessionImpl.java:499)
>>> at
>>> org.hibernate.engine.CascadingAction$5.cascade(CascadingAction.java:218)
>>> at org.hibernate.engine.Cascade.cascadeToOne(Cascade.java:268)
>>> at org.hibernate.engine.Cascade.cascadeAssociation(Cascade.java:216)
>>> at org.hibernate.engine.Cascade.cascadeProperty(Cascade.java:169)
>>>
>>> Does this say anthing to you?
>>>
>>> Greetings,
>>> Otto
>>>
>>> Martin Taal schrieb:
>>>> Hi Otto,
>>>> Yes, cust-past (move) between containers does now work nicely with
>>>> hibernate's orphan-delete.
>>>>
>>>> What exceptions do you get when you set the
>>>> PersistenceOptions.SET_CASCADE_ALL_ON_CONTAINMENT option?
>>>>
>>>> gr. Martin
>>>>
>>>> Otto wrote:
>>>>> Hi guys,
>>>>>
>>>>> I'm experiencing some problems when changing the containment
>>>>> position inside the containment tree (drag-n-drop in a treeview)
>>>>> and then try to resave it with teneo. When moving a element from
>>>>> one to another container i get 1 of 2 different exceptions, it
>>>>> depends on the case, but i couldn't distinquish yet when which
>>>>> case is triggered.
>>>>> #1
>>>>> te.exception.ConstraintViolationException: could not delete:
>>>>> [Milestone#18]
>>>>> [...]
>>>>> java.sql.SQLException: Cannot delete or update a parent row: a
>>>>> foreign key constraint fails
>>>>> (`model/annotation_annotatedmodelelements`, CONSTRAINT
>>>>> `annotation_annotatedmodelelements` FOREIGN KEY
>>>>> (`modelelement_e_id`) REFERENCES `modelelement`
>>>>> (`identifiableelement_e_id`))
>>>>>
>>>>> #2
>>>>> deleted object would be re-saved by cascade, remove deleted object
>>>>> from associations
>>>>>
>>>>> I found
>>>>> http://www.elver.org/hibernate/hibernate_details.html#cutpaste on
>>>>> the teneo page. I tried setting this globaloption
>>>>> PersistenceOptions.SET_CASCADE_ALL_ON_CONTAINMENT and didn't work
>>>>> and threw more exceptions. The second solution to set an annotation
>>>>> for every sing containment reference isnt really handy because we
>>>>> have quite some different containment references.
>>>>>
>>>>> I'm new to this and these erros don't tell me that much, so I would
>>>>> really appreciate if you could give me some hints or even
>>>>> solutions. Isn't there a easy way, i mean, changing containment is
>>>>> a common usecase?!
>>>>>
>>>>> Thanks in advance.
>>>>>
>>>>> Greetings,
>>>>> Otto
>>>>
>>>>
>>
>>
--
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 at springsite dot com - mtaal at elver dot org
Web: www.springsite.com - www.elver.org
Re: [Teneo] containment changes - problems with resaving
Hi Martin,I love your quick answers
CASCADE_POLICY_ON_NON_CONTAINMENT = "REMOVE,REFRESH,PERSIST,MERGE" and
SET_CASCADE_ALL_ON_CONTAINMENT is not set at all. With this combination
saving works, but moving an element throws the exception. The container
are in the same resource.
org.eclipse.emf.teneo.hibernate.HbMapperException: Exception when saving
resource modelStore
at
org.eclipse.emf.teneo.hibernate.resource.HibernateResource.saveResource(HibernateResource.java:369)
at
org.eclipse.emf.teneo.resource.StoreResource.save(StoreResource.java:404)
at
org.unicase.emfstore.esmodel.impl.ServerSpaceImpl.save(ServerSpaceImpl.java:268)
at org.unicase.emfstore.EmfStoreImpl.save(EmfStoreImpl.java:332)
at org.unicase.emfstore.EmfStoreImpl.createVersion(EmfStoreImpl.java:110)
at
org.unicase.emfstore.connection.rmi.RMIEmfStoreFacadeImpl.createVersion(RMIEmfStoreFacadeImpl.java:89)
at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
at sun.reflect.NativeMethodAccessorImpl.invoke(Unknown Source)
at sun.reflect.DelegatingMethodAccessorImpl.invoke(Unknown Source)
at java.lang.reflect.Method.invoke(Unknown Source)
at sun.rmi.server.UnicastServerRef.dispatch(Unknown Source)
at sun.rmi.transport.Transport$1.run(Unknown Source)
at java.security.AccessController.doPrivileged(Native Method)
at sun.rmi.transport.Transport.serviceCall(Unknown Source)
at sun.rmi.transport.tcp.TCPTransport.handleMessages(Unknown Source)
at sun.rmi.transport.tcp.TCPTransport$ConnectionHandler.run0(Unknown
Source)
at sun.rmi.transport.tcp.TCPTransport$ConnectionHandler.run(Unknown Source)
at java.util.concurrent.ThreadPoolExecutor$Worker.runTask(Unknown Source)
at java.util.concurrent.ThreadPoolExecutor$Worker.run(Unknown Source)
at java.lang.Thread.run(Unknown Source)
Caused by: org.hibernate.ObjectDeletedException: deleted object would be
re-saved by cascade (remove deleted object from associations):
[LeafSection#630]
at org.hibernate.impl.SessionImpl.forceFlush(SessionImpl.java:1014)
at
org.hibernate.event.def.DefaultSaveOrUpdateEventListener.entityIsTransient(DefaultSaveOrUpdateEventListener.java:165)
at
org.hibernate.event.def.DefaultSaveOrUpdateEventListener.performSaveOrUpdate(DefaultSaveOrUpdateEventListener.java:94)
at
org.hibernate.event.def.DefaultSaveOrUpdateEventListener.onSaveOrUpdate(DefaultSaveOrUpdateEventListener.java:70)
at org.hibernate.impl.SessionImpl.fireSaveOrUpdate(SessionImpl.java:507)
at org.hibernate.impl.SessionImpl.saveOrUpdate(SessionImpl.java:499)
at org.hibernate.engine.CascadingAction$5.cascade(CascadingAction.java:218)
at org.hibernate.engine.Cascade.cascadeToOne(Cascade.java:268)
at org.hibernate.engine.Cascade.cascadeAssociation(Cascade.java:216)
at org.hibernate.engine.Cascade.cascadeProperty(Cascade.java:169)
at org.hibernate.engine.Cascade.cascadeCollectionElements(Cascade.java:296)
at org.hibernate.engine.Cascade.cascadeCollection(Cascade.java:242)
at org.hibernate.engine.Cascade.cascadeAssociation(Cascade.java:219)
at org.hibernate.engine.Cascade.cascadeProperty(Cascade.java:169)
at org.hibernate.engine.Cascade.cascade(Cascade.java:130)
at
org.hibernate.event.def.AbstractFlushingEventListener.cascadeOnFlush(AbstractFlushingEventListener.java:131)
at
org.hibernate.event.def.AbstractFlushingEventListener.prepareEntityFlushes(AbstractFlushingEventListener.java:122)
at
org.hibernate.event.def.AbstractFlushingEventListener.flushEverythingToExecutions(AbstractFlushingEventListener.java:65)
at
org.hibernate.event.def.DefaultFlushEventListener.onFlush(DefaultFlushEventListener.java:26)
at org.hibernate.impl.SessionImpl.flush(SessionImpl.java:1000)
at
org.eclipse.emf.teneo.hibernate.HbSessionWrapper.flush(HbSessionWrapper.java:171)
at
org.eclipse.emf.teneo.hibernate.resource.HibernateResource.saveResource(HibernateResource.java:363)
... 19 more
Martin Taal schrieb:
> With these latest settings what's the stacktrace you are seeing?
>
> Are the source and target container in the same resource?
>
> gr. Martin
>
> Otto wrote:
>> Hi,
>>
>> I still didn't manage to solve this issue. Can you maybe give me some
>> more hints where to look?
>>
>> Thank you in advance,
>> Otto
>>
>> Martin Taal schrieb:
>>> Hi Otto,
>>> Hmm, another approach is the following, can you use the following
>>> combination of options:
>>> CASCADE_POLICY_ON_CONTAINMENT to REMOVE,REFRESH,PERSIST,MERGE
>>> SET_CASCADE_ALL_ON_CONTAINMENT to false
>>>
>>> gr. Martin
>>>
>>> Otto wrote:
>>>> Hi Martin,
>>>>
>>>> thanks for your quick answer! As described on
>>>> http://www.elver.org/hibernate/hibernate_details.html#cutpaste i set
>>>> PersistenceOptions.SET_CASCADE_ALL_ON_CONTAINMENT to false, but then
>>>> i couldn't even save the first time:
>>>>
>>>> ibernate.TransientObjectException: object references an unsaved
>>>> transient instance - save the transient instance before flushing:
>>>> ProjectHistory
>>>> at
>>>> org.hibernate.engine.ForeignKeys.getEntityIdentifierIfNotUnsaved(ForeignKeys.java:219)
>>>>
>>>>
>>>> But on http://www.elver.org/hibernate/options.html I read that you
>>>> have to set it to true in order to enable orphan-delete. I tried
>>>> that too. Saving the first time didn't make any problems (as without
>>>> the option).
>>>> but then i moved a object and got:
>>>>
>>>> org.hibernate.ObjectDeletedException: deleted object would be
>>>> re-saved by cascade (remove deleted object from associations):
>>>> [MergingSolution#26]
>>>> at org.hibernate.impl.SessionImpl.forceFlush(SessionImpl.java:1014)
>>>> at
>>>> org.hibernate.event.def.DefaultSaveOrUpdateEventListener.entityIsTransient(DefaultSaveOrUpdateEventListener.java:165)
>>>>
>>>> at
>>>> org.hibernate.event.def.DefaultSaveOrUpdateEventListener.performSaveOrUpdate(DefaultSaveOrUpdateEventListener.java:94)
>>>>
>>>> at
>>>> org.hibernate.event.def.DefaultSaveOrUpdateEventListener.onSaveOrUpdate(DefaultSaveOrUpdateEventListener.java:70)
>>>>
>>>> at
>>>> org.hibernate.impl.SessionImpl.fireSaveOrUpdate(SessionImpl.java:507)
>>>> at
>>>> org.hibernate.impl.SessionImpl.saveOrUpdate(SessionImpl.java:499)
>>>> at
>>>> org.hibernate.engine.CascadingAction$5.cascade(CascadingAction.java:218)
>>>>
>>>> at org.hibernate.engine.Cascade.cascadeToOne(Cascade.java:268)
>>>> at
>>>> org.hibernate.engine.Cascade.cascadeAssociation(Cascade.java:216)
>>>> at org.hibernate.engine.Cascade.cascadeProperty(Cascade.java:169)
>>>>
>>>> Does this say anthing to you?
>>>>
>>>> Greetings,
>>>> Otto
>>>>
>>>> Martin Taal schrieb:
>>>>> Hi Otto,
>>>>> Yes, cust-past (move) between containers does now work nicely with
>>>>> hibernate's orphan-delete.
>>>>>
>>>>> What exceptions do you get when you set the
>>>>> PersistenceOptions.SET_CASCADE_ALL_ON_CONTAINMENT option?
>>>>>
>>>>> gr. Martin
>>>>>
>>>>> Otto wrote:
>>>>>> Hi guys,
>>>>>>
>>>>>> I'm experiencing some problems when changing the containment
>>>>>> position inside the containment tree (drag-n-drop in a treeview)
>>>>>> and then try to resave it with teneo. When moving a element from
>>>>>> one to another container i get 1 of 2 different exceptions, it
>>>>>> depends on the case, but i couldn't distinquish yet when which
>>>>>> case is triggered.
>>>>>> #1
>>>>>> te.exception.ConstraintViolationException: could not delete:
>>>>>> [Milestone#18]
>>>>>> [...]
>>>>>> java.sql.SQLException: Cannot delete or update a parent row: a
>>>>>> foreign key constraint fails
>>>>>> (`model/annotation_annotatedmodelelements`, CONSTRAINT
>>>>>> `annotation_annotatedmodelelements` FOREIGN KEY
>>>>>> (`modelelement_e_id`) REFERENCES `modelelement`
>>>>>> (`identifiableelement_e_id`))
>>>>>>
>>>>>> #2
>>>>>> deleted object would be re-saved by cascade, remove deleted object
>>>>>> from associations
>>>>>>
>>>>>> I found
>>>>>> http://www.elver.org/hibernate/hibernate_details.html#cutpaste on
>>>>>> the teneo page. I tried setting this globaloption
>>>>>> PersistenceOptions.SET_CASCADE_ALL_ON_CONTAINMENT and didn't work
>>>>>> and threw more exceptions. The second solution to set an
>>>>>> annotation for every sing containment reference isnt really handy
>>>>>> because we have quite some different containment references.
>>>>>>
>>>>>> I'm new to this and these erros don't tell me that much, so I
>>>>>> would really appreciate if you could give me some hints or even
>>>>>> solutions. Isn't there a easy way, i mean, changing containment is
>>>>>> a common usecase?!
>>>>>>
>>>>>> Thanks in advance.
>>>>>>
>>>>>> Greetings,
>>>>>> Otto
>>>>>
>>>>>
>>>
>>>
>
>
Re: [Teneo] containment changes - problems with resaving
Hi Otto,Maybe what happens is when the object is removed from its container that it is placed in the
removedObjects list of the hibernateresource. Then when it is put in the other container it is not
removed from the removedObjects list.
Can you put a breakpoint in the saveResource method in the HibernateResource. There is a separate
section there which removes each object. You can also see if your object is present in the
removedEObjects at that point.
gr. Martin
Otto wrote:
> Hi Martin,
>
> I love your quick answers
> CASCADE_POLICY_ON_NON_CONTAINMENT = "REMOVE,REFRESH,PERSIST,MERGE" and
> SET_CASCADE_ALL_ON_CONTAINMENT is not set at all. With this combination
> saving works, but moving an element throws the exception. The container
> are in the same resource.
>
>
> org.eclipse.emf.teneo.hibernate.HbMapperException: Exception when saving
> resource modelStore
> at
> org.eclipse.emf.teneo.hibernate.resource.HibernateResource.saveResource(HibernateResource.java:369)
>
> at
> org.eclipse.emf.teneo.resource.StoreResource.save(StoreResource.java:404)
> at
> org.unicase.emfstore.esmodel.impl.ServerSpaceImpl.save(ServerSpaceImpl.java:268)
>
> at org.unicase.emfstore.EmfStoreImpl.save(EmfStoreImpl.java:332)
> at
> org.unicase.emfstore.EmfStoreImpl.createVersion(EmfStoreImpl.java:110)
> at
> org.unicase.emfstore.connection.rmi.RMIEmfStoreFacadeImpl.createVersion(RMIEmfStoreFacadeImpl.java:89)
>
> at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
> at sun.reflect.NativeMethodAccessorImpl.invoke(Unknown Source)
> at sun.reflect.DelegatingMethodAccessorImpl.invoke(Unknown Source)
> at java.lang.reflect.Method.invoke(Unknown Source)
> at sun.rmi.server.UnicastServerRef.dispatch(Unknown Source)
> at sun.rmi.transport.Transport$1.run(Unknown Source)
> at java.security.AccessController.doPrivileged(Native Method)
> at sun.rmi.transport.Transport.serviceCall(Unknown Source)
> at sun.rmi.transport.tcp.TCPTransport.handleMessages(Unknown Source)
> at sun.rmi.transport.tcp.TCPTransport$ConnectionHandler.run0(Unknown
> Source)
> at sun.rmi.transport.tcp.TCPTransport$ConnectionHandler.run(Unknown
> Source)
> at java.util.concurrent.ThreadPoolExecutor$Worker.runTask(Unknown
> Source)
> at java.util.concurrent.ThreadPoolExecutor$Worker.run(Unknown Source)
> at java.lang.Thread.run(Unknown Source)
> Caused by: org.hibernate.ObjectDeletedException: deleted object would be
> re-saved by cascade (remove deleted object from associations):
> [LeafSection#630]
> at org.hibernate.impl.SessionImpl.forceFlush(SessionImpl.java:1014)
> at
> org.hibernate.event.def.DefaultSaveOrUpdateEventListener.entityIsTransient(DefaultSaveOrUpdateEventListener.java:165)
>
> at
> org.hibernate.event.def.DefaultSaveOrUpdateEventListener.performSaveOrUpdate(DefaultSaveOrUpdateEventListener.java:94)
>
> at
> org.hibernate.event.def.DefaultSaveOrUpdateEventListener.onSaveOrUpdate(DefaultSaveOrUpdateEventListener.java:70)
>
> at
> org.hibernate.impl.SessionImpl.fireSaveOrUpdate(SessionImpl.java:507)
> at org.hibernate.impl.SessionImpl.saveOrUpdate(SessionImpl.java:499)
> at
> org.hibernate.engine.CascadingAction$5.cascade(CascadingAction.java:218)
> at org.hibernate.engine.Cascade.cascadeToOne(Cascade.java:268)
> at org.hibernate.engine.Cascade.cascadeAssociation(Cascade.java:216)
> at org.hibernate.engine.Cascade.cascadeProperty(Cascade.java:169)
> at
> org.hibernate.engine.Cascade.cascadeCollectionElements(Cascade.java:296)
> at org.hibernate.engine.Cascade.cascadeCollection(Cascade.java:242)
> at org.hibernate.engine.Cascade.cascadeAssociation(Cascade.java:219)
> at org.hibernate.engine.Cascade.cascadeProperty(Cascade.java:169)
> at org.hibernate.engine.Cascade.cascade(Cascade.java:130)
> at
> org.hibernate.event.def.AbstractFlushingEventListener.cascadeOnFlush(AbstractFlushingEventListener.java:131)
>
> at
> org.hibernate.event.def.AbstractFlushingEventListener.prepareEntityFlushes(AbstractFlushingEventListener.java:122)
>
> at
> org.hibernate.event.def.AbstractFlushingEventListener.flushEverythingToExecutions(AbstractFlushingEventListener.java:65)
>
> at
> org.hibernate.event.def.DefaultFlushEventListener.onFlush(DefaultFlushEventListener.java:26)
>
> at org.hibernate.impl.SessionImpl.flush(SessionImpl.java:1000)
> at
> org.eclipse.emf.teneo.hibernate.HbSessionWrapper.flush(HbSessionWrapper.java:171)
>
> at
> org.eclipse.emf.teneo.hibernate.resource.HibernateResource.saveResource(HibernateResource.java:363)
>
> ... 19 more
>
> Martin Taal schrieb:
>> With these latest settings what's the stacktrace you are seeing?
>>
>> Are the source and target container in the same resource?
>>
>> gr. Martin
>>
>> Otto wrote:
>>> Hi,
>>>
>>> I still didn't manage to solve this issue. Can you maybe give me some
>>> more hints where to look?
>>>
>>> Thank you in advance,
>>> Otto
>>>
>>> Martin Taal schrieb:
>>>> Hi Otto,
>>>> Hmm, another approach is the following, can you use the following
>>>> combination of options:
>>>> CASCADE_POLICY_ON_CONTAINMENT to REMOVE,REFRESH,PERSIST,MERGE
>>>> SET_CASCADE_ALL_ON_CONTAINMENT to false
>>>>
>>>> gr. Martin
>>>>
>>>> Otto wrote:
>>>>> Hi Martin,
>>>>>
>>>>> thanks for your quick answer! As described on
>>>>> http://www.elver.org/hibernate/hibernate_details.html#cutpaste i
>>>>> set PersistenceOptions.SET_CASCADE_ALL_ON_CONTAINMENT to false, but
>>>>> then i couldn't even save the first time:
>>>>>
>>>>> ibernate.TransientObjectException: object references an unsaved
>>>>> transient instance - save the transient instance before flushing:
>>>>> ProjectHistory
>>>>> at
>>>>> org.hibernate.engine.ForeignKeys.getEntityIdentifierIfNotUnsaved(ForeignKeys.java:219)
>>>>>
>>>>>
>>>>> But on http://www.elver.org/hibernate/options.html I read that you
>>>>> have to set it to true in order to enable orphan-delete. I tried
>>>>> that too. Saving the first time didn't make any problems (as
>>>>> without the option).
>>>>> but then i moved a object and got:
>>>>>
>>>>> org.hibernate.ObjectDeletedException: deleted object would be
>>>>> re-saved by cascade (remove deleted object from associations):
>>>>> [MergingSolution#26]
>>>>> at
>>>>> org.hibernate.impl.SessionImpl.forceFlush(SessionImpl.java:1014)
>>>>> at
>>>>> org.hibernate.event.def.DefaultSaveOrUpdateEventListener.entityIsTransient(DefaultSaveOrUpdateEventListener.java:165)
>>>>>
>>>>> at
>>>>> org.hibernate.event.def.DefaultSaveOrUpdateEventListener.performSaveOrUpdate(DefaultSaveOrUpdateEventListener.java:94)
>>>>>
>>>>> at
>>>>> org.hibernate.event.def.DefaultSaveOrUpdateEventListener.onSaveOrUpdate(DefaultSaveOrUpdateEventListener.java:70)
>>>>>
>>>>> at
>>>>> org.hibernate.impl.SessionImpl.fireSaveOrUpdate(SessionImpl.java:507)
>>>>> at
>>>>> org.hibernate.impl.SessionImpl.saveOrUpdate(SessionImpl.java:499)
>>>>> at
>>>>> org.hibernate.engine.CascadingAction$5.cascade(CascadingAction.java:218)
>>>>>
>>>>> at org.hibernate.engine.Cascade.cascadeToOne(Cascade.java:268)
>>>>> at
>>>>> org.hibernate.engine.Cascade.cascadeAssociation(Cascade.java:216)
>>>>> at org.hibernate.engine.Cascade.cascadeProperty(Cascade.java:169)
>>>>>
>>>>> Does this say anthing to you?
>>>>>
>>>>> Greetings,
>>>>> Otto
>>>>>
>>>>> Martin Taal schrieb:
>>>>>> Hi Otto,
>>>>>> Yes, cust-past (move) between containers does now work nicely with
>>>>>> hibernate's orphan-delete.
>>>>>>
>>>>>> What exceptions do you get when you set the
>>>>>> PersistenceOptions.SET_CASCADE_ALL_ON_CONTAINMENT option?
>>>>>>
>>>>>> gr. Martin
>>>>>>
>>>>>> Otto wrote:
>>>>>>> Hi guys,
>>>>>>>
>>>>>>> I'm experiencing some problems when changing the containment
>>>>>>> position inside the containment tree (drag-n-drop in a treeview)
>>>>>>> and then try to resave it with teneo. When moving a element from
>>>>>>> one to another container i get 1 of 2 different exceptions, it
>>>>>>> depends on the case, but i couldn't distinquish yet when which
>>>>>>> case is triggered.
>>>>>>> #1
>>>>>>> te.exception.ConstraintViolationException: could not delete:
>>>>>>> [Milestone#18]
>>>>>>> [...]
>>>>>>> java.sql.SQLException: Cannot delete or update a parent row: a
>>>>>>> foreign key constraint fails
>>>>>>> (`model/annotation_annotatedmodelelements`, CONSTRAINT
>>>>>>> `annotation_annotatedmodelelements` FOREIGN KEY
>>>>>>> (`modelelement_e_id`) REFERENCES `modelelement`
>>>>>>> (`identifiableelement_e_id`))
>>>>>>>
>>>>>>> #2
>>>>>>> deleted object would be re-saved by cascade, remove deleted
>>>>>>> object from associations
>>>>>>>
>>>>>>> I found
>>>>>>> http://www.elver.org/hibernate/hibernate_details.html#cutpaste on
>>>>>>> the teneo page. I tried setting this globaloption
>>>>>>> PersistenceOptions.SET_CASCADE_ALL_ON_CONTAINMENT and didn't work
>>>>>>> and threw more exceptions. The second solution to set an
>>>>>>> annotation for every sing containment reference isnt really handy
>>>>>>> because we have quite some different containment references.
>>>>>>>
>>>>>>> I'm new to this and these erros don't tell me that much, so I
>>>>>>> would really appreciate if you could give me some hints or even
>>>>>>> solutions. Isn't there a easy way, i mean, changing containment
>>>>>>> is a common usecase?!
>>>>>>>
>>>>>>> Thanks in advance.
>>>>>>>
>>>>>>> Greetings,
>>>>>>> Otto
>>>>>>
>>>>>>
>>>>
>>>>
>>
>>
--
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 at springsite dot com - mtaal at elver dot org
Web: www.springsite.com - www.elver.org
Re: [Teneo] containment changes - problems with resaving
And can you post the part of the hbm which covers the containment relation, to be sure that thedelete-orphan is indeed not present.
gr. Martin
Otto wrote:
> Hi Martin,
>
> I love your quick answers
> CASCADE_POLICY_ON_NON_CONTAINMENT = "REMOVE,REFRESH,PERSIST,MERGE" and
> SET_CASCADE_ALL_ON_CONTAINMENT is not set at all. With this combination
> saving works, but moving an element throws the exception. The container
> are in the same resource.
>
>
> org.eclipse.emf.teneo.hibernate.HbMapperException: Exception when saving
> resource modelStore
> at
> org.eclipse.emf.teneo.hibernate.resource.HibernateResource.saveResource(HibernateResource.java:369)
>
> at
> org.eclipse.emf.teneo.resource.StoreResource.save(StoreResource.java:404)
> at
> org.unicase.emfstore.esmodel.impl.ServerSpaceImpl.save(ServerSpaceImpl.java:268)
>
> at org.unicase.emfstore.EmfStoreImpl.save(EmfStoreImpl.java:332)
> at
> org.unicase.emfstore.EmfStoreImpl.createVersion(EmfStoreImpl.java:110)
> at
> org.unicase.emfstore.connection.rmi.RMIEmfStoreFacadeImpl.createVersion(RMIEmfStoreFacadeImpl.java:89)
>
> at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
> at sun.reflect.NativeMethodAccessorImpl.invoke(Unknown Source)
> at sun.reflect.DelegatingMethodAccessorImpl.invoke(Unknown Source)
> at java.lang.reflect.Method.invoke(Unknown Source)
> at sun.rmi.server.UnicastServerRef.dispatch(Unknown Source)
> at sun.rmi.transport.Transport$1.run(Unknown Source)
> at java.security.AccessController.doPrivileged(Native Method)
> at sun.rmi.transport.Transport.serviceCall(Unknown Source)
> at sun.rmi.transport.tcp.TCPTransport.handleMessages(Unknown Source)
> at sun.rmi.transport.tcp.TCPTransport$ConnectionHandler.run0(Unknown
> Source)
> at sun.rmi.transport.tcp.TCPTransport$ConnectionHandler.run(Unknown
> Source)
> at java.util.concurrent.ThreadPoolExecutor$Worker.runTask(Unknown
> Source)
> at java.util.concurrent.ThreadPoolExecutor$Worker.run(Unknown Source)
> at java.lang.Thread.run(Unknown Source)
> Caused by: org.hibernate.ObjectDeletedException: deleted object would be
> re-saved by cascade (remove deleted object from associations):
> [LeafSection#630]
> at org.hibernate.impl.SessionImpl.forceFlush(SessionImpl.java:1014)
> at
> org.hibernate.event.def.DefaultSaveOrUpdateEventListener.entityIsTransient(DefaultSaveOrUpdateEventListener.java:165)
>
> at
> org.hibernate.event.def.DefaultSaveOrUpdateEventListener.performSaveOrUpdate(DefaultSaveOrUpdateEventListener.java:94)
>
> at
> org.hibernate.event.def.DefaultSaveOrUpdateEventListener.onSaveOrUpdate(DefaultSaveOrUpdateEventListener.java:70)
>
> at
> org.hibernate.impl.SessionImpl.fireSaveOrUpdate(SessionImpl.java:507)
> at org.hibernate.impl.SessionImpl.saveOrUpdate(SessionImpl.java:499)
> at
> org.hibernate.engine.CascadingAction$5.cascade(CascadingAction.java:218)
> at org.hibernate.engine.Cascade.cascadeToOne(Cascade.java:268)
> at org.hibernate.engine.Cascade.cascadeAssociation(Cascade.java:216)
> at org.hibernate.engine.Cascade.cascadeProperty(Cascade.java:169)
> at
> org.hibernate.engine.Cascade.cascadeCollectionElements(Cascade.java:296)
> at org.hibernate.engine.Cascade.cascadeCollection(Cascade.java:242)
> at org.hibernate.engine.Cascade.cascadeAssociation(Cascade.java:219)
> at org.hibernate.engine.Cascade.cascadeProperty(Cascade.java:169)
> at org.hibernate.engine.Cascade.cascade(Cascade.java:130)
> at
> org.hibernate.event.def.AbstractFlushingEventListener.cascadeOnFlush(AbstractFlushingEventListener.java:131)
>
> at
> org.hibernate.event.def.AbstractFlushingEventListener.prepareEntityFlushes(AbstractFlushingEventListener.java:122)
>
> at
> org.hibernate.event.def.AbstractFlushingEventListener.flushEverythingToExecutions(AbstractFlushingEventListener.java:65)
>
> at
> org.hibernate.event.def.DefaultFlushEventListener.onFlush(DefaultFlushEventListener.java:26)
>
> at org.hibernate.impl.SessionImpl.flush(SessionImpl.java:1000)
> at
> org.eclipse.emf.teneo.hibernate.HbSessionWrapper.flush(HbSessionWrapper.java:171)
>
> at
> org.eclipse.emf.teneo.hibernate.resource.HibernateResource.saveResource(HibernateResource.java:363)
>
> ... 19 more
>
> Martin Taal schrieb:
>> With these latest settings what's the stacktrace you are seeing?
>>
>> Are the source and target container in the same resource?
>>
>> gr. Martin
>>
>> Otto wrote:
>>> Hi,
>>>
>>> I still didn't manage to solve this issue. Can you maybe give me some
>>> more hints where to look?
>>>
>>> Thank you in advance,
>>> Otto
>>>
>>> Martin Taal schrieb:
>>>> Hi Otto,
>>>> Hmm, another approach is the following, can you use the following
>>>> combination of options:
>>>> CASCADE_POLICY_ON_CONTAINMENT to REMOVE,REFRESH,PERSIST,MERGE
>>>> SET_CASCADE_ALL_ON_CONTAINMENT to false
>>>>
>>>> gr. Martin
>>>>
>>>> Otto wrote:
>>>>> Hi Martin,
>>>>>
>>>>> thanks for your quick answer! As described on
>>>>> http://www.elver.org/hibernate/hibernate_details.html#cutpaste i
>>>>> set PersistenceOptions.SET_CASCADE_ALL_ON_CONTAINMENT to false, but
>>>>> then i couldn't even save the first time:
>>>>>
>>>>> ibernate.TransientObjectException: object references an unsaved
>>>>> transient instance - save the transient instance before flushing:
>>>>> ProjectHistory
>>>>> at
>>>>> org.hibernate.engine.ForeignKeys.getEntityIdentifierIfNotUnsaved(ForeignKeys.java:219)
>>>>>
>>>>>
>>>>> But on http://www.elver.org/hibernate/options.html I read that you
>>>>> have to set it to true in order to enable orphan-delete. I tried
>>>>> that too. Saving the first time didn't make any problems (as
>>>>> without the option).
>>>>> but then i moved a object and got:
>>>>>
>>>>> org.hibernate.ObjectDeletedException: deleted object would be
>>>>> re-saved by cascade (remove deleted object from associations):
>>>>> [MergingSolution#26]
>>>>> at
>>>>> org.hibernate.impl.SessionImpl.forceFlush(SessionImpl.java:1014)
>>>>> at
>>>>> org.hibernate.event.def.DefaultSaveOrUpdateEventListener.entityIsTransient(DefaultSaveOrUpdateEventListener.java:165)
>>>>>
>>>>> at
>>>>> org.hibernate.event.def.DefaultSaveOrUpdateEventListener.performSaveOrUpdate(DefaultSaveOrUpdateEventListener.java:94)
>>>>>
>>>>> at
>>>>> org.hibernate.event.def.DefaultSaveOrUpdateEventListener.onSaveOrUpdate(DefaultSaveOrUpdateEventListener.java:70)
>>>>>
>>>>> at
>>>>> org.hibernate.impl.SessionImpl.fireSaveOrUpdate(SessionImpl.java:507)
>>>>> at
>>>>> org.hibernate.impl.SessionImpl.saveOrUpdate(SessionImpl.java:499)
>>>>> at
>>>>> org.hibernate.engine.CascadingAction$5.cascade(CascadingAction.java:218)
>>>>>
>>>>> at org.hibernate.engine.Cascade.cascadeToOne(Cascade.java:268)
>>>>> at
>>>>> org.hibernate.engine.Cascade.cascadeAssociation(Cascade.java:216)
>>>>> at org.hibernate.engine.Cascade.cascadeProperty(Cascade.java:169)
>>>>>
>>>>> Does this say anthing to you?
>>>>>
>>>>> Greetings,
>>>>> Otto
>>>>>
>>>>> Martin Taal schrieb:
>>>>>> Hi Otto,
>>>>>> Yes, cust-past (move) between containers does now work nicely with
>>>>>> hibernate's orphan-delete.
>>>>>>
>>>>>> What exceptions do you get when you set the
>>>>>> PersistenceOptions.SET_CASCADE_ALL_ON_CONTAINMENT option?
>>>>>>
>>>>>> gr. Martin
>>>>>>
>>>>>> Otto wrote:
>>>>>>> Hi guys,
>>>>>>>
>>>>>>> I'm experiencing some problems when changing the containment
>>>>>>> position inside the containment tree (drag-n-drop in a treeview)
>>>>>>> and then try to resave it with teneo. When moving a element from
>>>>>>> one to another container i get 1 of 2 different exceptions, it
>>>>>>> depends on the case, but i couldn't distinquish yet when which
>>>>>>> case is triggered.
>>>>>>> #1
>>>>>>> te.exception.ConstraintViolationException: could not delete:
>>>>>>> [Milestone#18]
>>>>>>> [...]
>>>>>>> java.sql.SQLException: Cannot delete or update a parent row: a
>>>>>>> foreign key constraint fails
>>>>>>> (`model/annotation_annotatedmodelelements`, CONSTRAINT
>>>>>>> `annotation_annotatedmodelelements` FOREIGN KEY
>>>>>>> (`modelelement_e_id`) REFERENCES `modelelement`
>>>>>>> (`identifiableelement_e_id`))
>>>>>>>
>>>>>>> #2
>>>>>>> deleted object would be re-saved by cascade, remove deleted
>>>>>>> object from associations
>>>>>>>
>>>>>>> I found
>>>>>>> http://www.elver.org/hibernate/hibernate_details.html#cutpaste on
>>>>>>> the teneo page. I tried setting this globaloption
>>>>>>> PersistenceOptions.SET_CASCADE_ALL_ON_CONTAINMENT and didn't work
>>>>>>> and threw more exceptions. The second solution to set an
>>>>>>> annotation for every sing containment reference isnt really handy
>>>>>>> because we have quite some different containment references.
>>>>>>>
>>>>>>> I'm new to this and th