Pergunta

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

Foi útil?

Solução

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).

Licenciado em: CC-BY-SA com atribuição
Não afiliado a StackOverflow
scroll top