使用shema
3.6
hibernate
生成器
org.hibernate.cfg.Configuration.generateSchemaCreationScript
使用模型定义:
@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;
}
}
生成器将ErpFolder字段生成为BLOB而不是ErpFolder的Long id:
create table ERP_Period (exercice integer not null, folder blob not null, period integer not null, label varchar(255), primary key (exercice, folder, period))
使用Database异常的结果(这是正常的):
org.firebirdsql.jdbc.FBSQLException: GDS Exception. 335544351. unsuccessful metadata update
attempt to index BLOB column in INDEX RDB$PRIMARY13
null