Hello,
I have a bit of a problem here with JPA, more specifically with the "persistence.xml" configuration file.
As I understand, each and every PersistenceUnit has to be declared in the "persistence.xml" file.
What I want is to declare 2 different Persistence units: one for production environment using a specific database and another one for testing purposes only (for this one, I'd use an in-memory Hypersonic DB).
What I would like is to have my unitTest-only-PersistenceUnit to be accessible directly in unittests (=> not in a JBoss managed environment) but I certainly DON'T want to have it even seen when deployed under JBoss.
In order to do so, my first idea would be to:
1: Declare my "production" PersistenceUnits in a file called "persistence.xml". This file would be automatically found by my application server.
2: Declare my test PersistenceUnit in another file (let's say persistence-test.xml". This file would not be seen by my appServer but could be specified manually in my J2SE unittest code (like this, for example: Persistence.createEntityManagerFactory(PERSISTENCE_XML_CONFIG_FILE_NAME, PERSISTENCE_UNIT_NAME);)
Problem is that I have to specify all the PersistenceUnits in the same single "persistence.xml" file... I can't just create 2 different persistence config files
Wouldn't it be easier for everybody if it was possible to give the name of a file playing the role of the "persistence.xml" file without forcibly being this file? That would help me a lot for my unit tests...
Don't know if that is clear enough. Anyway, thank you in advance for your responses.
Jer
|