0

I'm performing a JDOQL query that could look a bit complex:

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));

There is no reason that I can think of that DN would need that Geometry class, as my classes have nothing to do with geometry. This is parameterGroups mapping in 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;

These are TestParameterGroup fields

@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;

These are TestParameter fields

@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;

I'm still building up my query but just to make sure nothing is wrong, I tried running it before completing the whole query and I got this exception:

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)

Why is DN thinking that I need any geo-based class ?

Muhammad Gelbana
  • 3,890
  • 3
  • 43
  • 81
  • 1
    How would anyone know based on your post? You don't post the CLASSPATH (like the message implies you look at), or the classes, so nobody knows what types those fields are ... – Neil Stockton Mar 05 '13 at 08:27
  • @NeilStockton, the reason I didn't add any object graphs is because it's the first time I have heard of that class and i'm pretty sure I'm not using it anywhere. I apologize for that, I have some object graph presented in my question now. Thank you. – Muhammad Gelbana Mar 05 '13 at 10:40

1 Answers1

1

The query is simply weird (IMHO). You have

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

yet "parameterGroups" is a Map, so "parameterGroups.get(...)" is a TestParameterGroup. Consequently what is "TestParameterGroup.contains" trying to do. Or "oGroup.contains(...)" also for that matter.

If you have that class being thrown in an exception then you either reference it, or you include all sorts of random jars in the classpath, such as "datanucleus-spatial" for example.

Neil Stockton
  • 11,383
  • 3
  • 34
  • 29
  • Well yes I included all DN's RDBMS libs and deps which included spatial and jpa. I'm not sure if I don't need anything else but I removed those 2. For the strange query, it's a complicated query I'm trying to achieve, to be honest. TestTypeOptionsGroup (i.e. oGroup) is an object that `TestParameterGroup` use, to behave as expected, so I need to lookup `TestParameterGroup`s with the same key of a `TestTypeOptionsGroup` while the `TestTypeOptionsGroup` has a parameter with a specific boolean set to true, then, get the `TestParameter` with the same `TestTypeOptions`'s key !!, thanks any way :) – Muhammad Gelbana Mar 05 '13 at 13:40
  • I solved another similar query by simply reordering it's conditions. I guess that's the problem; conditions order ! If conditions order matter, would that be explained somewhere ? – Muhammad Gelbana Mar 07 '13 at 12:53