문제

I have an entity where I put a composed UniqueConstraint, and try to rename this constraint by using the "name" attribute :

@Entity
@Table(name = "ApplicatifTerminal", uniqueConstraints = @UniqueConstraint(name = "UniqueApplicatifTerminal", columnNames = {
        "idApplicatif", "idTerminal" }))
public class ApplicatifTerminalDo {

........

But the name of the constraint is not changed, even when regenerating the DB, and stay with the default name of "idAttribute". It's not a blocking problem, I'm aware. But I would like to know why this attribute name doesn't work.

PS : I use hibernate 4.0.1

도움이 되었습니까?

해결책

I doubt it should be renamed: Hibernate does not know that it is the same constraint that it generated earlier in another deployment. You will have to do that manually.

But Hibernate should create an unique constraint with that name, if none is existent ON TABLE GENERATION. Indeed it seems to be a bug in Hibernate 4.0.1 (which creates the constraint with the name of the first column only on new table schema generation) which is solved in 4.3.0 (which creates the constraint with the correct name, even if the table already exists).

라이센스 : CC-BY-SA ~와 함께 속성
제휴하지 않습니다 StackOverflow
scroll top