I am using Hibernate Implementation of JPA with Spring.
Class Country{
@OneToMany(mappedBy="Country", cascade = CascadeType.ALL, fetch = FetchType.LAZY)
List<State> stateList;
@OneToOne(cascade = CascadeType.ALL)
@JoinColumn(name = "Current_State_ID")
State currnetState;
}
State stateObj = new State();
country.getStateList().add(stateObj);
country.setCurrnetState(stateObj);
This creates 2 entries for in State Table, which messes up my logic. Can someone please point me what I am doing worng.
Aucun commentaire:
Enregistrer un commentaire