I have the following EJB structure. Don\'t wonder about Animal
and Inventory
, these classes are only here to demonstrate the structure in a simplified
If you are using EclipseLink, solution is simple. Modify the Path criteria to cast to RfIdTag:
Path
If you are using Hibernate, replace your method with:
public static T fOwner(Class type, String catName) {
CriteriaBuilder criteriaBuilder = em.getCriteriaBuilder();
CriteriaQuery criteriaQuery = criteriaBuilder.createQuery(type);
Root fromType = criteriaQuery.from(type);
Root fromRfId = criteriaQuery.from(RfIdTag.class);
Path
This makes a "join" ("a filtered cartesian product") between "T" and "RfIdTag".