How to add one element to collection without loading?
avihai marchiano
Ranch Hand
Joined: Jan 10, 2007
Posts: 342
posted
0
Hey,
Lets say i have - Department Department has a List of Emploee (@OneToMany).
I want to add one emploee to the list withot loading the whole collection.
department.getEmployee().add(emploee) will load the collection and it is bad if i have a big collection.
Thank you
Mike Keith
author
Ranch Hand
Joined: Jul 14, 2005
Posts: 304
posted
0
Well in theory, assuming the OneToMany from Department to Employee is lazy and you have not accessed or triggered the employees relationship, then if you just set the ManyToOne from your Employee to its department and commit then you should accomplish what you want. No guarantees, though, since different vendors may do different things with caching, etc.