I have created a simple Spring boot project with Spring data.
I have a TagGroup Entity which has one to many relation with Tags.
@Entity
@Table(name = "TAG_GROUP")
public class TagGroup{
@OneToMany(fetch=FetchType.LAZY,mappedBy = "tagGroup")
private Set<Tag> tagList;
}
The Tag Entity is as below
@Entity
@Table(name = "TAGS")
public class Tag {
@ManyToOne(optional = false,fetch=FetchType.LAZY)
@JoinColumn(name = "TAG_GROUP_ID")
private TagGroup tagGroup;
}
I am using Spring data extending the JPArepository and using its findAll method.
The problem , the Lazy fetch doesn't work BUT Infact it is loading the tag list also without calling the tagList explicitly as If it is EAGER...
Can anybody please tell me what I am doing wrong here ?