cayenne-user mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From Nikita Timofeev <ntimof...@objectstyle.com>
Subject Re: Question on how to properly create parent-child nested dependent objects?
Date Tue, 19 Sep 2017 13:47:41 GMT
We are back to what we have started from, it seems that you didn't
create table AUTO_PK_SUPPORT properly. Exception shows that there is
no row for 'CommunicationType' and because of this Cayenne can't
generate primary key.
This is a helper table that is used internally to generate primary
keys if you are using "Cayenne Generated" type.
All your need is to create (I think it is already created) and fill
this table, this can be done from Cayenne Modeler: Tools -> Generate
Database Schema -> Generate PK support flag, or you can try to run
this query directly:

INSERT INTO AUTO_PK_SUPPORT (TABLE_NAME, NEXT_ID)
VALUES ('CommunicationType', 200);

Database schema should be maintained by you, Cayenne can't help you
much with this as it can be dangerous in most cases, everything rest
should be fine, as Ari said you can create and/or modify everything in
one context and save it at the end.

On Tue, Sep 19, 2017 at 4:16 PM, Aristedes Maniatis <ari@maniatis.org> wrote:
> On 19/9/17 11:01PM, Andrew Willerding wrote:
>> The CommunicationType object does not yet exist permanently in the database table
so how or when does it generate the primary key for the object to be referenced by another
object before it is committed?  I was hoping to not have to worry about this as a "high-level"
user of Cayenne.
>
>
> You are right, you don't need to worry about all that. Just create one context and save
it at the end. Cayenne tracks the relationships between objects with a temporary key internally,
but you don't need to think about that. Once Caynenne commits, everything is assigned proper
primary keys and joined.
>
> Ari
>
>
> --
> -------------------------->
> Aristedes Maniatis
> GPG fingerprint CBFB 84B4 738D 4E87 5E5C  5EFA EF6A 7D2E 3E49 102A



-- 
Best regards,
Nikita Timofeev

Mime
View raw message