You are viewing a plain text version of this content. The canonical link for it is here.
Posted to dev@cayenne.apache.org by Kevin Menard <km...@servprise.com> on 2006/05/03 02:17:47 UTC

Bug in auto-DC registration?

Andrus, you'd probably be the best guy to answer this, but I'm going to  
throw it out there in general.  For reasons lost to me now, with the old  
milestones, I'd have code like the following:

final Blah b = (Blah) dc.createAndRegister(Blah.class);

// Somewhere else.
dc.unregisterObjects(Collections.singletonList(b));

// Somewhere else.
b.setSomeRelation(yo);


yo is registered with the DC, so setting the relationship should register  
b with the DC as well.  I suspect I had the unregister call because at one  
point there were problems with registering a DO twice with the same DC.

Anyway, the above causes an exception.  I've spent the better part of the  
day tracking it down.  It appears that when the insert occurs, the ID  
recorded for yo is null (so, the exception is a not-null constraint  
violation).  Remove the unregisterObjects() call and everything works  
dandy.  The problem seems to be the first time through all the ObjectDiffs  
get created fine.  The second time through, however, there is no  
ArcOperation created for the relationship.

So, is this a bug in how I'm doing things or in how Cayenne is?  At this  
point, I'm going to remove the unregisterObjects() call, but it seems to  
me that if setting relationships will auto-register, it should set  
everything up identically.

Thanks,
Kevin

Re: Bug in auto-DC registration?

Posted by Andrus Adamchik <an...@objectstyle.org>.
Sorry, I haven't ... it is on my TODO list - I am indeed pretty busy  
now.

Andrus


On May 4, 2006, at 5:37 PM, Kevin Menard wrote:

> Andrus,
>
> Were you able to give this any consideration yet?  I know you've  
> been busy with the JPA stuff, so if not, it's understandable.
>
> If my comments weren't clear enough in the test case what appears  
> to be happening is that given objects A, B, & C, where A's class  
> has relationships with both the classes of B & C:
>
> 1) Set up relationship between A & B, where at least one is  
> registered with a given DC.
> 	-- Relationship is set up fine in the object store
>
> 2) Unregister A.
> 	-- All relationships with A are removed from the object store
> 	-- If you call A.getB(), you get B, even though the object store  
> has a null value for that relationship
>
> 3) Set up relationship between A & C.
> 	-- A is auto-registered with C's context
> 	-- Object store is updated with relationship between A & C
> 	-- Object store is not updated with relationship between A & B
>
> 4) Commit A.
> 	-- Relationship between A & C is persisted while the one between A  
> & B is not
> 	-- A still thinks it has established relationships with B & C.
>
> Hopefully that made sense.
>
> -- 
> Kevin
>
> On Wed, 03 May 2006 09:59:03 -0400, Kevin Menard  
> <km...@servprise.com> wrote:
>
>> Okay, test has been committed to  
>> org.objectstyle.cayenne.access.ObjectStoreTst.  If you agree that  
>> it's an issue, I'll file a JIRA issue.  Regardless of whether I'm  
>> doing something wrong in my workflow, I think Cayenne is still  
>> behaving improperly in reporting and recording different object  
>> graphs.
>>
>
>
>


Re: Bug in auto-DC registration?

Posted by Kevin Menard <km...@servprise.com>.
Thanks a lot.  I didn't have enough time to respond to the first request  
for the JIRA ticket.  I'm glad I wasn't just imaging things either :-)

-- 
Kevin

On Fri, 05 May 2006 11:37:24 -0400, Andrus Adamchik  
<an...@objectstyle.org> wrote:

>> I'll be working on fixing this anyways, but I'd appreciate if you log  
>> this to Jira and assign to me.
>
> Never mind - I already checked in the fix and opened CAY-542 to record  
> it.
>
> Andrus



Re: Bug in auto-DC registration?

Posted by Andrus Adamchik <an...@objectstyle.org>.
On May 5, 2006, at 9:53 AM, Andrus Adamchik wrote:

> I'll be working on fixing this anyways, but I'd appreciate if you  
> log this to Jira and assign to me.

Never mind - I already checked in the fix and opened CAY-542 to  
record it.

Andrus

Re: Bug in auto-DC registration?

Posted by Andrus Adamchik <an...@objectstyle.org>.
I think we should treat this as a bug. The core issue is that when an  
object that has not been instantiated by the DataContext is being  
registered, we need to traverse its properties and create appropriate  
arc diffs.

I'll be working on fixing this anyways, but I'd appreciate if you log  
this to Jira and assign to me.

Andrus


On May 4, 2006, at 5:37 PM, Kevin Menard wrote:

> Andrus,
>
> Were you able to give this any consideration yet?  I know you've  
> been busy with the JPA stuff, so if not, it's understandable.
>
> If my comments weren't clear enough in the test case what appears  
> to be happening is that given objects A, B, & C, where A's class  
> has relationships with both the classes of B & C:
>
> 1) Set up relationship between A & B, where at least one is  
> registered with a given DC.
> 	-- Relationship is set up fine in the object store
>
> 2) Unregister A.
> 	-- All relationships with A are removed from the object store
> 	-- If you call A.getB(), you get B, even though the object store  
> has a null value for that relationship
>
> 3) Set up relationship between A & C.
> 	-- A is auto-registered with C's context
> 	-- Object store is updated with relationship between A & C
> 	-- Object store is not updated with relationship between A & B
>
> 4) Commit A.
> 	-- Relationship between A & C is persisted while the one between A  
> & B is not
> 	-- A still thinks it has established relationships with B & C.
>
> Hopefully that made sense.
>
> -- 
> Kevin
>
> On Wed, 03 May 2006 09:59:03 -0400, Kevin Menard  
> <km...@servprise.com> wrote:
>
>> Okay, test has been committed to  
>> org.objectstyle.cayenne.access.ObjectStoreTst.  If you agree that  
>> it's an issue, I'll file a JIRA issue.  Regardless of whether I'm  
>> doing something wrong in my workflow, I think Cayenne is still  
>> behaving improperly in reporting and recording different object  
>> graphs.
>>
>
>
>


