With annotation OneToOne, Hibernate is ignoring FetchType.LAZY
Code:
@Entity
@Table(name = "estudante", schema = "ingres", uniqueConstraints = {})
public class Estudante implements java.io.Serializable {
private Integer cdEstudante;
private EstEnderecoPais estEnderecoPais;
// Property accessors
@Id
@Column(name = "cd_estudante", unique = true, nullable = true, insertable = true, updatable = true)
public Integer getCdEstudante() {
return this.cdEstudante;
}
public void setCdEstudante(Integer cdEstudante) {
this.cdEstudante = cdEstudante;
}
@OneToOne(targetEntity = org.test.EstEnderecoPais.class, mappedBy = "estudante", fetch = FetchType.LAZY)
public EstEnderecoPais getEstEnderecoPais() {
return this.estEnderecoPais;
}
public void setEstEnderecoPais(EstEnderecoPais estEnderecoPais) {
this.estEnderecoPais = estEnderecoPais;
}
}
Code:
@Entity
@Table(name = "est_endereco_pais", schema = "ingres", uniqueConstraints = {})
public class EstEnderecoPais implements java.io.Serializable {
private Integer cdEstudante;
private Estudante estudante;
@Id
@Column(name = "cd_estudante", unique = true, nullable = false, insertable = true, updatable = true)
public Integer getCdEstudante() {
return this.cdEstudante;
}
public void setCdEstudante(Integer cdEstudante) {
this.cdEstudante = cdEstudante;
}
@OneToOne(targetEntity = org.test.Estudante.class, cascade = CascadeType.ALL, fetch = FetchType.LAZY)
@JoinColumn(name = "cd_estudante", nullable = true)
public Estudante getEstudante() {
return this.estudante;
}
public void setEstudante(Estudante estudante) {
this.estudante = estudante;
}
}
I looked at some other topics and i cannot found some solution that really works...