You are viewing a plain text version of this content. The canonical link for it is here.
Posted to dev@cayenne.apache.org by Tore Halset <ha...@pvv.ntnu.no> on 2007/10/29 09:23:06 UTC
query from modeler trouble
Hello.
I am trying to issue a query from the modeler to the projects DataMap
and a selected DataSource. I am stumbling and need some help..
Here is my current problematic stack trace from issuing a *data rows*
SelectQuery on an entity called "MyEntity".
Caused by: java.lang.ClassNotFoundException: myapp.data.MyEntity
at java.lang.Class.forName(Class.java:242)
at org.apache.cayenne.util.Util.getJavaClass(Util.java:570)
at org.apache.cayenne.map.ObjEntity.getJavaClass(ObjEntity.java:256)
at
org.apache.cayenne.reflect.PersistentDescriptorFactory.getDescriptor
(PersistentDescriptorFactory.java:50)
at org.apache.cayenne.reflect.ClassDescriptorMap.createDescriptor
(ClassDescriptorMap.java:128)
at
org.apache.cayenne.reflect.LazyClassDescriptorDecorator.checkDescriptorI
nitialized(LazyClassDescriptorDecorator.java:49)
at org.apache.cayenne.reflect.LazyClassDescriptorDecorator.getEntity
(LazyClassDescriptorDecorator.java:73)
at
org.apache.cayenne.access.trans.SelectTranslator.appendQueryColumns
(SelectTranslator.java:357)
at
org.apache.cayenne.access.trans.SelectTranslator.buildResultColumns
(SelectTranslator.java:332)
at org.apache.cayenne.access.trans.SelectTranslator.createSqlString
(SelectTranslator.java:107)
at
org.apache.cayenne.dba.postgres.PostgresSelectTranslator.createSqlString
(PostgresSelectTranslator.java:31)
at org.apache.cayenne.access.trans.QueryAssembler.createStatement
(QueryAssembler.java:95)
at org.apache.cayenne.access.jdbc.SelectAction.performAction
(SelectAction.java:71)
at org.apache.cayenne.access.DataNodeQueryAction.runQuery
(DataNodeQueryAction.java:57)
at org.apache.cayenne.access.DataNode.performQueries(DataNode.java:236)
So the problem is that myapp.data.MyEntity does not exist. Is there
some smart trick to duplicate the model and make all ObjEntities
generic? Or perhaps generate and load the classes in a disposable
client class loader?
Regards,
- Tore.
Re: query from modeler trouble
Posted by Andrus Adamchik <an...@objectstyle.org>.
I'd say clone a DataMap (e.g. via XML, although
Util.cloneViaSerialization() would likely also work). And then
replace Java class for all cloned entities to be CayenneDataObject.
This should be MUCH less painful than creating real Java classes on
the fly.
Andrus
On Oct 29, 2007, at 10:23 AM, Tore Halset wrote:
> Hello.
>
> I am trying to issue a query from the modeler to the projects
> DataMap and a selected DataSource. I am stumbling and need some help..
>
> Here is my current problematic stack trace from issuing a *data
> rows* SelectQuery on an entity called "MyEntity".
>
> Caused by: java.lang.ClassNotFoundException: myapp.data.MyEntity
> at java.lang.Class.forName(Class.java:242)
> at org.apache.cayenne.util.Util.getJavaClass(Util.java:570)
> at org.apache.cayenne.map.ObjEntity.getJavaClass(ObjEntity.java:256)
> at
> org.apache.cayenne.reflect.PersistentDescriptorFactory.getDescriptor
> (PersistentDescriptorFactory.java:50)
> at org.apache.cayenne.reflect.ClassDescriptorMap.createDescriptor
> (ClassDescriptorMap.java:128)
> at
> org.apache.cayenne.reflect.LazyClassDescriptorDecorator.checkDescripto
> rInitialized(LazyClassDescriptorDecorator.java:49)
> at
> org.apache.cayenne.reflect.LazyClassDescriptorDecorator.getEntity
> (LazyClassDescriptorDecorator.java:73)
> at
> org.apache.cayenne.access.trans.SelectTranslator.appendQueryColumns
> (SelectTranslator.java:357)
> at
> org.apache.cayenne.access.trans.SelectTranslator.buildResultColumns
> (SelectTranslator.java:332)
> at org.apache.cayenne.access.trans.SelectTranslator.createSqlString
> (SelectTranslator.java:107)
> at
> org.apache.cayenne.dba.postgres.PostgresSelectTranslator.createSqlStri
> ng(PostgresSelectTranslator.java:31)
> at org.apache.cayenne.access.trans.QueryAssembler.createStatement
> (QueryAssembler.java:95)
> at org.apache.cayenne.access.jdbc.SelectAction.performAction
> (SelectAction.java:71)
> at org.apache.cayenne.access.DataNodeQueryAction.runQuery
> (DataNodeQueryAction.java:57)
> at org.apache.cayenne.access.DataNode.performQueries(DataNode.java:
> 236)
>
> So the problem is that myapp.data.MyEntity does not exist. Is there
> some smart trick to duplicate the model and make all ObjEntities
> generic? Or perhaps generate and load the classes in a disposable
> client class loader?
>
> Regards,
> - Tore.
>