Grails has a multi-tenancy plugin for a single database and a multi-tenancy plugin for multi-databases, but the one for multi-databases is no longer supported/maintained. Is there some way I can instead use Spring or Hibernate themselves for a multi-tenancy multi-database Grails application?
相关问题
- java.lang.IllegalArgumentException: Cannot set to
- Spring Data MongoDB - lazy access to some fields
- Declaring an explict object dependency in Spring
- Decoding body parameters with Spring
- Spring Integration - Inbound file endpoint. How to
相关文章
- java JDK动态代理和cglib动态代理最后获取的代理对象都为null的问题
- org.xml.sax.SAXParseException; lineNumber: 7; colu
- SpringMVC如何把File封装到Map中?
- Hibernate Tutorial - Where to put Mapping File?
- Spring: controller inheritance using @Controller a
- How to load @Configuration classes from separate J
- Java spring framework - how to set content type?
- Hibernate doesn't generate cascade
In our case we use LocalContainerEntityManagerFactoryBean where we create a multiTenantMySQLProvider.
And here the implementation of the MySQLMultiTenantConnectionProviderImpl
}
You can use Hibernate multitenancy described here http://docs.jboss.org/hibernate/orm/4.3/devguide/en-US/html/ch16.html
OR
You can also consider Spring's AbstractRoutingDataSource
https://spring.io/blog/2007/01/23/dynamic-datasource-routing/
You can find a newer post, giving an exemplary use with hibernate, the gist of the solution you can find in the following two snippets
the return value will be used as a discriminator for a datasource, the following configuration sets the mapping
This is how I use hibernate multitenancy with SCHEMA approach. May be it will be helpful for you.
applicationContext.xml
MyAppMultiTenantConnectionProvider.java
MyAppTenantIdentifierResolver.java