You are viewing a plain text version of this content. The canonical link for it is here.
Posted to user@cayenne.apache.org by Juergen Saar <ju...@jsaar.org> on 2009/07/29 14:43:40 UTC

Refresh ObjectId for meaningful PK

Hi,

I'm working on an 20 year old project with meaningful primary keys.

Till now, we used cayenne only for reading but now we are working on the
first 'real' Web-Components that handle Order-Data.

So I have to create the primary key myself.

In the Modeller I created ObjAttributes for the PK-Fields and use the
setters to transfer the PK-Values to the Business-Object.

In most cases this seems to work, only sometimes a CayenneRuntimeExeption
tells me some Problems about temporary ObjectIds. The Data are stored pretty
correct in the Database Tables.

In some cases, especially on 1:1 Relations there are Problems with the
Foreign Keys.

So I try to setup my own ObjectId with the generated Values for the primary
Key and put this into the DataObject by setObjectId().

This brings the whole BusinessObject in trouble.

Is there a correct way to solve this problem?
-Juergen-

Re: Refresh ObjectId for meaningful PK

Posted by Juergen Saar <ju...@jsaar.org>.
Sorry ... I'm working with 2.0.4

actually I stopped using setObjectId.

Now on Commit the following CayenneRuntimeException is thrown;
Can't extract a master key. Missing key (esd_abteil), master ID
(<ObjectId:EsSend, TEMP:000002770CF60001>)

The relation for this is a 1:1 relation and the esd_abteil Property in the
belonging root-Object (EsSend) has the correct value
as I can see in the debug-logfile.

I think the Problem is caused by the ObjectId ...


2009/7/29 Andrey Razumovsky <ra...@gmail.com>

> Manually invoking setObjectId() in the middle of CDO lifecycle isn't a good
> idea, because data object might have already been registered in context
> with
> another ObjectId. What CayenneRuntimeExeptions are you having and what is
> your version of Cayenne?
>
> 2009/7/29 Juergen Saar <ju...@jsaar.org>
>
> > Hi,
> >
> > I'm working on an 20 year old project with meaningful primary keys.
> >
> > Till now, we used cayenne only for reading but now we are working on the
> > first 'real' Web-Components that handle Order-Data.
> >
> > So I have to create the primary key myself.
> >
> > In the Modeller I created ObjAttributes for the PK-Fields and use the
> > setters to transfer the PK-Values to the Business-Object.
> >
> > In most cases this seems to work, only sometimes a CayenneRuntimeExeption
> > tells me some Problems about temporary ObjectIds. The Data are stored
> > pretty
> > correct in the Database Tables.
> >
> > In some cases, especially on 1:1 Relations there are Problems with the
> > Foreign Keys.
> >
> > So I try to setup my own ObjectId with the generated Values for the
> primary
> > Key and put this into the DataObject by setObjectId().
> >
> > This brings the whole BusinessObject in trouble.
> >
> > Is there a correct way to solve this problem?
> > -Juergen-
> >
>

Re: Refresh ObjectId for meaningful PK

Posted by Andrey Razumovsky <ra...@gmail.com>.
Manually invoking setObjectId() in the middle of CDO lifecycle isn't a good
idea, because data object might have already been registered in context with
another ObjectId. What CayenneRuntimeExeptions are you having and what is
your version of Cayenne?

2009/7/29 Juergen Saar <ju...@jsaar.org>

> Hi,
>
> I'm working on an 20 year old project with meaningful primary keys.
>
> Till now, we used cayenne only for reading but now we are working on the
> first 'real' Web-Components that handle Order-Data.
>
> So I have to create the primary key myself.
>
> In the Modeller I created ObjAttributes for the PK-Fields and use the
> setters to transfer the PK-Values to the Business-Object.
>
> In most cases this seems to work, only sometimes a CayenneRuntimeExeption
> tells me some Problems about temporary ObjectIds. The Data are stored
> pretty
> correct in the Database Tables.
>
> In some cases, especially on 1:1 Relations there are Problems with the
> Foreign Keys.
>
> So I try to setup my own ObjectId with the generated Values for the primary
> Key and put this into the DataObject by setObjectId().
>
> This brings the whole BusinessObject in trouble.
>
> Is there a correct way to solve this problem?
> -Juergen-
>