[2.2.3 JAVA] Can I really achieve Multitenancy using Spring 3/Hiberante 4/Postgres 9.2

302 views
Skip to first unread message

Mukul Sharma

unread,
May 20, 2014, 1:44:59 AM5/20/14
to play-fr...@googlegroups.com
Hello, 
I am quite new to Play and trying to achieve multi-tenancy using Spring and Hibernate. My need is to have a shared application with tenant specific DB Schemas. 
I started with https://github.com/vtajzich/spring-hibernate4-multitenant ( multi-tenancy with spring and hibernate) and https://github.com/jamesward/play-java-spring (setting up play app with spring), 
and have them up and running. Following them, I have created my quick sample play app with spring and hibernate at https://github.com/mukulobject/play-spring-hibernate-multitenancy.

Is it possible to configure hibernate sessionFactory with Play ? I have tried and could have it initialized after little hunch, though I am not sure if I am doing it right. 
If not, is it really possible to have multi-tenancy implemented with spring and hibernate. Any help would be greatly appreciated.

Thanks and Regards
Mukul

sachin walia

unread,
May 20, 2014, 3:01:48 PM5/20/14
to play-fr...@googlegroups.com
Default Play DB plugin supports multiple databases. If you are planning to use Spring with Play (which probably would be best if you are using Hibernate) then nothing is stopping you to use the same configuration that you have defined in your Spring application context. Make sure you import the right Spring dependencies.

See the configuration for multiple datasources here:

Mukul Sharma

unread,
May 21, 2014, 1:33:01 PM5/21/14
to play-fr...@googlegroups.com
Thanks Sachin, 
I could get it working with the exception I am not able to apply org.springframework.orm.hibernate4.support.OpenSessionInViewFilter. 
I looked into Play Filter module and realized I can make use of Play specific filters ( please correct me if I am wrong) but external Filters. Is there a way I can apply org.springframework.orm.hibernate4.support.OpenSessionInViewFilter to my requests?

Thanks and Regards

Mukul Sharma

unread,
May 23, 2014, 2:03:43 PM5/23/14
to play-fr...@googlegroups.com
Hi Play'ers, 
Would appreciate if someone can review and provide me with comments.

Regards
Mukul
Reply all
Reply to author
Forward
0 new messages