Michael,

> I was just trying to figure out where the salesOrderList property was in your 
> model, per this error:


Good point.  There is a SalesOrderList Relationship defined for the the 
Customer record (with a reverse relationship of Customer).

I checked the ObjEntity config for the Customer and here is the entry

        Name: salesOrderList
        Target:  SalesOrder
        Sematics: to many, list
        Delete Rule: Nullify
        Used For Locking: not checked

I set the Delete rule to "Nullify" thinking that there may come a time to 
delete the Customer record while retaining the SalesOrder record.  (Also I 
noticed that the Delete Rule for the SaleOrder - orderitemList is set to 
"Cascade", but MySQL doesn't seem to want to cascade delete the OrderItems when 
I delete a SalesOrder).

I would expect from my understanding of the Modeler is that when a Customer is 
deleted via Cayenne, that the SalesOrder - customerOID would be set to null.

Thanks,
Joe






On Nov 27, 2009, at 10:38 AM, Michael Gentry wrote:

> Hi Joe,
> 
> I was just trying to figure out where the salesOrderList property was
> in your model, per this error:
> 
>    Error unsetting to-many DataObject property: salesOrderList
> 
> I can't tell if that is in SalesOrder or OrderItem and it doesn't seem
> to match salesOrder.getOrderItemList().
> 
> Thanks,
> 
> mrg
> 
> 
> On Fri, Nov 27, 2009 at 10:29 AM, Joe Baldwin <[email protected]> wrote:
>> Michael,
>> 
>> 
>>> Is childList the same as salesOrderList?
>> 
>> Sorry, I am not sure what you mean by "the same".
>> 
>> If you are asking is the entity self-referential, then the answer is no.  
>> The parent is named "SalesOrder" and the child is "OrderItem". It is a 
>> simple "to-many" relationship (one sales-order to many order-items).
>> 
>> More info:
>> I did some more testing and found that the problem is associated with older 
>> SalesOrders stored in the production server and seems to be creating an 
>> Exception on
>> 
>>        objectContext.deleteObjects(salesOrder.getOrderItemList())
>> 
>> However, when I create a SalesOrder with new data, I cannot duplicate the 
>> Exception condition. So perhaps the Exception is somehow associated with the 
>> older data.
>> 
>> Also, I wrote my own "deleteObjects" method (for debugging purposes) and it 
>> appears to work fine with the new SalesOrders or seemingly as well the 
>> ObjectContext version and generated the same Exception with the older data.
>> 
>> The complication with debugging this issue is that the data is on the 
>> production server and once I attempt a test (even though it claims that it 
>> failed) the data is actually deleted, so I can't duplicate the test once all 
>> the data is deleted.
>> 
>> Thanks,
>> Joe
>> 
>> 
>> 
>> On Nov 27, 2009, at 10:03 AM, Michael Gentry wrote:
>> 
>>> Is childList the same as salesOrderList?
>>> 
>>> 
>>> On Thu, Nov 26, 2009 at 6:29 PM, Joe Baldwin <[email protected]> 
>>> wrote:
>>>> I am getting an odd exception when I attempt to delete a DataObject with a 
>>>> "to-many" (aka child list).
>>>> 
>>>> Here is the pseudo code:
>>>> 
>>>> 1. deleteObjects(parent.getChildList())
>>>> 2. deleteObject(parent)
>>>> 3. objectContext.commitChanges()
>>>> 
>>>> on Exception
>>>>        objectcontext.rollbackChanges()
>>>> 
>>>> 
>>>> It is very odd but I am getting the following error:
>>>> 
>>>> org.apache.cayenne.reflect.PropertyException:
>>>> [v.3.0B1 Nov 03 2009 19:16:06]
>>>> Error unsetting to-many DataObject property: salesOrderList
>>>> 
>>>> But it is deleting all the associated database rows.
>>>> 
>>>> Am I missing a step in the delete procedure?
>>>> 
>>>> thanks,
>>>> Joe
>>>> 
>>>> 
>> 
>> 

Reply via email to