I have this code :
@javax.persistence.Entity(access = AccessType.PROPERTY)
@Table(name = "ENTITIES")
@Inheritance(strategy = InheritanceType.JOINED)
public class Entity extends AbstractSimpleEntity implements IEntity {
@Id(generate = GeneratorType.TABLE)
@Column(name = "entity_id", nullable = false, unique = true)
public long getPrimaryKey() { return id; }
...
}
and
@Entity(access = AccessType.PROPERTY)
@Table(name = "PERSONS")
@Inheritance(strategy = InheritanceType.JOINED)
@PrimaryKeyJoinColumns( { @PrimaryKeyJoinColumn( name = "entity_id", referencedColumnName = "entity_id") } )
@Remote(IPerson.class)
public class Person extends org.infodavid.par.Entity implements IPerson { ... }
the first table is ok and like :
CREATE TABLE ENTITIES (
entity_id INTEGER GENERATED BY DEFAULT AS IDENTITY (START WITH 0, INCREMENT BY 1) PRIMARY KEY,
...
)
the second table seems not ok because the only key I have is 'entity_id' and no second key like 'person_id'. See what I want to do :
CREATE TABLE PERSONS (
person_id INTEGER GENERATED BY DEFAULT AS IDENTITY(START WITH 0, INCREMENT BY 1) PRIMARY KEY,
...
entity_id INTEGER NOT NULL,
FOREIGN KEY (entity_id) REFERENCES ENTITIES(entity_id) ON DELETE CASCADE,
)
JBoss has not created the column 'person_id'.
How can it work if a person has the same id as the entity ? I would like to create an other subclass of 'Entity' (like Company or something like this) and I don't understand how it can work.