|
From: Kopylenko, D. <dko...@ac...> - 2003-10-16 21:39:31
|
Petra,
a little correction
1) Rollback/Commit rule (-) or (+) should be a prefix of Exception name
2) You should not specify FQN of the exception. You just do it like this:
+MyException1,-MyException2
3) If you do not declare any "rollback/commit" rules for the exceptions, the
default behaviour of the framework is to rollback on the RuntimeExceptions
and commit otherwise (if you applying AOP Tx interceptor)
Regards,
Dmitriy.
-----Original Message-----
From: Kopylenko, Dmitry
To: 'petra staub'; 'spr...@li...'
Sent: 10/16/2003 3:48 PM
Subject: RE: [Springframework-developer] Transactions / AOP / Hibernate
Petra,
> In my case I have now business/management object which make use of
more
than only one DAO (is this ok?)
That is perfectly ok.
>Can I somehow get control of the actual transaction functionality? What
possiblities do I have? Are rollbacks automatically performed if
>something goes wrong?
In general, if the Exception is thrown by the DAO (usually unchecked)
and is
caught by Tx interceptor, then the transaction is rolled back
automatically.
But you could declaratively specify the Exceptions for which you want to
rollback and for which you want to commit if caught by Tx AOP e.g.
<bean id="exampleTransactionInterceptor"
class="org.springframework.transaction.interceptor.TransactionIntercepto
r">
<property name="transactionManager"><ref
bean="myTransactionManager"/></property>
<property name="transactionAttributeSource">
<value>
example.ExampleBusinessInterface.exampleMethod=PROPAGATION_REQUIRED,com.
myco
mpany.MyException1+,com.mycompany.MyException2-
example.ExampleBusinessInterface.anotherExampleMethod=PROPAGATION_REQUIR
ED
</value>
</property>
</bean>
So the (+) in the declaration: "com.mycompany.MyException1+" directs Tx
AOP
infrastructure to commit the transaction if this exception is caught and
respectively (-): com.mycompany.MyException1- says roll it back.
Hope this helps,
Dmitriy.
-----Original Message-----
From: petra staub [mailto:ca...@ho...]
Sent: Thursday, October 16, 2003 3:21 PM
To: spr...@li...
Subject: [Springframework-developer] Transactions / AOP / Hibernate
Hi
I have a question to the transaction handling with Springframework, in
details, applying Declarative Transaction Demarcation (as outlined in
the
"Data Access with the Spring Framework" on Hibernates site).
In advance, sorry for my little knowledge on AOP which may be the main
reason for my question here... ;
Well, as I understood, you can declare an "Interceptor" which inserts/
"weaves in" transaction management code into the appropriate class
methods.
I think this happens when entering and exiting the methods or am I
wrong?
In my little application, I have (as suggested by Dmitry in an earlier
posting) created DAO objects, which do not know anything about trans-
actions and soley perform "basic" database work, and business objects,
or
"management beans" which use these DAO objects and provide the final
interface for persisting methods to the user.
In my case I have now business/management object which make use of more
than
only one DAO (is this ok?). I would like to things like
BusinessObject {
a_Method {
(Transactions start by Interceptor??)
DAO_A.do_something; ---> requires transactions
DAO_B.do_something_else; ---> must not be transaction
oriented
(Transaction commit by Interceptor??)
}
}
Can I somehow get control of the actual transaction functionality? What
possiblities do I have? Are rollbacks automatically performed if
something
goes wrong?
This AOP stuff does for me some "magic" stuff, I just can't grasp
somehow...
:-)
Thanks for any Springframework-brush ups! ;-)
_________________________________________________________________
MSN Hotmail - Absolut kostenfrei! Der weltweit grösste E-Mail-Anbieter
im
Netz: http://www.msn.ch/hotmail
-------------------------------------------------------
This SF.net email is sponsored by: SF.net Giveback Program.
SourceForge.net
hosts over 70,000 Open Source Projects. See the people who have HELPED
US
provide better services: Click here:
http://sourceforge.net/supporters.php
_______________________________________________
Springframework-developer mailing list
Spr...@li...
https://lists.sourceforge.net/lists/listinfo/springframework-developer
-------------------------------------------------------
This SF.net email is sponsored by: SF.net Giveback Program.
SourceForge.net hosts over 70,000 Open Source Projects.
See the people who have HELPED US provide better services:
Click here: http://sourceforge.net/supporters.php
_______________________________________________
Springframework-developer mailing list
Spr...@li...
https://lists.sourceforge.net/lists/listinfo/springframework-developer
|