I'm having some trouble mapping a bidirectional one to many list using Hibernate 3.0.5, Annotations Beta 2, and hsqldb 1.7.2. Specifically, the index column is null for every new record. What have I done incorrectly?
Code:
@Entity
public class FieldTypeAttribute {
...
@ManyToOne
@JoinColumn(name="fieldTypeAttribute_id")
public FieldType getType() {
return type;
}
public void setType(FieldType type) {
this.type = type;
}
}
@Entity
public class FieldType extends PersistentEntity {
...
@OneToMany(mappedBy="type", cascade=CascadeType.ALL)
@IndexColumn(name="typeAttributeIndex")
public List<FieldTypeAttribute> getAttributes() {
return attributes;
}
}
The generated SQL (show_sql=true):
Hibernate: insert into FieldTypeAttribute (name, fieldTypeAttribute_id, description, id) values (?, ?, ?, null)
HSQL Script:
create table FieldType (name varchar(255), description varchar(255), id integer generated by default as identity (start with 1), primary key (id))
create table FieldTypeAttribute (name varchar(255), description varchar(255), id integer generated by default as identity (start with 1), fieldTypeAttribute_id integer, typeAttributeIndex integer, primary key (id))
alter table FieldTypeAttribute add constraint FKDA86EDC8CB49B8FB foreign key (fieldTypeAttribute_id) references FieldType
INSERT INTO FIELDTYPE VALUES('Phone Number',NULL,1)
INSERT INTO FIELDTYPEATTRIBUTE VALUES('Area Code',NULL,1,1,NULL)