1

I've been having trouble getting grails 3.1.6, and jndi to work with multiple datasources I'm very close but I need to set a 'hibernate.default_schema' on one of the data sources, however it's environment specific.

resources.goovy:

    dataSource(JndiObjectFactoryBean) {
        jndiName = "java:comp/env/jdbc/blah"
    }

I've read that you can put it in a 'hibernateProperties' on the sessionFactory but I'm not sure how to add the property that I need.

How do I set the 'hibernate.default_schema' on the dataSource?

Edit: I've tried to set the schema via the application.yml but it doesn't seem to work:

someEnv: # rest of the db config setup in resources.groovy
    dataSources:
        dataSource:
            hibernate:
                default_schema: something
Lifeweaver
  • 986
  • 8
  • 29
  • There is already a hibernateProperties set on each sessionFactory bean, and the values are set from the `hibernate` block in the configuration, so you should be able to add that under `hibernate_` – Burt Beckwith Oct 24 '16 at 21:03
  • By setting `environment.development.hibernate.default_schema: blah_schema` I was able to get it to work. This solution appeared to not affect my other data sources. If you 'answer' the question I can mark it. – Lifeweaver Oct 25 '16 at 15:13
  • Cool, glad it's working (and not as involved as digging into the Spring bean definition) – Burt Beckwith Oct 25 '16 at 15:15

1 Answers1

0

There is already a hibernateProperties set on each sessionFactory bean, and the values are set from the hibernate block in the configuration, so you should be able to add that under hibernate_<yourdatasourcename>.

Burt Beckwith
  • 75,342
  • 5
  • 143
  • 156