Hi All,
We've been using hibernate annotations 3.1 beta 3 with hibernate 3.1 beta release. We've a class DataCenter which has one to one relationship with class Workgroup.
Here's how we've defined the annotations in DataCenter class (only relevant portion of DataCenter class):
Code:
public class DataCenter extends BaseAdminEntity {
private WorkGroup workgroup;
@OneToOne(cascade = CascadeType.ALL)
@JoinColumn(name="WORKGROUP_ID", referencedColumnName="id")
@NotNull
public WorkGroup getWorkgroup() {
return workgroup;
}
Here's how the schema is generated:
Code:
create table DATACENTER (
id number(19,0) not null,
CREATED_DATE timestamp,
CREATED_BY_ID number(19,0),
CREATED_BY_NAME varchar2(64),
MODIFIED_DATE timestamp,
MODIFIED_BY_ID number(19,0),
MODIFIED_BY_NAME varchar2(64),
NAME varchar2(64) not null,
IS_ACTIVE number(1,0) not null,
DESCRIPTION varchar2(256) not null,
WORKGROUP_ID number(19,0),
primary key (id),
unique (WORKGROUP_ID)
);
As you can see in the schema, one-to-one relationship with Workgroup has unique constraint. Is there a way i can remove this unique constraint for this column WORKGROUP_ID using annotations? The reason is that in our c ase each DataCenter will have one workgroup but it need not be unique.
Could someone please let me know how to remove the unique constraint in this case?
Thanks for any input in advance!