We know primary key of associated object and we need to put it into my entity bean.
For example: entity Tour contains entity Destination.
In first step we import all Destinations from text file with loaded xguid as primary key.
In second step we import Tours (there is Destionation xguid too).
Does exist some way how to insert Destination into new Tours without loading Destination?
Correct way with load is:
Destination d = em.find(Destination.class,xguid); Tour t = new Tour(); t.setDestination(d);
Destination d = new Destination(); d.setId(xguid); Tour t = new Tour(); t.setDestination(d);
using the underlying Hibernate session API, you can use session.load(class, id); it will actually not load the object from the DB but give you a proxy