[hibernate-issues] [Hibernate-JIRA] Created: (HHH-4831) @NaturalId and @Column(unique=true) annotations generate two unique constraints.

Marcin Kuthan (JIRA) noreply at atlassian.com
Fri Jan 22 06:49:29 EST 2010


@NaturalId and @Column(unique=true) annotations generate two unique constraints.
--------------------------------------------------------------------------------

                 Key: HHH-4831
                 URL: http://opensource.atlassian.com/projects/hibernate/browse/HHH-4831
             Project: Hibernate Core
          Issue Type: Bug
          Components: annotations
    Affects Versions: 3.3.2
            Reporter: Marcin Kuthan


@NaturalId and @Column(unique=true) annotations generate two unique constraints.

For the following column definition:

{code}
@Column(name = "dictionary_code", length = 256, nullable = false, unique = true)
@org.hibernate.annotations.NaturalId
public String getCode() {
    return code;
}
{code}

Generated DDL for Mysql:
{code}
create table foo (entity_id bigint not null auto_increment, dictionary_code varchar(256) not null unique, primary key (entity_id), unique (dictionary_code)) ENGINE=InnoDB;
{code}

Generated DDL for Oracle:
{code}
create table foo (entity_id number(19,0) not null, dictionary_code varchar2(256 char) not null unique, primary key (entity_id), unique (dictionary_code));
{code}

As a workaround I set unique=false in @Column annotation. The @NaturalId annotation processor must be aware of @Column annotation, IMHO.

-- 
This message is automatically generated by JIRA.
-
If you think it was sent incorrectly contact one of the administrators: http://opensource.atlassian.com/projects/hibernate/secure/Administrators.jspa
-
For more information on JIRA, see: http://www.atlassian.com/software/jira

        


More information about the hibernate-issues mailing list