[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
|
- From: Martin Taal <mtaal@xxxxxxxxx>
- Date: Tue, 15 Sep 2009 13:47:25 +0200
- Newsgroups: eclipse.tools.emf
- Organization: EclipseCorner
- User-agent: Thunderbird 2.0.0.23 (X11/20090817)
Hi Josef,
Every save results in a commit, so if you do a save on each action then you get a commit on each action, and the order
is determined by the order of the calls to .save(..). If you do multiple actions on the model and then do one save then
Hibernate will try to find an optimal execution order.
gr. Martin
Josef Duschl wrote:
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
--
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