cayenne-user mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From "Becker, Joel" <joel.bec...@essvote.com>
Subject Clone and modify DataMap - NullPointerException with SelectQuery with Expression
Date Fri, 04 Nov 2011 19:15:40 GMT
Hi, I wrote code to clone a DataMap, appending a suffix to the Entities
to avoid name collisions (in this instance I am not cloning the
relationships). After adding the cloned DataMap to the data node, I can
successfully commit transactions to the dynamically-generated tables. I
can also query for all of the objects in the tables (they are
CayenneDataObjects, since I can't generate new Java classes
dynamically).

 

However, when I create a SelectQuery given the DbEntity and an
Expression, where the expression is
ExpressionFactory.matchEquals(MaritalStatus.DESCRIPTION_PROPERTY,
"Married"), and call DataContext.performQuery(), I get a
NullPointerException here:

java.lang.NullPointerException

                at
org.apache.cayenne.access.trans.QueryAssemblerHelper.appendObjPath(Query
AssemblerHelper.java:141)

                at
org.apache.cayenne.access.trans.QualifierTranslator.objectNode(Qualifier
Translator.java:376)

                at
org.apache.cayenne.exp.Expression.traverse(Expression.java:464)

                at
org.apache.cayenne.exp.Expression.traverse(Expression.java:461)

                at
org.apache.cayenne.exp.Expression.traverse(Expression.java:441)

                at
org.apache.cayenne.access.trans.QualifierTranslator.doAppendPart(Qualifi
erTranslator.java:76)

                at
org.apache.cayenne.access.trans.QualifierTranslator.doAppendPart(Qualifi
erTranslator.java:65)

                at
org.apache.cayenne.access.trans.QueryAssemblerHelper.appendPart(QueryAss
emblerHelper.java:83)

                at
org.apache.cayenne.access.trans.SelectTranslator.createSqlString(SelectT
ranslator.java:130)

                at
org.apache.cayenne.access.trans.QueryAssembler.createStatement(QueryAsse
mbler.java:194)

                at
org.apache.cayenne.access.jdbc.SelectAction.performAction(SelectAction.j
ava:70)

                at
org.apache.cayenne.access.DataNodeQueryAction.runQuery(DataNodeQueryActi
on.java:87)

                at
org.apache.cayenne.access.DataNode.performQueries(DataNode.java:269)

                at
org.apache.cayenne.access.DataDomainQueryAction.runQuery(DataDomainQuery
Action.java:422)

                at
org.apache.cayenne.access.DataDomainQueryAction.access$000(DataDomainQue
ryAction.java:69)

                at
org.apache.cayenne.access.DataDomainQueryAction$2.transform(DataDomainQu
eryAction.java:395)

                at
org.apache.cayenne.access.DataDomain.runInTransaction(DataDomain.java:85
0)

                at
org.apache.cayenne.access.DataDomainQueryAction.runQueryInTransaction(Da
taDomainQueryAction.java:392)

                at
org.apache.cayenne.access.DataDomainQueryAction.execute(DataDomainQueryA
ction.java:121)

                at
org.apache.cayenne.access.DataDomain.onQuery(DataDomain.java:743)

                at
org.apache.cayenne.util.ObjectContextQueryAction.runQuery(ObjectContextQ
ueryAction.java:333)

                at
org.apache.cayenne.util.ObjectContextQueryAction.execute(ObjectContextQu
eryAction.java:96)

                at
org.apache.cayenne.access.DataContext.onQuery(DataContext.java:1278)

                at
org.apache.cayenne.access.DataContext.performQuery(DataContext.java:1267
)

 

At the QueryAssemblerHelper.appendObjPath() line:

        for (PathComponent<ObjAttribute, ObjRelationship> component :
getObjEntity()

 

because getObjEntity() returns null because the query's classDescriptor
is null.

 

When I clone the DataMap, do I need to create a ClassDescriptor for each
ObjEntity? If so, is that possible for dynamic ObjEntity's which don't
have a real corresponding Java class?

 

Thanks,

Joel

 


Mime
  • Unnamed multipart/alternative (inline, None, 0 bytes)
View raw message