Re: Bug in auto-DC registration?

Posted by Kevin Menard <km...@servprise.com>.
Andrus,

Were you able to give this any consideration yet?  I know you've been busy  
with the JPA stuff, so if not, it's understandable.

If my comments weren't clear enough in the test case what appears to be  
happening is that given objects A, B, & C, where A's class has  
relationships with both the classes of B & C:

1) Set up relationship between A & B, where at least one is registered  
with a given DC.
	-- Relationship is set up fine in the object store

2) Unregister A.
	-- All relationships with A are removed from the object store
	-- If you call A.getB(), you get B, even though the object store has a  
null value for that relationship

3) Set up relationship between A & C.
	-- A is auto-registered with C's context
	-- Object store is updated with relationship between A & C
	-- Object store is not updated with relationship between A & B

4) Commit A.
	-- Relationship between A & C is persisted while the one between A & B is  
not
	-- A still thinks it has established relationships with B & C.

Hopefully that made sense.

-- 
Kevin

On Wed, 03 May 2006 09:59:03 -0400, Kevin Menard <km...@servprise.com>  
wrote:

> Okay, test has been committed to  
> org.objectstyle.cayenne.access.ObjectStoreTst.  If you agree that it's  
> an issue, I'll file a JIRA issue.  Regardless of whether I'm doing  
> something wrong in my workflow, I think Cayenne is still behaving  
> improperly in reporting and recording different object graphs.
>



Re: Bug in auto-DC registration?

Posted by Kevin Menard <km...@servprise.com>.
On Tue, 02 May 2006 20:26:07 -0400, Kevin Menard <km...@servprise.com>  
wrote:

> Will do.
>

Okay, test has been committed to  
org.objectstyle.cayenne.access.ObjectStoreTst.  If you agree that it's an  
issue, I'll file a JIRA issue.  Regardless of whether I'm doing something  
wrong in my workflow, I think Cayenne is still behaving improperly in  
reporting and recording different object graphs.

-- 
Kevin

Re: Bug in auto-DC registration?

Posted by Kevin Menard <km...@servprise.com>.
Will do.

-- 
Kevin

On Tue, 02 May 2006 20:23:31 -0400, Andrus Adamchik  
<an...@objectstyle.org> wrote:

> Kevin,
>
> could you please check in a unit test that shows this problem - I'll  
> take a look.
>
> Andrus
>
>
> On May 2, 2006, at 8:17 PM, Kevin Menard wrote:
>
>> Andrus, you'd probably be the best guy to answer this, but I'm going to  
>> throw it out there in general.  For reasons lost to me now, with the  
>> old milestones, I'd have code like the following:
>>
>> final Blah b = (Blah) dc.createAndRegister(Blah.class);
>>
>> // Somewhere else.
>> dc.unregisterObjects(Collections.singletonList(b));
>>
>> // Somewhere else.
>> b.setSomeRelation(yo);
>>
>>
>> yo is registered with the DC, so setting the relationship should  
>> register b with the DC as well.  I suspect I had the unregister call  
>> because at one point there were problems with registering a DO twice  
>> with the same DC.
>>
>> Anyway, the above causes an exception.  I've spent the better part of  
>> the day tracking it down.  It appears that when the insert occurs, the  
>> ID recorded for yo is null (so, the exception is a not-null constraint  
>> violation).  Remove the unregisterObjects() call and everything works  
>> dandy.  The problem seems to be the first time through all the  
>> ObjectDiffs get created fine.  The second time through, however, there  
>> is no ArcOperation created for the relationship.
>>
>> So, is this a bug in how I'm doing things or in how Cayenne is?  At  
>> this point, I'm going to remove the unregisterObjects() call, but it  
>> seems to me that if setting relationships will auto-register, it should  
>> set everything up identically.
>>
>> Thanks,
>> Kevin
>>
>



Re: Bug in auto-DC registration?

Posted by Andrus Adamchik <an...@objectstyle.org>.
Kevin,

could you please check in a unit test that shows this problem - I'll  
take a look.

Andrus


On May 2, 2006, at 8:17 PM, Kevin Menard wrote:

> Andrus, you'd probably be the best guy to answer this, but I'm  
> going to throw it out there in general.  For reasons lost to me  
> now, with the old milestones, I'd have code like the following:
>
> final Blah b = (Blah) dc.createAndRegister(Blah.class);
>
> // Somewhere else.
> dc.unregisterObjects(Collections.singletonList(b));
>
> // Somewhere else.
> b.setSomeRelation(yo);
>
>
> yo is registered with the DC, so setting the relationship should  
> register b with the DC as well.  I suspect I had the unregister  
> call because at one point there were problems with registering a DO  
> twice with the same DC.
>
> Anyway, the above causes an exception.  I've spent the better part  
> of the day tracking it down.  It appears that when the insert  
> occurs, the ID recorded for yo is null (so, the exception is a not- 
> null constraint violation).  Remove the unregisterObjects() call  
> and everything works dandy.  The problem seems to be the first time  
> through all the ObjectDiffs get created fine.  The second time  
> through, however, there is no ArcOperation created for the  
> relationship.
>
> So, is this a bug in how I'm doing things or in how Cayenne is?  At  
> this point, I'm going to remove the unregisterObjects() call, but  
> it seems to me that if setting relationships will auto-register, it  
> should set everything up identically.
>
> Thanks,
> Kevin
>