Note that there are some explanatory texts on larger screens.

plurals
  1. PO
    primarykey
    data
    text
    <p>The way Spring handle the transaction through Annotation is using AOP as you've said. The AOP bit is implemented using Dynamic Proxies (see <a href="http://download.oracle.com/javase/1.3/docs/guide/reflection/proxy.html" rel="nofollow">doc</a>)</p> <p>So in order to do so you'll need to retrieve an instance of your class (Pojo here) through the spring container since to make it work, Spring will return you a Dynamic Proxy over your Pojo that will automatically surround any annotated method with the transaction management code.</p> <p>If you simply do a </p> <pre><code>Pojo p = new Pojo(); p.doInTransaction(); </code></pre> <p>Spring doesn't have any role to play here and your method call won't be inside a transaction.</p> <p>so what you need to do is something like this</p> <pre><code>ApplicationContext springContext = ...; Pojo p = (Pojo) springContext.getBean("your.pojo.id"); p.doInTransaction(); </code></pre> <p>Note: this is an example, you should prefer dependency injection instead of retrieving your bean manually from the context</p> <p>By doing so, and with a properly configured Spring Context, Spring should have lookout your classes to scan for transactional annotation and automatically wrapped your beans into annotation aware dynamic proxies instances. From your point of view that doesn't change anything, you'll still cast your object to your own Classes, but if you try to print out the class name of your spring context Pojo bean, you'll get something as Proxy$... and not your original class name.</p> <p>Have a look at this link anyway : <a href="http://static.springsource.org/spring/docs/2.0.x/reference/transaction.html" rel="nofollow">link text</a></p>
    singulars
    1. This table or related slice is empty.
    plurals
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
 

Querying!

 
Guidance

SQuiL has stopped working due to an internal error.

If you are curious you may find further information in the browser console, which is accessible through the devtools (F12).

Reload