How's that for a subject. So I am working on a new project where we are using JPA/Hibernate and Spring for transactional service junk and using JpaDaoSupport.
I want to completely decouple the database generation from the server startup process so I am using the Ant hibernatetool task like so:
I have a Data Source defined in Spring using c3p0 but because the Ant task doesn't know about Spring I also have redundant info in the persistence.xml file. Is there a way to
a) tell the ant task to use a spring defined database (probably not would be my guess)
b) tell Spring to use the data source defined in the persistence.xml file
If the answer is possible with (b) then I have another question...
b.1) Is there a way to tell the persistence.xml file to use a properties file with the connection info rather than putting it directly in the xml file and if so (yes, another question) can you pull in an environment variable to use for the path?
For example, right now I am doing this in the applicationContext.xml file like so:
where environment is an environment variable set when the server starts.
Originally posted by Gregg Bolinger: b.1) Is there a way to tell the persistence.xml file to use a properties file with the connection info rather than putting it directly in the xml file
Don't know the answers to other questions (haven't used Spring), but for this one you need not specify the connection properties in the persistence.xml. Instead you could point the persistence.xml to a datasource bound to JNDI:
The creation of the datasource and binding it to JNDI itself would be a separate task (which i think you are already doing through your Spring configuration files).
Update: I just re-read the question. My answer probably doesn't make any sense if you are going for option b, since you are trying to define the datasource through the persistence.xml [ October 26, 2008: Message edited by: Jaikiran Pai ]
Yea, thanks. I'm not defining the data source via jndi so it doesn't help too much. I'd like to keep the definition in one place though so maybe I need to look into that option. The question still remains though, if I were to define the data source in the persistence.xml (via jndi or whatever) how does Spring know to use that as well without redundant info in both files?