it throws the exception:
org.hibernate.hql.ast.QuerySyntaxException: Statistic is not mapped
[select s from Statistic s ]
at org.hibernate.hql.ast.util.SessionFactoryHelper.requireClassPersister(SessionFactoryHelper.java:180)
But when I run:
but when I run Statistic.all().fetch()
it works fine.
Is there there anything special I need to do to get JPA queries to
work? The Statistic model does extend a base model, and there is a
package-level filterDef applied to the base model.
> --
> You received this message because you are subscribed to the Google Groups "play-framework" group.
> To post to this group, send email to play-fr...@googlegroups.com.
> To unsubscribe from this group, send email to play-framewor...@googlegroups.com.
> For more options, visit this group at http://groups.google.com/group/play-framework?hl=en.
>
>
package models;
@Entity(name="statistics")
public class Statistic extends MTAModel{ ... }
@MappedSuperclass
@Filter(name="tenant")
public abstract class MTAModel extends AuditableModel { ... }
@MappedSuperclass
public abstract class AuditableModel extends play.db.jpa.Model { ... }
@FilterDef(name="tenant", parameters= { @ParamDef( name="tenant_id",
type="long") }, defaultCondition=" (tenant_id = :tenant_id OR
tenant_id = -1)" )
package models;
public class MultiTenant extends Controller {
@Before
public static void setFilters() {
Tenant tenant = Tenant.current();
if(tenant != null){
((Session) JPA.em().getDelegate()).enableFilter("tenant").setParameter("tenant_id",
tenant.id);
here you are changing the name of the entity so I guess your query
should go like:
"SELECT s from statistics s where ..."
if you want to change the table name you need to use @Table(name = ...)