0

i'm new to hibernate and i use annotations

These are my two tables:

enter image description here

This is my Table "Persona"

 @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;

    ....

This is my second table "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);

the primary Key of "Persona" is "codigo" and for "TipoIdentificacion" is "codigo" wich is FK from persona (codTipoIdent)

everything looks fine, also i made a crud in my web app really well, but when i debug it for request a list of "TipoIdentificacion" it looks like

enter image description here

it make a loop, why?

MitoCode
  • 319
  • 2
  • 10
  • 25
  • 1
    You have two cars. The cars owner is you. And you have two cars. And the cars owner is you. And you have two cars... It's completely expected when you have a *bidirectional* association. – JB Nizet Apr 22 '14 at 16:14
  • yes i know more of that now, thanks =) I appreciate it. – MitoCode Apr 22 '14 at 17:27

0 Answers0