0

Using Griffon 1.2 and JPA is there any way to configure the persistence.xml with environmental properties - so I can have a different jdbc.url for dev/test/prod ?

i.e. conf/metainf/persistence.xml

 <property name="javax.persistence.jdbc.url"      value="${javax.persistence.jdbc.url}" />

I was hoping something like this would work in JpaConfig.groovy

environments {
    development {
        persistenceUnit {
            entityManager {
                // EntityManager properties go here
                javax.persistence.jdbc.url = 'jdbc:h2:mem:sample'
            }
        }
    }...

I could create multiple duplicate persistence xml files and I believe I can specify the active persistence unit in JpaConfig.groovy. Or is there some other way to parameterize the JPA configuration per environment?

Thanks

prule
  • 2,536
  • 31
  • 32

1 Answers1

0

I'm afraid parameterizable persistence.xml files are not supported at the moment because those files are never touched by the plugin; however this would be a nice addition to the plugin. Would you care to register a ticket at http://jira.codehaus.org/browse/griffon ?

In the meantime, setting all relevant properties in JpaConfig.groovy is the only way to achieve this.

Andres Almiray
  • 3,236
  • 18
  • 28
  • Sorry, could you explain how I can use JpaConfig to do this? I couldn't get it working by specifying the url in JpaConfig. – prule Mar 23 '13 at 04:07
  • I believe you must surround with quotes any compound keys, that is, "javax.persistence.jdbc.url" = 'jdbc:h2:mem:sample' – Andres Almiray Mar 24 '13 at 09:26