I have add "A in B" and "B in A" for hibernate save correctly their FK in database, for example in this code:
Code:
miembro.setAsociacion(asociacion);
asociacion.setMiembros(miembros);
asociacionBo.save(asociacion)
;
the result is :
- One row in database representing association
- One row in database representing member (with FK association add)
In this code:
Code:
//miembro.setAsociacion(asociacion);
asociacion.setMiembros(miembros);
asociacionBo.save(asociacion);
the result is:
- One row in database representing association
- One row in database representing member (without FK association add)
this is associationĀ“s mapping:
Code:
@OneToMany(mappedBy="asociacion",cascade=CascadeType.ALL,fetch=FetchType.EAGER,orphanRemoval=true)
private Set<Miembro> miembros;
this is memberĀ“s mapping:
Code:
@ManyToOne
@JoinColumn(name="IDASOCIACION",referencedColumnName="IDASOCIACION")
private Asociacion asociacion;
I thought that pesistence since Asociation was in cascade and when hibernate insert asociation row,hibernate insert row member with FK asociation but it dont work in this way.
I dont understand why.
somebody can explain this behavior?
Kind regards.