Create an Entity all other Entity definitions can extend

24 views
Skip to first unread message

andreu...@taskize.co.uk

unread,
Mar 18, 2016, 9:50:24 AM3/18/16
to Sculptor Generator
Hi,

We are in a situation where we want all our entities to have some common fields. Lets say we want to have a BaseEntity with a field deleted that is a boolean defining the state of the entity. We are happy having to define "extends @BaseEntity" for every single Entity definition but the problem we are experiencing is that it does translate into a composition approach in the db.
Example would be:

----------------------------------------------------------------------
Sculptor:
----------------------------------------------------------------------
abstract Entity BaseEntity {
   boolean deleted;
}

Entity SomeEntity extends @Entity {
   String name;
}
----------------------------------------------------------------------

this gets translated into a ddl like:
----------------------------------------------------------------------
CREATE TABLE BASE_ENTITY (
   BASE_ENTITY_ID BIGINT NOT NULL,
   DELETED BOOLEAN
);

CREATE TABLE SOME_ENTITY (
   SOME_ENTITY_ID BIGINT NOT NULL,
   NAME VARCHAR(10),
   BASE_ENTITY_ID BIGINT NOT NULL
);
----------------------------------------------------------------------

where we would like something more like:
----------------------------------------------------------------------
CREATE TABLE SOME_ENTITY (
   SOME_ENTITY_ID BIGINT NOT NULL,
   NAME VARCHAR(10),
   DELETED BOOLEAN
);
----------------------------------------------------------------------


Is there anyway to achieve this?

Best regards,
Andreu
Reply all
Reply to author
Forward
0 new messages