[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index] [Newsgroup Home]
[news.eclipse.tools.emf] Re: Question about Teneo/Hibernate and Transactions

Hi Josef,
Transactions can be handled in 2 ways:
- a resource has its own session and the resource.save is done in a transaction managed by the resource itself
- resources can share a session/transaction, see here:
http://www.elver.org/hibernate/hibernateresources.html#Sharing+one+Session+between+Resources%2C+One+transaction+when+saving+multiple+resources

For the case you mention below (assuming that the objects are in different resources) you have to share a session between resources.

If all the objects are in one resource then the scenario you describe is not possible between two save actions. In this case you have to nullify the reference before deleting the referenced object. So the actions can be done on the model in 3 steps but can only be persisted in one save action.

This should also apply to 1.0.4 which I guess you are using.

gr. Martin

Josef Duschl wrote:
Hi,

How are transactions managed in the EMF/Teneo/Hibernate ressources?

Ie. is it possible to do following modifications between two ressource.save() calls?

* Delete an object which is referenced by another one by foreign key without deleting the referencing object.
* Create a new object to replace the deleted one.
* Make the reference point to the new object instead of the deleted one.


When doing that, I get a SQL exception stating that a foreign key constraint has been violated.
Will the three modifications, when done in three separate steps on the model, be executed as three separate operations (transactions) on the database?


Kind Regards,

Josef



--

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@xxxxxxxxxxxxxx - mtaal@xxxxxxxxx
Web: www.springsite.com - www.elver.org