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 >> class hierarchy persistence MappedSuperclass
Date Wed, 22 Jun 2016 18:42:31 GMT

Thank you Andrus for your answer.

For my overview on Cayenne do you mean Cayenne cannot persists class hierarchy' properties
? How may I manage JPA @javax.persistence.MappedSuperclass in Cayenne ?

Auditable is just an exemple to reproduce my case from a more complex project which has a
lot of superclasses and doing interfaces for each is not an option (poor OOP design). Moreover
the use of listeners on super abstract classes could be a great advantage but seems not useful
if they can't be persisted.

Is an evolution doable in a reasonable time ?

Best Regards,


-----Original Message-----

Hi Frederic,

Looking at the GitHub example, my recommendation is to avoid mapping Auditable in Cayenne

as an entity. The easiest alternative is to make Auditable an interface and let appropriate

entities implement it.


De : Frederic Gilbart
Envoyé : lundi 20 juin 2016 21:25
À : '' <>
Objet : RE: UUID as primary key

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