I am trying to use the JPA 2.0's criteria query with the underlying implementation of Hibernate. I am having issues while trying to access properties of subclass in the where clause..
Following are brief description of the entities:
- Class A (which is a Entity & a Table by itself) - Class B (which is a Entity & a Table by itself) - Class A has OneToMany relationship with B - Class AB & BA are child classes of B (Both are entities but are not mapped to any tables. It holds few properties specific to it.) - Let us suppose both classes AB & BA has a property '''symbol'''
Now comes the criteria query:
CriteriaBuilder qb = futuresEntityManager.getCriteriaBuilder(); CriteriaQuery<A> query = qb.createQuery(A.class); Root<A> a = query.from(A.class); Join<A,B> b = a.joinSet("aLegs", JoinType.INNER);
Now when I form the predicates:
predicate=qb.and(qb.equal(a.get("id").get("accountId"), "1234")); predicate=qb.and(predicate,b.get("symbol").in(input.getSymbol())); ----- The above line does not work at run time as b does not hold the reference to symbol. only child classes AB & BA holds it..
How do i access the properties of child classes in this query ? I have to Include both AB & BA for the symbol predicate.
Can anybody help me to resolve this issue ?
|