Pregunta

Is it possible to create relationships (@OneToMany , @ManyToMany) between two entities in two different persistence units?

After following this set up http://viralpatel.net/blogs/spring-roo-two-database-configuration/ i want to see if an entity created with one persistent unit context can interact with another entity on another context.

If this isn't possible, do i just have to manage transactions on my own?

¿Fue útil?

Solución

You cant have relationships across two different contexts/databases. Some databases allow you to setup db-links. These create a virtual schema/db in the database which looks likes in the same db even though it is not. However, I have found these types of solutions to be slow and problematic.

Also, when dealing with 2 different db's, transaction management becomes more complicated. You can use the full 2 phase commit transaction management. Or you can use a custom transaction manager that works specifically on your 2 database instances.

Licenciado bajo: CC-BY-SA con atribución
No afiliado a StackOverflow
scroll top