grails-guides / database-per-tenant Goto Github PK
View Code? Open in Web Editor NEWA Guide to using Database-Per-Tenant Multi Tenancy with GORM 6.1
License: Apache License 2.0
A Guide to using Database-Per-Tenant Multi Tenancy with GORM 6.1
License: Apache License 2.0
Hi,
I used multitenancy descriminator in single database.
@entity
class Student implements MultiTenant {
static hasMany = [persons:Person]
static mapping = {
persons joinTable:'student_person'
}
Long tenantId
//...other properties
}
@entity
class Person implements MultiTenant {
static belongsTo =[Student]
static hasMany = [students:Student]
static mapping = {
students joinTable:'student_person'
}
Long tenantId
//other properties
}
@entity
class StudentPerson {
static constraints = {
}
Long studentId
Long personId
// String relType
}
student_person table contain student_id,person_id columns only
I got the studentInstance object from studentId
After I use "studentInstance.persons" it will throw the exception no tenant_id on student_person.tenat_id
The generated hql is adding student_person.tenant_id column in the query where condition. It will throw the exception " Unknown column 'persons0_.tenant_id' " in 'where clause' for all join tables.
The generated hql is
select
persons0_.student_id as student_3_48_0_,
persons0_.person_id as person_i4_48_0_,
person1_.id as id1_32_1_,
person1_.version as version2_32_1_,
person1_.tenant_id as tenant_i3_32_1_,
person1_.first_name as first_na4_32_1_,
...........
from
student_person persons0_
inner join
person person1_
on persons0_.person_id=person1_.id
where
? = persons0_.tenant_id
and persons0_.student_id=?
The student_person table does n't contain tenant_id in table
Thanks
Siva.
A declarative, efficient, and flexible JavaScript library for building user interfaces.
๐ Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
An Open Source Machine Learning Framework for Everyone
The Web framework for perfectionists with deadlines.
A PHP framework for web artisans
Bring data to life with SVG, Canvas and HTML. ๐๐๐
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
Some thing interesting about web. New door for the world.
A server is a program made to process requests and deliver data to clients.
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
Some thing interesting about visualization, use data art
Some thing interesting about game, make everyone happy.
We are working to build community through open source technology. NB: members must have two-factor auth.
Open source projects and samples from Microsoft.
Google โค๏ธ Open Source for everyone.
Alibaba Open Source for everyone
Data-Driven Documents codes.
China tencent open source team.