Using the shema
generator of hibernate
3.6
org.hibernate.cfg.Configuration.generateSchemaCreationScript
And with thoses models definition :
@Entity
@Table(name="ERP_Period")
@PrimaryKeyJoinColumn(name = "id")
public class ErpPeriod extends Record{
@EmbeddedId
private PeriodId codeId;
@Override
public PeriodId getCodeId() {
return codeId;
}
public void setCodeId(PeriodId codeId) {
this.codeId = codeId;
}
}
@Embeddable
public class PeriodId {
private ErpFolder folder;
private int exercice;
private int period;
public ErpFolder getFolder() {
return folder;
}
public void setFolder(ErpFolder folder) {
this.folder = folder;
}
}
@Entity
@Table(name="ERP_Folder")
@PrimaryKeyJoinColumn(name = "id")
public class ErpFolder extends AbsErpFolder{
@Id
@GeneratedValue(strategy=GenerationType.AUTO)
private Long codeId;
@Override
public Long getCodeId() {
return codeId;
};
public void setCodeId(Long codeId) {
this.codeId = codeId;
}
}
The generator genrates the ErpFolder field as BLOB instead of Long id of the ErpFolder :
create table ERP_Period (exercice integer not null, folder blob not null, period integer not null, label varchar(255), primary key (exercice, folder, period))
With the result of the Database exception ( which is normal ):
org.firebirdsql.jdbc.FBSQLException: GDS Exception. 335544351. unsuccessful metadata update
attempt to index BLOB column in INDEX RDB$PRIMARY13
null