You are viewing a plain text version of this content. The canonical link for it is here.
Posted to user@cayenne.apache.org by Chris Murphy <ch...@strandz.org> on 2008/10/07 11:16:00 UTC

Accepting DOs from a Spring service

I have a Swing application that is being converted from using JDO to 
using Cayenne. It uses ROP and calls some Spring services. On the server 
WebApplicationContextFilter is being used. Some of the Spring services 
return more than just straightforward objects like Strings, they return 
DOs as well. I want these DOs to work in the application just like any 
other - so I want them to be part of the application's DataContext, and 
I want them to be of the client variety. My current best theory approach 
is for PK values to be returned rather than DOs, and for the method 
DataObjectUtils.objectForPk() to be used when a real DO is required. Is 
this an approach that ought to work?

I'll concentrate on one of the types of DOs that comes across: Worker. 
Using the debugger I can see that the Workers are of the Cayenne server 
variety and still contain their PKs (but not much else). Thus I can test 
the above 'best theory' approach:

This works fine:
        int toReplacePK = DataObjectUtils.intPKForObject( 
(Persistent)toReplace);

With the PK I would think from the doco that 
DataObjectUtils.objectForPK() would be able to give me the kind of DO I 
want.

However this does not work:
        result = DataObjectUtils.objectForPK(
            objectContext,
            
org.strandz.data.wombatrescue.objects.cayenne.client.Worker.class,
            toReplacePK);

This is what the error looks like:
org.apache.cayenne.exp.ExpressionException: [v.3.0M4 May 18 2008 
16:32:02] Can't resolve path component: [worker.jdoid].
    at 
org.apache.cayenne.map.PathComponentIterator.invalidPathException(PathComponentIterator.java:146)

The error is coming from the server. It makes sense that the object is 
being fetched from the server as it has not been queried. Should I be 
able to use DataObjectUtils.objectForPK() from an ROP client?

thanks - Chris Murphy

-- 
Seaweed Software Pty Ltd,
http://www.strandz.org


Re: Thanks for fixing ROP Rollback

Posted by Andrey Razumovsky <ra...@gmail.com>.
Hi Tarik!

I've some changes in rollback procedure today too, so I recommend to use
fresh-built Cayenne jar with all changes.

Andrey

Thanks for fixing ROP Rollback

Posted by Tarik <ch...@gmail.com>.
Hi Andrey,

Thanks for fixing the rollbackChanges() method in ROP.  I will try to 
pick up your changes from svn and apply it as a patch to my cayenne 3 
jar.

Tarik

Re: Accepting DOs from a Spring service

Posted by Andrey Razumovsky <ra...@gmail.com>.
Hi Chris!

I think you encountered bug that has already been fixed [1]. You can try
last build instead of M4.
[1]. https://issues.apache.org/cayenne/browse/CAY-1081

2008/10/7, Chris Murphy <ch...@strandz.org>:
>
>
> I have a Swing application that is being converted from using JDO to using
> Cayenne. It uses ROP and calls some Spring services. On the server
> WebApplicationContextFilter is being used. Some of the Spring services
> return more than just straightforward objects like Strings, they return DOs
> as well. I want these DOs to work in the application just like any other -
> so I want them to be part of the application's DataContext, and I want them
> to be of the client variety. My current best theory approach is for PK
> values to be returned rather than DOs, and for the method
> DataObjectUtils.objectForPk() to be used when a real DO is required. Is this
> an approach that ought to work?
>
> I'll concentrate on one of the types of DOs that comes across: Worker.
> Using the debugger I can see that the Workers are of the Cayenne server
> variety and still contain their PKs (but not much else). Thus I can test the
> above 'best theory' approach:
>
> This works fine:
>       int toReplacePK = DataObjectUtils.intPKForObject(
> (Persistent)toReplace);
>
> With the PK I would think from the doco that DataObjectUtils.objectForPK()
> would be able to give me the kind of DO I want.
>
> However this does not work:
>       result = DataObjectUtils.objectForPK(
>           objectContext,
>
> org.strandz.data.wombatrescue.objects.cayenne.client.Worker.class,
>           toReplacePK);
>
> This is what the error looks like:
> org.apache.cayenne.exp.ExpressionException: [v.3.0M4 May 18 2008 16:32:02]
> Can't resolve path component: [worker.jdoid].
>   at
> org.apache.cayenne.map.PathComponentIterator.invalidPathException(PathComponentIterator.java:146)
>
> The error is coming from the server. It makes sense that the object is
> being fetched from the server as it has not been queried. Should I be able
> to use DataObjectUtils.objectForPK() from an ROP client?
>
> thanks - Chris Murphy
>
> --
> Seaweed Software Pty Ltd,
> http://www.strandz.org
>
>