Hello, Currently I'm developing an application that needs to access more than one database. It has objects persisted in two databases.
I'm using Spring + JPA + Struts. I've added to the applicationContext.xml a new datasource, new persistence unit manager and a new entity manager factory. My idea was to extend GenericDaoJpa and inject a new entity manager overriding method 'setEntityManager'. public class GenericDaoJpa <T, PK extends Serializable> implements GenericDao<T, PK> { ............ @PersistenceContext(unitName="ApplicationEntityManager") public void setEntityManager(EntityManager entityManager) { this.entityManager = entityManager; } ........... } public class OtherGenericDaoJpa extends GenericDaoJpa { @Override @PersistenceContext(unitName="otherunitname") public void setEntityManager(EntityManager entityManager) { super.setEntityManager(entityManager); } } I'm using PersistenceAnnotationBeanPostProcessor to inject this dependencies. The things is that this class inpects the first class, OtherGenericDaoJpa, and gets the annotation. Then, it inpects the parent class, GenericDaoJpa, and gets the other annotation. After this, it injects the dependencies, first with OtherGenericDaoJpa and then with GenericDaoJpa, setting at the end the 'ApplicationEntityManager' entity manager instead of the new one. I don't know if I'm choosing the wrong way to get what I want of if there is a limitation in the PersistenceAnnotationBeanPostProcessor. From my reduced point of view the processor should not take into account methods of parent classes if they are override by another child class or maybe it should inject dependencies in reverse order (from parent to childs). How can I solve this? Should I change the PersistenceAnnotationBeanPostProcessor or is there any other way? Thanks, Jorge -- View this message in context: http://www.nabble.com/GenericDao---JPA-overriding-PersitenceContext-annotation-tf4191976s2369.html#a11921214 Sent from the AppFuse - User mailing list archive at Nabble.com. --------------------------------------------------------------------- To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED]