Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Multi tenancy with multiple datasources is not working #623

Open
leopinho opened this issue Sep 21, 2022 · 0 comments
Open

Multi tenancy with multiple datasources is not working #623

leopinho opened this issue Sep 21, 2022 · 0 comments

Comments

@leopinho
Copy link

leopinho commented Sep 21, 2022

If I add "implements MultiTenancy" to the domain class, it tries to use default datasource instead of the one defined in the datasource mapping field and then it returns a table not found error.

If I remove "implements MultiTenant" or remove the multiple databases setup, everything works fine.

class SystemTransaction implements MultiTenant<SystemTransaction> {
	static mapping = {
		 datasource 'accountTransaction'

18:51:05.0222 [http-nio-8080-exec-9] DEBUG o.s.j.d.DataSourceUtils - Fetching JDBC Connection from DataSource
18:51:05.0239 [http-nio-8080-exec-9] DEBUG o.h.e.j.s.SqlExceptionHelper - could not extract ResultSet [n/a]
java.sql.SQLSyntaxErrorException: Table 'gaming.system_transaction' doesn't exist
	at com.mysql.cj.jdbc.exceptions.SQLError.createSQLException(SQLError.java:120)
	at com.mysql.cj.jdbc.exceptions.SQLExceptionsMapping.translateException(SQLExceptionsMapping.java:122)
	at com.mysql.cj.jdbc.ClientPreparedStatement.executeInternal(ClientPreparedStatement.java:916)
	at com.mysql.cj.jdbc.ClientPreparedStatement.executeQuery(ClientPreparedStatement.java:972)
	at java.base/jdk.internal.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
	at java.base/jdk.internal.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:77)
	at java.base/jdk.internal.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43)
	at java.base/java.lang.reflect.Method.invoke(Method.java:568)
	at org.apache.tomcat.jdbc.pool.StatementFacade$StatementProxy.invoke(StatementFacade.java:118)
	at jdk.proxy2/jdk.proxy2.$Proxy153.executeQuery(Unknown Source)
	at org.hibernate.engine.jdbc.internal.ResultSetReturnImpl.extract(ResultSetReturnImpl.java:57)
	at org.hibernate.loader.Loader.getResultSet(Loader.java:2322)
	at org.hibernate.loader.Loader.executeQueryStatement(Loader.java:2075)
	at org.hibernate.loader.Loader.executeQueryStatement(Loader.java:2037)
	at org.hibernate.loader.Loader.doQuery(Loader.java:956)
	at org.hibernate.loader.Loader.doQueryAndInitializeNonLazyCollections(Loader.java:357)
	at org.hibernate.loader.Loader.doList(Loader.java:2868)
	at org.hibernate.loader.Loader.doList(Loader.java:2850)
	at org.hibernate.loader.Loader.listIgnoreQueryCache(Loader.java:2682)
	at org.hibernate.loader.Loader.list(Loader.java:2677)
	at org.hibernate.loader.criteria.CriteriaLoader.list(CriteriaLoader.java:109)
	at org.hibernate.internal.SessionImpl.list(SessionImpl.java:1917)
	at org.hibernate.internal.CriteriaImpl.list(CriteriaImpl.java:370)
	at org.grails.orm.hibernate.query.AbstractHibernateCriteriaBuilder.invokeMethod(AbstractHibernateCriteriaBuilder.java:1699)
	at org.grails.orm.hibernate.query.AbstractHibernateCriteriaBuilder.list(AbstractHibernateCriteriaBuilder.java:1570)
	at org.grails.datastore.mapping.query.api.BuildableCriteria$list$0.call(Unknown Source)

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant