我是休眠新手,我使用注释
这是我的两张桌子:
这是我的表“角色”
@Entity
@Table(name = "persona")
public class Persona implements java.io.Serializable {
@Id
@GeneratedValue(strategy = GenerationType.IDENTITY)
@Column(name = "codigo", unique = true, nullable = false)
private int codigo;
@ManyToOne(fetch = FetchType.LAZY)
@JoinColumn(name = "codTipoIdent", nullable = false)
private TipoIdentificacion tipoIdentificacion;
....
这是我的第二张桌子“TipoIdentificacion”
@Entity
@Table(name = "tipoIdentificacion")
public class TipoIdentificacion implements java.io.Serializable {
@Id
@GeneratedValue(strategy = GenerationType.IDENTITY)
@Column(name = "codigo", unique = true, nullable = false)
private int codigo;
@Column(name = "nombre", nullable = false)
private String nombre;
@Column(name = "siglas", nullable = false)
private String siglas;
@OneToMany(fetch = FetchType.LAZY, mappedBy = "tipoIdentificacion")
private Set<Persona> persona = new HashSet<Persona>(0);
“Persona”的主键是“codigo”,“TipoIdentificacion”的主键是“codigo”,它是来自角色的 FK (codTipoIdent)
一切看起来都很好,我在我的网络应用程序中做了一个非常好的事情,但是当我调试它以请求“TipoIdentificacion”列表时,它看起来像
它会循环,为什么?