Hey guys, can you please help me out with ForeignKey constraint name override for following setup:
Code:
@MappedSuperclass
public abstract class Base
{
@Id
@GeneratedValue(strategy = GenerationType.IDENTITY)
@Column(name = "id")
protected long id;
public Long getId()
{
return id;
}
}
Code:
@MappedSuperclass
public abstract class CreateUpdateTimestampableBase extends Base {}
Code:
@Entity
@Table(name = "abstract_users")
@Access(AccessType.FIELD)
@Inheritance(strategy = InheritanceType.JOINED)
@DiscriminatorColumn(name = "user_type", discriminatorType = DiscriminatorType.STRING, length = 15)
abstract public class AbstractUser extends CreateUpdateTimestampableBase {}
Code:
@Entity
@Table(name = "users")
@Access(AccessType.FIELD)
@DiscriminatorValue("user")
public class User extends AbstractUser {}
I tried
@PrimaryKeyJoinColumn(name = "id", foreignKey = @ForeignKey(name = "...")), it changed primary key column name, however it doesn't respect foreign key. Also i tried
@AssociationOverride(), but couldn't make it work... Any ideas?
Currently i get mangled FK name like:
Code:
ALTER TABLE ONLY users ADD CONSTRAINT fk_ncwxer8x284o9w96xjk9uxfh7 FOREIGN KEY (id) REFERENCES abstract_users(id);
I don't want to use custom naming strategy, because default strategy with mangled name makes easier for me to find which foreign keys i didn't declared by myself, and makes it easier to handle liquibase dependencies later for me.