cayenne-user mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From Frederic Gilbart <>
Subject RE: UUID as primary key
Date Mon, 20 Jun 2016 19:24:51 GMT
Hi all,

After further tests I think the problem is not relative to UUID nor primary keys but to properties
from super classes that seem never persisted.

I've updated the Tutorial code to add a new class org.apache.cayenne.tutorial.persistent.Auditable
with has some basic properties, then updated Artist class to override Auditable.

Gallery does not override it but uses the 2 new properties, so I can compare results. DBEntity
is updated accordingly.

Test sources are available on github

Properties which are super class based are not persisted. Properties of the ObjEntity are.

One strange behavior : on first run, when tables are created, properties of the superclass
are returned not null, but not saved in database. On the second run, when tables already exists
the test fails : super properties are null & not saved.

I'm not familiar with Cayenne : I like concepts in use and try to evaluate Cayenne for a project,
I don't know if i use it poorly to get such results.

Any help would be appreciated.



De : Frederic Gilbart
Envoyé : dimanche 19 juin 2016 21:16
À : '' <>
Objet : UUID as primary key

Hi all,

I'm looking for some information to use java.util.UUID as a «Meaningful Primary Key » as
stated in .

I've planned to use a Listener onPreUpdate to initialize the value.

Every tries shown an Integer used in my VARCHAR column, and my UUID key unused (but a sequence
value instead)

Modeler PK generation is « default ».
I'm using it that way

public void postAdd(Audit object) {
   object.setCreationDate(new Date());

Most of objects extends this abstract super class Audit.

Listerner is added to context at startup and  triggered as expected.

I'm using 4M3.

Do you know how to deal with this ?

One more thing : for all abstract super classes, should I duplicate properties on the overiding
objects because without doing it values seems not persisted  ?


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