[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

The objects are all in one resource. So do I read you correctly, that whatever single action I perform on the model, in this case, is reflected as one single commit on the database. The order of performing the actions also determines the order of execution on the database.

Martin Taal wrote:

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