Creating applications that interact with multiple databases
As of Spring Roo 1.1.3, both entity
and persistence
setup
commands support the persistenceUnit
argument which lets you create enterprise applications which interact with multiple databases. In this recipe we'll create two persistent units:
flight
: theflight
persistence unit consists of a single entity,Flight
. It uses Hibernate as a JPA provider and maps to a MySQL database named "myFlightDB".payment
: thepayment
persistence unit consists of a single entity,Payment
. It uses Hibernate as the JPA provider and maps to a MySQL database named "myPaymentDB".
Getting ready
Exit the Roo shell and delete the contents of the C:\roo-cookbook\ch02-recipes
directory.
Start the Roo shell from the C:\roo-cookbook\ch02-recipes
directory.
How to do it...
The following steps will demonstrate how to create an application that interacts with multiple databases:
Create the
flight-app
Roo project:..roo> project --topLevelPackage sample.roo.flightapp...