Hi,
We used to generate our ddl using hibernateTool.
The following mapping:
Code:
@Entity
@Table(name="TB_SHARE")
public class BoShare implements Serializable {
@Id
@GeneratedValue(generator = "foreignGenerator")
@GenericGenerator(name = "foreignGenerator",
strategy = "foreign",
parameters = { @Parameter
(name = "property",
value = "bomain")
}
)
private Long id;
private String name;
@Version
private Integer version;
@OneToOne(mappedBy="share",fetch=FetchType.LAZY)
protected BoMain bomain;
//...(getters/setters/hashcode/equals)
}
@Entity
@Table(name="TB_MAIN")
public class BoMain implements Serializable {
@Id
private Long id;
@Version
private Integer version;
private String name;
@OneToOne(fetch=FetchType.LAZY)
@PrimaryKeyJoinColumn
private BoShare share;
//...(getters/setters/hashcode/equals)
}
With hibernate 3.3.2, that mapping produce the following ddl:
Code:
drop table TB_MAIN cascade constraints;
drop table TB_SHARE cascade constraints;
create table TB_MAIN (id number(19,0) not null, name varchar2(255 char), version number(10,0), primary key (id));
create table TB_SHARE (id number(19,0) not null, name varchar2(255 char), version number(10,0), primary key (id));
The binding sounds ok since the id of BoMain is properly used as id of BoShare.
The same mapping with hibernate 3.6.0 produced the ddl:
Code:
drop table TB_MAIN cascade constraints;
drop table TB_SHARE cascade constraints;
create table TB_MAIN (id number(19,0) not null, name varchar2(255 char), version number(10,0), primary key (id));
create table TB_SHARE (id number(19,0) not null, name varchar2(255 char), version number(10,0), primary key (id));
alter table TB_MAIN add constraint FKF0A5838ABA594AA3 foreign key (id) references TB_FSL_SHARE;
The generated foreign key on TB_MAIN prevent any insert in both table. Apparently during the secondPassCompile the @PrimaryKeyJoinColum is not taken into account.
Replacing it with @JoinColum(name="id") fix the problem.
Is it a problem with our mapping or change in the PrimaryKeyJoinColum are managed? In the second case, does it have any other impacts?
Best regards.