Using EJBQL with EntityQuery jboss seam

169 Views Asked by At

I have a method that receives a lot of params and should use this in a query, EJBQL query. With normal query I can use:

public void method(Long code){
Query q = this.em.createQuery("SELECT a FROM ClassA a WHERE a.code = :code);        q.setParameter("code", code);
}

This works very well. But change this to EJBQL dont work as I expected:

public void method(Long code){
        EntityQuery<Object> eq = new EntityQuery<Object>();
        eq.setEjbql("SELECT a FROM ClassA a WHERE a.code = :code");
        //Set here the param code
        }

My EntityQuery is from: org.jboss.seam.framework

1

There are 1 best solutions below

0
Omid P On

you shouldn't new entityQuery use this

EntityManager em = (EntityManager) Expressions.instance().createValueExpression("#{entityManager}").getValue();

em.createQuery("SELECT a FROM ClassA a WHERE a.code = :code);