I use spring data, jpa and hibernate
I have a Advertisement class
@Entity
public class Advertisement implements Serializable {
@Id
@GeneratedValue(strategy = GenerationType.AUTO)
private Long id;
@OneToMany(mappedBy="id", cascade={CascadeType.REMOVE}, fetch=FetchType.LAZY)
private Set<Message> messages = new HashSet<Message>();
}
and a message class
@Entity
public class Message implements Serializable {
@Id
@GeneratedValue(strategy = GenerationType.AUTO)
private Long id;
@ManyToOne(fetch = FetchType.LAZY)
private Advertisement advertisement;
}
when i search an Advertisement by id, i can see all their message... i don't understand why, i put lazy...
I search a way to load Advertisement without message.