Hey all,
We're developing a multi-tenant application using using a single
database/ schema. To distinguish the data between each tenant we are
using hibernate filters that are applied @before each request in play
(then applying it manually for jobs etc.). There is a good, recent
tutorial that I've found <a href="
http://www.lunatech-research.com/
archives/2011/03/04/play-framework-writing-multitenancy-application-
hibernate-filters">here</a>.
The filter appears to work find however it is not being applied to
findById in the models.
For example:
(the id is from another tenant and therefore should be filtered).
MyModel model1 = MyModel.findById(id);
MyModel model2 = MyModel.find("id = ?", id).first();
model1 returns the model associated with the id however model2 does
not (returns null). model2 is the correct behavior as this model is
from another tenant.
In play.db.jpa.JPQL.class, all of the find methods use createQuery
except findById - which itself uses EntityManager.find.
So it appears that the hibernate filter is only applied to createQuery
and not find. Is this the correct behavior or might I have some
configuration problem?
Thanks