[2.0-java] Hybernate filter equivalent with ebean (multi-tenancy)

360 views
Skip to first unread message

Gyorn

unread,
Apr 6, 2012, 3:47:52 PM4/6/12
to play-fr...@googlegroups.com
Hi,

We are about to build a multi tenant app, and we would like to use the hybernate filter system (http://www.lunatech-research.com/archives/2011/03/04/play-framework-writing-multitenancy-application-hibernate-filters). 
Is there some kind of equivalent with ebean ? or is it possible to make one similar ?

I couldn't find how to permanently add some "user_id = session().get('userId')" stuff on every queries, without explicitly add them in custom model method.
Is there a way to make MyModel.find.all, MyModel.find.byId always use the ByUserId filter ? Or do i have to redefine all thoses methods and explicitly add the eq() part ?

I'm not sure how to do it the right way, so any help would be much apreciated :)

But i'm not sure the solution Guillaume Bort is talking about is applicable with only one DB.

Scott Rippee

unread,
Mar 2, 2013, 2:09:09 AM3/2/13
to play-fr...@googlegroups.com
I'm hoping for something similar to hibernate filters as well for ebeans.  Any suggestions out there?

Thanks,
Scott


On Monday, December 24, 2012 6:12:52 AM UTC-8, Jorge Nuñez wrote:
Hello Gyorn, I am in the same request. What did you resolve?

Dmitry Chuiko

unread,
Mar 19, 2013, 4:12:17 AM3/19/13
to play-fr...@googlegroups.com
Hi everyone!

Any progress here? Is there any opportunity to use Ebean with some kind of filters (like it can be done in Hibernate) to support multi tenancy?

Dmitry Chuiko

unread,
Mar 19, 2013, 5:26:21 AM3/19/13
to play-fr...@googlegroups.com
I found a solution. Ebean supports something like query interceptors called BeanQueryAdapter (http://www.avaje.org/bugdetail-169.html). So just add it in your Ebean ServerConfig and add where filter to any intercepted query.


On Friday, April 6, 2012 11:47:52 PM UTC+4, Gyorn wrote:
Reply all
Reply to author
Forward
0 new messages