Skip to main content


Eclipse Community Forums
Forum Search:

Search      Help    Register    Login    Home
Home » Modeling » EMF » [TENEO] PersistenceOptions.CASCADE_POLICY_ON_CONTAINMENT, "FALSE" and Addition of a new Ob
[TENEO] PersistenceOptions.CASCADE_POLICY_ON_CONTAINMENT, "FALSE" and Addition of a new Ob [message #491465] Wed, 14 October 2009 17:19 Go to next message
Waldi  is currently offline Waldi Friend
Messages: 60
Registered: July 2009
Member
Dear All,

I set the PersistenceOptions.CASCADE_POLICY_ON_CONTAINMENT, "FALSE",
because if I had a relation between 2 Objects (from diffrent resources)
and I delete relation, only the relation should be deleted not the
inheritance Object. Now, if I create a new Object and try to Persist it a

14372 [main] ERROR org.hibernate.event.def.AbstractFlushingEventListener
- Could not synchronize database state with session
org.hibernate.TransientObjectException: object references an unsaved
transient instance - save the transient instance before flushing: Lager

will appear.

The following Command works really fine but if i persist exception above
occur

Lager lager = ZlvpFactory.eINSTANCE.createLager();
lager.setName("Neues Lager");
Command cmd = null;
if (obj instanceof Jahr) {
cmd = AddCommand.create(service.getEditingDomain(), (Jahr)obj,
ZlvpPackage.Literals.JAHR__LAGER, lager);
}

if (cmd.canExecute()) {
service.getEditingDomain().getCommandStack().execute(cmd);
} else {
throw new ExecutionException("Fehler beim Anlegen des Lagers");
}

If I set PersistenceOptions.CASCADE_POLICY_ON_CONTAINMENT, "true" all
works fine but the inheritance Object will be deleted.
Re: [TENEO] PersistenceOptions.CASCADE_POLICY_ON_CONTAINMENT, "FALSE" and Addition of a ne [message #491515 is a reply to message #491465] Wed, 14 October 2009 20:36 Go to previous messageGo to next message
Martin Taal is currently offline Martin TaalFriend
Messages: 5468
Registered: July 2009
Senior Member
Hi Waldi,
FALSE is not a valid value for this option. But maybe you mean the SET_CASCADE_ALL_ON_CONTAINMENT option?

In this case I would set the PersistenceOptions.CASCADE_POLICY_ON_CONTAINMENT option to the following values:
REFRESH,PERSIST,MERGE

gr. Martin

Waldi Waldemar wrote:
> Dear All,
>
> I set the PersistenceOptions.CASCADE_POLICY_ON_CONTAINMENT, "FALSE",
> because if I had a relation between 2 Objects (from diffrent resources)
> and I delete relation, only the relation should be deleted not the
> inheritance Object. Now, if I create a new Object and try to Persist it a
>
> 14372 [main] ERROR org.hibernate.event.def.AbstractFlushingEventListener
> - Could not synchronize database state with session
> org.hibernate.TransientObjectException: object references an unsaved
> transient instance - save the transient instance before flushing: Lager
>
> will appear.
>
> The following Command works really fine but if i persist exception above
> occur
>
> Lager lager = ZlvpFactory.eINSTANCE.createLager();
> lager.setName("Neues Lager");
> Command cmd = null;
> if (obj instanceof Jahr) {
> cmd = AddCommand.create(service.getEditingDomain(),
> (Jahr)obj, ZlvpPackage.Literals.JAHR__LAGER, lager);
> }
>
> if (cmd.canExecute()) {
> service.getEditingDomain().getCommandStack().execute(cmd);
> } else {
> throw new ExecutionException("Fehler beim Anlegen des
> Lagers");
> }
>
> If I set PersistenceOptions.CASCADE_POLICY_ON_CONTAINMENT, "true" all
> works fine but the inheritance Object will be deleted.


--

With Regards, Martin Taal

Springsite/Elver.org
Office: Hardwareweg 4, 3821 BV Amersfoort
Postal: Nassaulaan 7, 3941 EC Doorn
The Netherlands
Cell: +31 (0)6 288 48 943
Tel: +31 (0)84 420 2397
Fax: +31 (0)84 225 9307
Mail: mtaal@springsite.com - mtaal@elver.org
Web: www.springsite.com - www.elver.org
Re: [TENEO] PersistenceOptions.CASCADE_POLICY_ON_CONTAINMENT, "FALSE" and Addition of a ne [message #491533 is a reply to message #491515] Wed, 14 October 2009 21:45 Go to previous message
Waldi  is currently offline Waldi Friend
Messages: 60
Registered: July 2009
Member
mysterious. Hmm but i try it, why does it run?? OK thanks a lot... It
works fine



Martin Taal schrieb:
> Hi Waldi,
> FALSE is not a valid value for this option. But maybe you mean the
> SET_CASCADE_ALL_ON_CONTAINMENT option?
>
> In this case I would set the
> PersistenceOptions.CASCADE_POLICY_ON_CONTAINMENT option to the following
> values: REFRESH,PERSIST,MERGE
>
> gr. Martin
>
> Waldi Waldemar wrote:
>> Dear All,
>>
>> I set the PersistenceOptions.CASCADE_POLICY_ON_CONTAINMENT, "FALSE",
>> because if I had a relation between 2 Objects (from diffrent
>> resources) and I delete relation, only the relation should be deleted
>> not the inheritance Object. Now, if I create a new Object and try to
>> Persist it a
>>
>> 14372 [main] ERROR
>> org.hibernate.event.def.AbstractFlushingEventListener - Could not
>> synchronize database state with session
>> org.hibernate.TransientObjectException: object references an unsaved
>> transient instance - save the transient instance before flushing: Lager
>>
>> will appear.
>>
>> The following Command works really fine but if i persist exception
>> above occur
>>
>> Lager lager = ZlvpFactory.eINSTANCE.createLager();
>> lager.setName("Neues Lager");
>> Command cmd = null;
>> if (obj instanceof Jahr) {
>> cmd = AddCommand.create(service.getEditingDomain(),
>> (Jahr)obj, ZlvpPackage.Literals.JAHR__LAGER, lager);
>> }
>>
>> if (cmd.canExecute()) {
>>
>> service.getEditingDomain().getCommandStack().execute(cmd);
>> } else {
>> throw new ExecutionException("Fehler beim Anlegen des
>> Lagers");
>> }
>>
>> If I set PersistenceOptions.CASCADE_POLICY_ON_CONTAINMENT, "true" all
>> works fine but the inheritance Object will be deleted.
>
>
Previous Topic:XMLTypeFactoryImpl fails to recreate QNames properly while "undoing change"
Next Topic:[CDO] CDO server log trace
Goto Forum:
  


Current Time: Fri Apr 26 20:17:19 GMT 2024

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

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

Back to the top