Play 2.3+ Multi-tenancy (Schema/DB per tenant) example
461 views
Skip to first unread message
Nicolaas Frederick Huysamen
unread,
Sep 23, 2014, 2:09:31 AM9/23/14
Reply to author
Sign in to reply to author
Forward
Sign in to forward
Delete
You do not have permission to delete messages in this group
Copy link
Report message
Show original message
Either email addresses are anonymous for this group or you need the view member email addresses permission to view the original message
to play-fr...@googlegroups.com
We are evaluating using Play for a new application, but one requirement is that we have shema (or db) per tenant multi-tenancy. Tenants are created dynamically (by creating their schema from a template). Are there any good examples of achieving this in Play? During the request we are able to figure out the tenant from the request headers, so a simple stateless approach will work great.
Thanks
Ian Rae
unread,
Sep 23, 2014, 10:42:45 AM9/23/14
Reply to author
Sign in to reply to author
Forward
Sign in to forward
Delete
You do not have permission to delete messages in this group
Copy link
Report message
Show original message
Either email addresses are anonymous for this group or you need the view member email addresses permission to view the original message
to play-fr...@googlegroups.com
Play works well with Flyway, which does schema creation (and migration) programmatically.
You do not have permission to delete messages in this group
Copy link
Report message
Show original message
Either email addresses are anonymous for this group or you need the view member email addresses permission to view the original message
to play-fr...@googlegroups.com
Not quite what I was asking about though. I am interested in knowing how (or if) Play can do multi-tenancy with db/schema per tenant from a single app.
Earle Nietzel
unread,
Sep 24, 2014, 11:45:23 AM9/24/14
Reply to author
Sign in to reply to author
Forward
Sign in to forward
Delete
You do not have permission to delete messages in this group
Copy link
Report message
Show original message
Either email addresses are anonymous for this group or you need the view member email addresses permission to view the original message
to play-fr...@googlegroups.com
Hi Nick,
Sounds like unified access to your tenant datasources is what your looking for.
You do not have permission to delete messages in this group
Copy link
Report message
Show original message
Either email addresses are anonymous for this group or you need the view member email addresses permission to view the original message
to play-fr...@googlegroups.com
There is nothing out of the box. Probably you will need to create an Action composition to decide which tenant is accessing your application and create the SessionFactory/EntityManagerFactory/WhateEverFactory based on that. Hibernate 4 has support for the schema approach. Here is the link => http://docs.jboss.org/hibernate/orm/4.2/devguide/en-US/html/ch16.html#d5e4771
You do not have permission to delete messages in this group
Copy link
Report message
Show original message
Either email addresses are anonymous for this group or you need the view member email addresses permission to view the original message
to play-framework
This is a little old post, but it may benefit other users like me.
I have put together an example on how Play + JPA (Hibernate) works to achieve multi-tenancy. It supports schema/database per tenant with the support of a common database which will have "common to all tenants" information.