cayenne-user mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From Michael Gentry <blackn...@gmail.com>
Subject Re: How to setup cayenne for tables with meaningful pk
Date Sat, 11 Jun 2016 14:19:37 GMT
Hi Fredrik,

If it helps, here is a simple example:

- https://github.com/mrg/cbe/tree/master/InsertingObjects/MeaningfulPK


The more interesting files are the main program and the Cayenne project
files:

-
https://github.com/mrg/cbe/blob/master/InsertingObjects/MeaningfulPK/src/main/java/cbe/inserting/MeaningfulPK.java

-
https://github.com/mrg/cbe/blob/master/InsertingObjects/MeaningfulPK/src/main/resources/cayenne-cbe-inserting.xml

-
https://github.com/mrg/cbe/blob/master/InsertingObjects/MeaningfulPK/src/main/resources/cbe-inserting.map.xml


You can download the two XML files and load it up in Cayenne Modeler to
take a look.  You need to make sure your meaningful PK is mapped as a Java
attribute and set the value before calling commitChanges().  And to second
what Ari said, don't use meaningful PKs if you can avoid it.

mrg


On Sat, Jun 11, 2016 at 3:19 AM, Fredrik Widengren <
fredrik.widengren@gmail.com> wrote:

> Hello
> I'm kind of new to Cayenne. So sorry if the question bordering to the
> obvious.
>
> I'm trying find out how I can create records where the db does not auto
> generate pk.
> First I got an error where Cayenne complained on that the AUTO_PK table was
> missing. After creating that, I can create records, but cayenne then picks
> values from the auto_pk table. So obviously that's not what I want. I need
> to be able to have a method where I can supply the pk value.
>
> I can't find any documentation on that.
>
> Thanks for any help.
>
> /Fredrik
>

Mime
  • Unnamed multipart/alternative (inline, None, 0 bytes)
View raw message