Hi all,
I have a web application configured with Spring 3.0 + JPA. The services are annotated for transactions using a custom annotation. For example, a transactional method could be annotated as following:
As explained here, I configured my own annotation parser which is used to get extra information about the transactionality (the @MyCustomTransactionalAnnotation above).Code:@MyCustomTransactionalAnnotation(value=true) @Transactional public void myServiceMethod() { // ... }
Eventually (when a transaction is needed) Spring's JpaTransactionManager will call my own JpaDialect, passing both the EntityManger and the TransactionDefinition (derived from the result returned by my custom annotation parser).
My JpaDialect receives a TransactionDefinition object which does not expose the information my custom parser provides. The exact hiearchy of the passed definition (in Spring 3.1) is:Code:Object beginTransaction(EntityManager entityManager, TransactionDefinition definition) throws PersistenceException, SQLException, TransactionException;
In practice, my JpaDialect does not have access to the extra transactional information added from my parser. This because the default JpaTransactionManager hides the transaction attributes in an anonymous class.Code:org.springframework.transaction.TransactionDefinition +org.springframework.transaction.interceptor.DelegatingTransactionAttribute +my custom TransactionAnnotationParser
How could my JpaDialect get the extra information obtained by my annotation parser?
I currently user reflection in order to access private internal fields, but this is far away from being nice design...


Reply With Quote
