Hi Andrea,
As DataContext can only commit objects that are registered, I think
your "unregistered" object got pulled in when you established a
relationship with another, registered, object (by this you've
attached the object to the bigger persistent object graph).
In other words "setMyAttribute(foo)" is not enough to auto-register
an object, but "setMyRelationship(myCayenneDataObject2)" is.
This is a default behavior in 1.2, consistent with the overall
Cayenne philosophy. Your example code is still does not have the
details to prove this idea, but I think that's what it is.
Andrus
On Dec 16, 2005, at 11:46 AM, Andrea Borgogelli Avveduti wrote:
> Hi Andrus,
> I was wondering if dataobjects which are not register are comitted
> too.
> In the following example I have declared two dataobjects, set the
> relative attributes and resgistered only one. But when I commit,
> Cayenne inserts two objects in my db.
>
> // Example (not real code):
>
> .....
> public MyCayenneDataClass myCayenneDataObject;
> .....
>
> myCayenneDataObject.setMyAttribute(foo);
>
> ......
> MyCayenneDataClass myCayenneDataObject2 = ( MyCayenneDataClass )
> dataContext.createAndRegisterNewObject( MyCayenneDataClass.class );
> .....
> datacontext.commitChanges(); // TWO OBJECTS ARE COMMITTED. WHY NOT
> ONLY ONE ?
This archive was generated by hypermail 2.0.0 : Fri Dec 16 2005 - 04:31:26 EST