Chris Murphy | 1 Sep 08:57 2008

Is registerNewObject() required?


I have a relationship between two entities whereby a Worker references 
another Worker. The name of the relationship is 'actualBelongsToGroup'. 
When I try to set one on the other using this relationship, Cayenne baulks:

Caused by: java.lang.NullPointerException
    at 
org.apache.cayenne.CayenneDataObject.setToOneTarget(CayenneDataObject.java:297)
    at 
org.strandz.data.wombatrescue.objects.cayenne.auto._Worker.setActualBelongsToGroup(_Worker.java:229)
    at 
org.strandz.data.wombatrescue.objects.cayenne.Worker.setBelongsToGroup(Worker.java:139)

The problem occurs because getDataContext() on the <being set> worker is 
returning null.

Do I have to dataContext.registerNewObject( <being set worker>) on the 
<being set worker> before calling setActualBelongsToGroup( <another 
worker>) on it? 

What is the philosophy here? I thought I would be able to put together a 
graph of objects, without regard to persistence issues, then later 
register them, then commit?

thanks - Chris

--

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

(Continue reading)

Michał Morzywołek | 1 Sep 09:50 2008
Picon

Re: Is registerNewObject() required?

Hello Chris,

i'm not a serious Cayenne developer so i might be wrong but as far as I know
objects have to be registered with cayenne before any changes/reading of
relationships. It can be done by registerNewObject() (for already existing
objects) or createNewObject() (object is registered during creation). Like
i've said - im out of the game for some time so i might be wrong :)

*Announcement*Fresh Msc looking for a job - got any free spot ;-)?

Goodluck,
Michał Morzywołek

2008/9/1 Chris Murphy <chris <at> strandz.org>

>
> I have a relationship between two entities whereby a Worker references
> another Worker. The name of the relationship is 'actualBelongsToGroup'. When
> I try to set one on the other using this relationship, Cayenne baulks:
>
> Caused by: java.lang.NullPointerException
>   at
> org.apache.cayenne.CayenneDataObject.setToOneTarget(CayenneDataObject.java:297)
>   at
> org.strandz.data.wombatrescue.objects.cayenne.auto._Worker.setActualBelongsToGroup(_Worker.java:229)
>   at
> org.strandz.data.wombatrescue.objects.cayenne.Worker.setBelongsToGroup(Worker.java:139)
>
> The problem occurs because getDataContext() on the <being set> worker is
> returning null.
(Continue reading)

Tarik | 1 Sep 21:10 2008
Picon

Rolling back changes in ROP does seem to work

I'm trying to roll back a transaction in ROP but strangely, none of changed
values get reverted.  Am I missing something basic or is rolling back
changes on ROP broken?

