| [news.eclipse.tools.emf] Re: Question about Teneo/Hibernate and Transactions |
Martin Taal wrote:
Hi Josef,transaction managed by the resource itself
Transactions can be handled in 2 ways:
- a resource has its own session and the resource.save is done in a
- 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 differentresources) you have to share a session
between resources.
If all the objects are in one resource then the scenario you describe is notpossible between two save actions. In this
case you have to nullify the reference before deleting the referencedobject. 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