A bug in hibernate creates duplicated foreign key constraints when generates a ddl script using hibernate tool or Noemalife DDL Generator. This happens when the model has a hierarchy with subclasses that extend the superclasse using generics.
Example (using JPA):
@MappedSuperclass
public abstract class AbstractPersonRelationship<T extends AbstractEntity> extends AbstractEntity
@Entity
public class PersonRelationship extends AbstractPersonRelationship<Person>
@Entity
public class PersonPractitionerBinding extends AbstractPersonRelationship<Practitioner>
WIth hbm2ddl in the ddl script I have:
alter table PSN_PRACTITIONER_BINDING
add constraint FK_PSNPRACT_PRACT_TARGET
foreign key (TARGET_ID_PRACT)
references PSN_PERSON;
alter table PSN_PRACTITIONER_BINDING
add constraint FK_PSNPRACT_PRACT_TARGET
foreign key (TARGET_ID_PRACT)
references PSN_PRACTITIONER;
In PersonRelationhip the constraint is not duplicated...
|