Hi Tom.
Thanks for your reply.
The different between void load() function in hibernate and getReference in JPA is,
Load()
will directly read the loaded entity into the input param without any return value,
but
getReference() or find()
just return the entity as the return value.....
We use a lot in our base entity ,
PersistenceEntity.class
public void load() {
org.hiberntae.session.load(this,
this.id);//support in hibernate,change the entity itself
}
so we could use :
User user = new User();
user.setId(1L);
user.load(); //user will be the entity loaded by ORM
and now if use getReference()
PersistenceEntity.class
public void load() {
Object object = javax.persistence.EntityManager.getReference(this.getClass,
this.id);
setObjectToThis(); //this = object
}
How to set Object value to this.
solution : copy bean by BeanUtil ,cglib copier or java reflect
risk: but does this safety , for lazy load entity with proxy.
or any better solution......
But the disaster is from we use the void load() api.....
--
BR,
Ajax