|
Hi all,
I am working on a rewrite of an application I have been working on for a while. Now I would like to add the multi tenant single db plugin. I have a couple of questions about the plugin though:
1. When I look at the mySQL database tables, the tenantId column is a int(11) and not a bigint(20) which the ID columns are. Shouldn't the tenantId column also be a bigint(20)? 2. The @MultiTenant annotation adds the tenantId column, I would also like to have a 2 way relationship to the Tenant class. I have tried to implement this with normal relationships, but I get:
Non-existent mapping property [tenant] specified for property [people] in class [class Client] So is there any way to implement this? Regards, Andréas Upplandsgatan 93 . 113 44 . Stockholm . Sweden [hidden email] |
|
2012/8/8 Andréas Kühne <[hidden email]>
Yeah, you're right.
The tenantId is added in runtime, probably after grails try to map it.
IMHO, Tenant relationship should be transparent and you shouldn't manipulate it. But you probably could do this mapping directly the column. static mapping = { customer column: "tenant_id"
} I haven't tested it, but you can try. []s,
|
|
Hi,
Thanks for the answer. I solved my problem by adding getters instead of using relationships. I am still a bit confused about why the tenant plugin uses Integers to store the tenantId column... Anyone know why?
// Andréas
2012/8/13 Lucas F. A. Teixeira <[hidden email]>
vänliga hälsningar, Andréas Upplandsgatan 93 . 113 44 . Stockholm Mobil 076 543 8825 [hidden email] |
|
I think (guess) that Integer was chosen to represent tenant id because 2,147,483,647 is probably enough tenants for most systems (last famous words..?). I saw no reason to change it when I was working on the multi-tenant-single-db plugin.
The multi-tenant architecture (at least the one I had in mind when working on the plugin) works best for systems where the tenants doesn't interact / know about each other. Think of it as running the same application for multiple customers in one JVM process. Joshua Burnett started a new branch[1] working on making the tenant column more configurable. Feel free to work on more configuration options for the AST transformation responsible for adding the tenantId field. [1] https://github.com/multi-tenant/grails-multi-tenant-single-db/commits/tenantid_config
- Kim A. Betti
Have a nice day! |
|
Hi,
I agree that 2,147,483,647 is really enough for anyone. The reason I questioned it was that the ID column is a Long and I think that the tenantId should be the same so that relationships are safe. I also agree that tenants should not communicate with oneanother, and that is the reason I need the plugin. What I would like to have is a relationship between the multitenant classes and the tenant class.
In my case the tenant class is called Client. It has a number of users connected to it. I would like to be able to do client.users and get a list of users associated to that class. This is for the administrators of the system who should be able to see all clients and all users. I know that a way of doing this would be to have an administration application and the main application is completely void of all code that has administration. But I would like to have all of the code in one app.
I have found a solution, by manually creating the links, but I was mainly wondering if it was possible to do it automatically. // Andréas
2012/8/15 Kimble <[hidden email]> I think (guess) that Integer was chosen to represent tenant id because vänliga hälsningar, Andréas Upplandsgatan 93 . 113 44 . Stockholm Mobil 076 543 8825 [hidden email] |
|
I see, administration problems and concerns has been discussed a couple of time already.
Personally I would just do a "query users by client / tenant id" and not bother with the Hibernate relationship. They tend to cause at least the same amount of trouble as they solve anyway :-)
- Kim A. Betti
Have a nice day! |
|
Yes,
That's exactly how I solved it as well. // Andréas
2012/8/16 Kimble <[hidden email]> I see, administration problems and concerns has been discussed a couple of vänliga hälsningar, Andréas Upplandsgatan 93 . 113 44 . Stockholm Mobil 076 543 8825 [hidden email] |
| Powered by Nabble | Edit this page |
