Let's say I have a Hibernate object that declares OneToMany relation to another object:
@Entity public class SomeEntity { @OneToMany(fetch = FetchType.LAZY) private List<OtherEntity> otherEntities = new LinkedList<OtherEntity>(); [...] }
When matching SomeEntity with the corresponding DTO, all I need is identifiers that identify OtherEntity as the primary key (i.e., I am not actually interested in OtherEntity instances).
Does Hibernate support this pattern, i.e. retrieves only the identifiers of the objects referenced by the OneToMany ?
I canβt influence how SomeEntity restored (i.e. I have an existing SomeEntity instance obtained within te area of ββthe current Hibernate session), but suppose that lazy loading has not yet taken place, so just get the identifiers of the child objects (and incomplete objects) will actually benefit performance.
source share