I have entity with joined inheritance subclass vis
@QueryEntity
@Entity(name = "Bore")
...
@Inheritance(strategy = InheritanceType.JOINED)
@DiscriminatorColumn(name = "TYPE_ID", discriminatorType = DiscriminatorType.INTEGER)
public class Bore implements Serializable {
...
Long id;
String operator;
.... ( a very long list)
and subclass
@QueryEntity
@Entity(name = "WaterBore")
...
public class WaterBore extends Bore{
..
String drawer;
All goes well when I query based on fields that are only in the Bore. (eg operator like '*Jones*'. I have been trying to create a query to hand fields in Water (say drawer like '*FRED*')
This code is fine for queries on id or operator or other items only in the Bore object
EntityManager em = emf.createEntityManager();
JPAQuery query = new JPAQuery(em);
QBore bore = QBore.bore;
BorePredicateBuilder<Bore> bpb = new BorePredicateBuilder("bore");
bpb.parseCriteria(criteria); // this is builder which parses a complex definition from a form-based query builder into a BooleanExpression
Predicate wc = bpb.build();
List<BoreProjection> bhl;
bhl = query.from(bore).where(wc).list(new QBoreProjection(
bore.id,bore.operator));
}
This code dont not.
EntityManager em = emf.createEntityManager();
JPAQuery query = new JPAQuery(em);
QWaterBore bore = QWaterBore.bore;
BorePredicateBuilder<WaterBore> bpb = new BorePredicateBuilder("bore");
bpb.parseCriteria(criteria);
Predicate wc = bpb.build();
List<BoreProjection> bhl;
bhl = query.from(bore).where(wc).list(new QBoreProjection(
bore.id,bore.operator));
}
wc looks like containIc(boreHole,FRED)
The stack trace is
.IllegalArgumentException: Undeclared path 'bore'. Add this path as a source to the query to be able to reference it.] with root cause
java.lang.IllegalArgumentException: Undeclared path 'bore'. Add this path as a source to the query to be able to reference it.
at com.mysema.query.types.ValidatingVisitor.visit(ValidatingVisitor.java:78)
at com.mysema.query.types.ValidatingVisitor.visit(ValidatingVisitor.java:30)
at com.mysema.query.types.PathImpl.accept(PathImpl.java:94)
at com.mysema.query.types.ValidatingVisitor.visit(ValidatingVisitor.java:65)
at com.mysema.query.types.ValidatingVisitor.visit(ValidatingVisitor.java:30)
at com.mysema.query.types.OperationImpl.accept(OperationImpl.java:90)
at com.mysema.query.DefaultQueryMetadata.validate(DefaultQueryMetadata.java:351)
at com.mysema.query.DefaultQueryMetadata.addWhere(DefaultQueryMetadata.java:193)
at com.mysema.query.support.QueryMixin.where(QueryMixin.java:420)
at com.mysema.query.support.QueryBase.where(QueryBase.java:119)