0

我正在执行一个看起来有点复杂的 JDOQL 查询:

Query q = pm.newQuery(IxlTest.class, "id == :tId && parameterGroups.get(oGroup.key).contains(tp) && oGroup.contains(opt) && opt.displayInResults");
q.setResult("oGroup, opt");
vars.append(TestTypeOptionsGroup.class.getName() + " oGroup;");
vars.append(TestTypeOption.class.getName() + " opt;");
vars.append(TestParameterGroup.class.getName() + " tpGroup;");
vars.append(TestParameter.class.getName() + " tp;");
q.declareVariables(vars.toString());
System.out.println(q.execute(testId));

我没有理由认为 DN 需要那个Geometry课程,因为我的课程与几何无关。这是parameterGroups映射IxlTest

@Persistent(defaultFetchGroup = "true", table = "ixl_test_parameter_groups_rel")
@Join(column = "test_fk", extensions = { @Extension(vendorName = "datanucleus", key = "primary-key", value = "false") })
@Key(types = { String.class }, column = "test_parameter_group_key", mappedBy = "name", dependent = "true")
@Value(types = { TestParameterGroup.class }, column = "test_parameter_group_fk", dependent = "true")
private Map<String, TestParameterGroup> parameterGroups;

这些是TestParameterGroup字段

@Persistent(primaryKey = "true", valueStrategy = IdGeneratorStrategy.IDENTITY)
private long id;
private String name;
private String key;
private boolean active;
@Column(name = "script_substitute")
private boolean scriptSubstitute;
@Column(name = "substitute_all")
private boolean substituteAll;
@Column(name = "script_value_when_checked")
private String scriptValueWhenChecked;
@Column(name = "script_value_when_unchecked")
private String scriptValueWhenUnChecked;
@Persistent(defaultFetchGroup = "true")
@Key(types = { String.class }, mappedBy = "key", dependent = "true")
@Value(types = { TestParameter.class }, column = "parameters_group_id", dependent = "true")
private Map<String, TestParameter> parameters;

这些是TestParameter字段

@Persistent(primaryKey = "true", valueStrategy = IdGeneratorStrategy.IDENTITY)
private long id;
private String key;
private String value;
private boolean active;
@Column(name = "script_substitute")
private boolean scriptSubstitute;
@Column(name = "substitute_all")
private boolean substituteAll;

我仍在构建我的查询,但为了确保没有任何问题,我尝试在完成整个查询之前运行它,但我得到了这个异常:

javax.jdo.JDOException: Class "com.vividsolutions.jts.geom.Geometry" was not found in the CLASSPATH. Please check your specification and your CLASSPATH.
    at org.datanucleus.api.jdo.NucleusJDOHelper.getJDOExceptionForNucleusException(NucleusJDOHelper.java:570)
    at org.datanucleus.api.jdo.JDOQuery.execute(JDOQuery.java:252)

Class "com.vividsolutions.jts.geom.Geometry" was not found in the CLASSPATH. Please check your specification and your CLASSPATH.
org.datanucleus.exceptions.ClassNotResolvedException: Class "com.vividsolutions.jts.geom.Geometry" was not found in the CLASSPATH. Please check your specification and your CLASSPATH.
    at org.datanucleus.JDOClassLoaderResolver.classForName(JDOClassLoaderResolver.java:245)
    at org.datanucleus.JDOClassLoaderResolver.classForName(JDOClassLoaderResolver.java:410)
    at org.datanucleus.store.rdbms.sql.expression.SQLExpressionFactory.invokeMethod(SQLExpressionFactory.java:382)
    at org.datanucleus.store.rdbms.sql.expression.ObjectExpression.invoke(ObjectExpression.java:783)
    at org.datanucleus.store.rdbms.query.QueryToSQLMapper.processInvokeExpression(QueryToSQLMapper.java:2871)
    at org.datanucleus.query.evaluator.AbstractExpressionEvaluator.compilePrimaryExpression(AbstractExpressionEvaluator.java:200)
    at org.datanucleus.query.evaluator.AbstractExpressionEvaluator.compileUnaryExpression(AbstractExpressionEvaluator.java:169)
    at org.datanucleus.query.evaluator.AbstractExpressionEvaluator.compileAdditiveMultiplicativeExpression(AbstractExpressionEvaluator.java:148)
    at org.datanucleus.query.evaluator.AbstractExpressionEvaluator.compileRelationalExpression(AbstractExpressionEvaluator.java:123)
    at org.datanucleus.query.evaluator.AbstractExpressionEvaluator.compileOrAndExpression(AbstractExpressionEvaluator.java:65)
    at org.datanucleus.query.evaluator.AbstractExpressionEvaluator.evaluate(AbstractExpressionEvaluator.java:46)
    at org.datanucleus.query.expression.Expression.evaluate(Expression.java:337)
    at org.datanucleus.query.expression.DyadicExpression.evaluate(DyadicExpression.java:70)
    at org.datanucleus.query.expression.DyadicExpression.evaluate(DyadicExpression.java:67)
    at org.datanucleus.query.expression.DyadicExpression.evaluate(DyadicExpression.java:67)
    at org.datanucleus.store.rdbms.query.QueryToSQLMapper.compileFilter(QueryToSQLMapper.java:461)
    at org.datanucleus.store.rdbms.query.QueryToSQLMapper.compile(QueryToSQLMapper.java:381)
    at org.datanucleus.store.rdbms.query.JDOQLQuery.compileQueryFull(JDOQLQuery.java:883)
    at org.datanucleus.store.rdbms.query.JDOQLQuery.compileInternal(JDOQLQuery.java:343)
    at org.datanucleus.store.query.Query.executeQuery(Query.java:1747)
    at org.datanucleus.store.query.Query.executeWithArray(Query.java:1666)
    at org.datanucleus.api.jdo.JDOQuery.execute(JDOQuery.java:243)

为什么 DN 认为我需要任何基于地理的课程?

4

1 回答 1

1

查询很奇怪(恕我直言)。你有

parameterGroups.get(oGroup.key).contains(tp)

然而“parameterGroups”是一个地图,所以“parameterGroups.get(...)”是一个TestParameterGroup。因此,“TestParameterGroup.contains”试图做什么。或者“oGroup.contains(...)”也为此。

如果您将该类抛出异常,那么您可以引用它,或者在类路径中包含各种随机 jar,例如“datanucleus-spatial”。

于 2013-03-05T11:36:05.947 回答