I have the two entities similar to the ones below:
@Entity
@DynamicUpdate
public class EntityOne {
@Id
public long id;
public String name;
public String displayName;
@JsonManagedReference
@OneToMany(mappedBy = "id", cascade = CascadeType.ALL)
@OrderBy(value = "name")
public List<EntityTwo> entityTwoList;
}
entity two is
@Entity
@DynamicUpdate
public class EntityTwo {
@Id
public long id;
@JsonBackReference
@ManyToOne
@JoinColumn(name = "id")
public EntityOne entityOne;
}
service:
Lists.newArrayList(repository.findAll());
The service calls the findAll() method of the CRUDRepository. I don't want the list of entity two objects to load when calling findall() but this solution doesn't work. Anything incorrect that i am doing here to lazy load the collection. I basically don't want the collection to be loaded until its specified.
By default the mappings are lazy load.