Hello!
I'm using Hibernate Annotations. I want to create a
unique index over a column. But I can only create a "simple" index. Is there any way to do this?
my class:
Code:
@Entity
@Embeddable
@Table(name = "itemtypes")
public class ItemType implements Serializable {
private static final long serialVersionUID = 132352309765740359L;
@Id
@GeneratedValue(strategy=GenerationType.SEQUENCE)
@Column(name="itemtypeid", nullable = false)
private int itemTypeId;
@Index(columnNames = { "name" }, name = "itemtypes_name_key")
@Column(name="name", length=50, nullable = false)
private String name;
@Column(name="lineinfo", nullable = false)
private boolean hasLineInfo = false;
[...]
}
I want this:
Code:
CREATE TABLE itemtypes
(
itemtypeid integer NOT NULL,
lineinfo boolean NOT NULL,
name character varying(50) NOT NULL,
CONSTRAINT itemtypes_pkey PRIMARY KEY (itemtypeid)
)
WITH (OIDS=FALSE);
ALTER TABLE itemtypes OWNER TO me;
CREATE UNIQUE INDEX itemtypes_name_key
ON itemtypes
USING btree
(name);
But I only get this:
Code:
[...]
CREATE INDEX itemtypes_name_key
ON itemtypes
USING btree
(name);
UNIQUE keyword missing :(
Thx for your time!