GithubHelp home page GithubHelp logo

grails-guides / database-per-tenant Goto Github PK

View Code? Open in Web Editor NEW
3.0 3.0 5.0 667 KB

A Guide to using Database-Per-Tenant Multi Tenancy with GORM 6.1

License: Apache License 2.0

JavaScript 0.88% CSS 47.12% Groovy 41.98% Shell 6.82% Batchfile 3.20%

database-per-tenant's People

Contributors

benrhine avatar graemerocher avatar ilmoralito avatar ilopmar avatar sdelamo avatar

Stargazers

 avatar  avatar  avatar

Watchers

 avatar  avatar  avatar  avatar  avatar

database-per-tenant's Issues

Why tenant_id is automatically added to join table hql query when I use student.persons

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.

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.