You are viewing a plain text version of this content. The canonical link for it is here.
Posted to user@cayenne.apache.org by 刘波 <10...@qq.com> on 2018/07/22 15:46:06 UTC
CayenneDataObject is likely not mapped
ServerRuntime cayenneRuntime = ServerRuntime.builder()
.addConfig("cayenne-project.xml")
.build();
ObjectContext context = cayenneRuntime.newContext();
DataObject person = new CayenneDataObject();
person.setObjectId(new ObjectId("Person"));
context.registerNewObject(person);
String name = (String) person.readProperty("name");
Exception in thread "main" java.lang.IllegalArgumentException: Can't find ObjEntity for Persistent class: org.apache.cayenne.CayenneDataObject, class is likely not mapped.
at org.apache.cayenne.access.DataContext.registerNewObject(DataContext.java:536)
Person is a table in mysql, we aren't map it in xml, we want use it in fly, we don't define a deEntity for the table, just want use cayenne api to do the ORM job.
and ideas, thanks~
Re: CayenneDataObject is likely not mapped
Posted by Andrus Adamchik <an...@objectstyle.org>.
See my reply in "is is possible to dynamically create entity in cayenne" thread. An explicit reverse-engineering step is required.
Andrus
> On Jul 22, 2018, at 6:46 PM, 刘波 <10...@qq.com> wrote:
>
> ServerRuntime cayenneRuntime = ServerRuntime.builder()
> .addConfig("cayenne-project.xml")
> .build();
> ObjectContext context = cayenneRuntime.newContext();
>
>
> DataObject person = new CayenneDataObject();
> person.setObjectId(new ObjectId("Person"));
> context.registerNewObject(person);
>
> String name = (String) person.readProperty("name");
> Exception in thread "main" java.lang.IllegalArgumentException: Can't find ObjEntity for Persistent class: org.apache.cayenne.CayenneDataObject, class is likely not mapped.
> at org.apache.cayenne.access.DataContext.registerNewObject(DataContext.java:536)
>
> Person is a table in mysql, we aren't map it in xml, we want use it in fly, we don't define a deEntity for the table, just want use cayenne api to do the ORM job.
>
>
> and ideas, thanks~