我正在尝试创建一个 where 子句,该子句检查是否存储在列中的值(在“Q”类中标识为
public final DateTimePath<java.sql.Timestamp> startDate = createDateTime("StartDate", java.sql.Timestamp.class);
) 大于或等于提供的值。
该值以 long 形式提供,但(自然)我可以在检查之前创建任何必要的数据类型。
我尝试了以下方法:
{
....
final QViewVETFullList fullList = QViewVETFullList.viewVETFullList;
....
final String startDate = "28.05.2012"; // test data
final BooleanExpression startDateExp = getDateGTEExpression(fullList.startDate, startDate);
.....
query = query.from(fullList);
query = query.where(startDateExp); // this is where it falls over
...
}
public static BooleanExpression getDateGTEExpression(
DateTimePath<Timestamp> path, String dateStr) {
// this seems to be the problem??
final DateTimePath<Timestamp> datePath = Expressions.dateTimePath(
java.sql.Timestamp.class, dateStr);
// this syntax works successfully with other data types
return BooleanOperation.create(Ops.GOE, path, datePath );
}
代码编译并运行到添加“where”子句的位置。然后它会因以下内容而崩溃:
....
Caused by: java.lang.IllegalArgumentException: Undeclared path 28.05.2012
at com.mysema.query.types.ValidatingVisitor.visit(ValidatingVisitor.java:48)
at com.mysema.query.types.ValidatingVisitor.visit(ValidatingVisitor.java:10)
at com.mysema.query.types.path.DateTimePath.accept(DateTimePath.java:46)
at com.mysema.query.types.ValidatingVisitor.visit(ValidatingVisitor.java:101)
at com.mysema.query.types.ValidatingVisitor.visit(ValidatingVisitor.java:36)
at com.mysema.query.types.ValidatingVisitor.visit(ValidatingVisitor.java:10)
at com.mysema.query.types.expr.BooleanOperation.accept(BooleanOperation.java:44)
at com.mysema.query.DefaultQueryMetadata.validate(DefaultQueryMetadata.java:296)
at com.mysema.query.DefaultQueryMetadata.addWhere(DefaultQueryMetadata.java:138)
at com.mysema.query.support.QueryMixin.where(QueryMixin.java:375)
at com.mysema.query.support.QueryBase.where(QueryBase.java:44)
at com.***.***.***.***.***DAOBean.get*****(***tDAOBean.java:185)
如果您对此事有任何想法,我将不胜感激。