apache-cayenne

Inheritance - DB relations


I'm using Cayenne 4.1 and want to use the single table inheritance, but I have the problem that when using the modeller the DB relation I've created in the modeller are always dropped :-/ In Detail: I have the table and entity photo (superclass), the I have subclasses photoA and photoB, in photo I have a field (qualifier) which has the id of class A or class B, as it's not possible to maintain such an ambivalent relation directly in the DB, I maintain the relation in the modeller, so I can use it in the entity class, this works all fine, except that when I run the reengineer database schema function that the relations are dropped :-/

...but maybe I understood the concept wrong :-(

br Markus


Solution

  • You got everything right, you just hit the limitation of the Cayenne DB import functionality. It allows you to customize only the object layer, not DB, as it doesn't keep track of changes and just compares your model with the DB state on every run.

    Here what you could do about it: