Hi Andrey,

You've run into CAY-574:

https://issues.apache.org/cayenne/browse/CAY-574

This issue has been fixed in 3.0-SNAPSHOT and will be in 3.0M4 when that
is released.  If you don't want to run the snapshots, Andrus has a
workaround for the problem as a comment in the aforementioned issue.

-- 
Kevin Menard
Servprise International, Inc.
Remote reboot & power control for your network
www.servprise.com                  +1 508.892.3823 x308


> -----Original Message-----
> From: Razumovsky Andrey [mailto:[EMAIL PROTECTED]
> Sent: Tuesday, February 19, 2008 7:24 AM
> To: [email protected]
> Subject: ROP: DataObjectUtils.objectForPK() doesn't work
> 
> Hello!
> 
> So that's the problem, when i run my simple example:
> public static void main(String[] args) throws CayenneException {
>               ClientConnection connection = new
> HessianConnection("http://localhost:8080/cayenne/cws";);
> 
>               DataChannel channel = new ClientChannel(connection);
>               ObjectContext context = new CayenneContext(channel);
> 
>               Militaryman mm =
> (Militaryman)DataObjectUtils.objectForPK(context, Militaryman.class,
> 100110250529L);
>               Dicrow dr = (Dicrow)DataObjectUtils.objectForPK(context,
> Dicrow.class, 100110142120L);
> 
>               mm.setToDicrow1(dr);
>               context.commitChanges();
>       }
> 
> I get exception on client:
> Exception in thread "main" org.apache.cayenne.CayenneRuntimeException:
> [v.3.0M2 Oct 28 2007 16:09:02] No DbEntity for ObjEntity: Militaryman
>       at
> org.apache.cayenne.DataObjectUtils.buildId(DataObjectUtils.java:308)
>       at
>
org.apache.cayenne.DataObjectUtils.objectForPK(DataObjectUtils.java:149
> )
>       at com.nic.porshe.Main.main(Main.java:26)
> 
> Still, this code works all right:
> public static void main4(String[] args) throws CayenneException {
>               ClientConnection connection = new
> HessianConnection("http://localhost:8080/cayenne/cws";);
> 
>               DataChannel channel = new ClientChannel(connection);
>               ObjectContext context = new CayenneContext(channel);
> 
>               Expression e1 =
> Expression.fromString("db:militarymanid='100110250529'");
>               SelectQuery select = new SelectQuery(Militaryman.class,
> e1);
>               Militaryman mm =
> (Militaryman)context.performQuery(select).get(0);
> 
>               Expression e2 =
> Expression.fromString("db:dicrowid='100110142120'");
>               SelectQuery select2 = new SelectQuery(Dicrow.class, e2);
>               Dicrow dr =
(Dicrow)context.performQuery(select2).get(0);
> 
>               mm.setToDicrow1(dr);
>               context.commitChanges();
>       }
> 
> Thanks for help,
> Andrey)

Reply via email to