Hibernate version: 2.1.7
I'm working on a multi layer app with JBoss/Hibernate.
I found some examples getting children items of an entity
with a lazy loading association : i made a business method to reattach the entity to a new hibernate session for getting children --> works fine!
The problem is i found nothing about filling a new hibernate set to create associations for a new entity
with lazy loading. I would like to create a business method like that :
Code:
public void setChildrenToEntity(HashSet set,Entity entity)
{
Session session = HibernateUtils.getHibernateSession();
session.lock(entity,LockMode.READ);
net.sf.hibernate.collection.Set children = new net.sf.hibernate.collection.Set()
children.addAll(set)
entity.setChildren(children)
}
where am i wrong in my code? what's the best practice?
thanks in advance!