This is what I'm doing:

        ClientConnection connection = new HessianConnection("http://" +
server
                + "/cayenne-service", "cayenne-user", "secret", null);

        DataChannel channel = new ClientChannel(connection);

        ObjectContext context = new CayenneContext(channel);

        Contact contact = context.newObject(Contact.class);

        contact.setFirstName("Joe");

        context.commitChanges();

        System.out.println("1. persistence state=
"+contact.getPersistenceState()+" first name="+contact.getFirstName());

        contact.setFirstName("Jack");

        System.out.println("2. persistence state=
"+contact.getPersistenceState()+" first name="+contact.getFirstName());

        context.rollbackChanges();

(Continue reading)

Tarik | 2 Sep 19:35 2008
Picon

Rolling back changes in ROP does NOT seem to work

Sorry I had a typo in the subject of my email.  Should have been Rolling
back changes in ROP does NOT seem to work.  Thanks for any help with this.

On 9/1/08, Tarik <chertar <at> gmail.com> wrote:
>
> I'm trying to roll back a transaction in ROP but strangely, none of changed
> values get reverted.  Am I missing something basic or is rolling back
> changes on ROP broken?
>
> This is what I'm doing:
>
>         ClientConnection connection = new HessianConnection("http://" +
> server
>                 + "/cayenne-service", "cayenne-user", "secret", null);
>
>         DataChannel channel = new ClientChannel(connection);
>
>         ObjectContext context = new CayenneContext(channel);
>
>         Contact contact = context.newObject(Contact.class);
>
>         contact.setFirstName("Joe");
>
>         context.commitChanges();
>
>         System.out.println("1. persistence state=
> "+contact.getPersistenceState()+" first name="+contact.getFirstName());
>
>         contact.setFirstName("Jack");
>
(Continue reading)

Joe Baldwin | 3 Sep 19:43 2008
Picon
Picon

Result Set Filters?

Lets say that I might want to filter my result set by eliminating  
certain entries.  What is the recommended (i.e. best practice) method  
of filtering the result set so that you can produce a Java List that  
is a subset of the original result set?

I would like to accomplish this in much the same way as sort-ordering  
a result-set.

BTW, the reason I want to do this is that the SQL filter would be  
complex when compared with Java List processing.

Aristedes Maniatis | 3 Sep 20:02 2008
Picon

Re: Result Set Filters?


On 04/09/2008, at 3:43 AM, Joe Baldwin wrote:

> Lets say that I might want to filter my result set by eliminating  
> certain entries.  What is the recommended (i.e. best practice)  
> method of filtering the result set so that you can produce a Java  
> List that is a subset of the original result set?

You can use Cayenne expressions to filter a list in memory.

http://cayenne.apache.org/doc/in-memory-evaluation.html

Ari Maniatis

-------------------------->
ish
http://www.ish.com.au
Level 1, 30 Wilson Street Newtown 2042 Australia
phone +61 2 9550 5001   fax +61 2 9550 4001
GPG fingerprint CBFB 84B4 738D 4E87 5E5C  5EFA EF6A 7D2E 3E49 102A

Joe Baldwin | 3 Sep 20:07 2008
Picon
Picon

Re: Result Set Filters?

Thanks; that is it!  I figured Cayenne could do it, I just couldn't  
find the example.

On Sep 3, 2008, at 2:02 PM, Aristedes Maniatis wrote:

>
> On 04/09/2008, at 3:43 AM, Joe Baldwin wrote:
>
>> Lets say that I might want to filter my result set by eliminating  
>> certain entries.  What is the recommended (i.e. best practice)  
>> method of filtering the result set so that you can produce a Java  
>> List that is a subset of the original result set?
>
> You can use Cayenne expressions to filter a list in memory.
>
> http://cayenne.apache.org/doc/in-memory-evaluation.html
>
>
> Ari Maniatis
>
>
> -------------------------->
> ish
> http://www.ish.com.au
> Level 1, 30 Wilson Street Newtown 2042 Australia
> phone +61 2 9550 5001   fax +61 2 9550 4001
> GPG fingerprint CBFB 84B4 738D 4E87 5E5C  5EFA EF6A 7D2E 3E49 102A
>
>

(Continue reading)

Joe Baldwin | 3 Sep 20:26 2008
Picon
Picon

Re: Result Set Filters?

Ari,

do you know if result sets can be combined?

Joe

On Sep 3, 2008, at 2:02 PM, Aristedes Maniatis wrote:

>
> On 04/09/2008, at 3:43 AM, Joe Baldwin wrote:
>
>> Lets say that I might want to filter my result set by eliminating  
>> certain entries.  What is the recommended (i.e. best practice)  
>> method of filtering the result set so that you can produce a Java  
>> List that is a subset of the original result set?
>
> You can use Cayenne expressions to filter a list in memory.
>
> http://cayenne.apache.org/doc/in-memory-evaluation.html
>
>
> Ari Maniatis
>
>
> -------------------------->
> ish
> http://www.ish.com.au
> Level 1, 30 Wilson Street Newtown 2042 Australia
> phone +61 2 9550 5001   fax +61 2 9550 4001
> GPG fingerprint CBFB 84B4 738D 4E87 5E5C  5EFA EF6A 7D2E 3E49 102A
(Continue reading)

Aristedes Maniatis | 3 Sep 20:40 2008
Picon

Re: Result Set Filters?


On 04/09/2008, at 4:26 AM, Joe Baldwin wrote:

> do you know if result sets can be combined?

They are simply Java Collections. Combine them as you would any  
regular list. Nothing special you need to do.

Ari

-------------------------->
ish
http://www.ish.com.au
Level 1, 30 Wilson Street Newtown 2042 Australia
phone +61 2 9550 5001   fax +61 2 9550 4001
GPG fingerprint CBFB 84B4 738D 4E87 5E5C  5EFA EF6A 7D2E 3E49 102A

Andrus Adamchik | 4 Sep 13:43 2008

Re: Rolling back changes in ROP does seem to work

Hi Tarik,

You are right, this is a bug in Cayenne. I can reproduce it. Let me  
Jira it and see what we can do.

Andrus

On Sep 1, 2008, at 10:10 PM, Tarik wrote:

> I'm trying to roll back a transaction in ROP but strangely, none of  
> changed
> values get reverted.  Am I missing something basic or is rolling back
> changes on ROP broken?
>
> This is what I'm doing:
>
>        ClientConnection connection = new HessianConnection("http://" +
> server
>                + "/cayenne-service", "cayenne-user", "secret", null);
>
>        DataChannel channel = new ClientChannel(connection);
>
>        ObjectContext context = new CayenneContext(channel);
>
>        Contact contact = context.newObject(Contact.class);
>
>        contact.setFirstName("Joe");
>
>        context.commitChanges();
>
(Continue reading)


Gmane