I am performing some tests with SpringData and Hibernate and found some interesting behavior on lazy loading and findBy... methods.
I have the following method on a child class.
List findByArtistCredit(Long artistCreditId);
and the following mapping between Recording and ArtistCredit...
@ManyToOne(fetch=FetchType.LAZY)
@JoinColumn(name="artist_credit" , referencedColumnName="artist_credit_id")
private ArtistCredit artistCreditReference;
on the "One" side...
@OneToMany(fetch=FetchType.LAZY,mappedBy="artistCreditReference")
private Set<Recording> recordings;
And what happens is that the collection on the "Many side" is being eagerly fetched...
Does anyone know "why is happening?"
Any answer is wellcome.
Regards.
Aucun commentaire:
Enregistrer un commentaire