Hi all, look this code:
// In A.java class
@OneToMany(mappedBy="a", fetch=FetchType.EAGER)
@Cascade(CascadeType.SAVE_UPDATE)
private List<B> bList;
// In B.java class
@ManyToOne(fetch=FetchType.LAZY)
@JoinColumn(name="id_a")
@Cascade(CascadeType.SAVE_UPDATE)
private A a;
And this is my record in DB tables.
// Table A
| ID | other column . . . |
| 1 | . . . |
//Table B
| ID | ID_A | other column . . . |
| 1 | 1 | . . . |
| 2 | 1 | . . . |
Now, i try to build a criteria to obtain all A records, int his case one!
List<A> aList=session.createCriteria(A.class).list();
The problem is this code return two rendundant records! One foreach record in B.
How can i resolve without change my fetchtype to LAZY?
Thanks.