waldo2188
unread,Nov 24, 2009, 12:35:36 PM11/24/09Sign in to reply to author
Sign in to forward
You do not have permission to delete messages in this group
Either email addresses are anonymous for this group or you need the view member email addresses permission to view the original message
to beanlib
Hey everyone,
I use Beanlib in a GWT project to detach an object from Hibernate.
This is very simple, except when the item contains a list of objects
that refer to the first. In this case the object is called recursively
and it did finally completed more ...
A small example?!
_____
public class A {
private long id;
private List<B> bs;
....
}
public class B {
private long id;
private A a;
....
}
public class objetADao() {
public A getA(idDeA) {
Session session = sessionFactory.getCurrentSession();
Criteria crit = session.createCriteria(A.class);
crit.add(Restrictions.eq("id", idDeA) );
A a = (A) crit.uniqueResult();
Class<?>[] entityClasses = { A.class, B.class };
Set<Class<?>> entityClassSet = new HashSet<Class<?>>(Arrays.asList
(entityClasses));
CollectionPropertyName<?>[] colProps = {
new CollectionPropertyName(A.class, "bs")
};
Set<? extends CollectionPropertyName<?>> collectionPropertyNameSet =
new HashSet<CollectionPropertyName<?>>(Arrays.asList(colProps));
HibernateBeanReplicator r = new Hibernate3BeanReplicator
(entityClassSet, collectionPropertyNameSet, null);
a = r.deepCopy(a);
return a;
}
}
_____
in the example I use the method deepCopy because the copy method kills
the code systematically.
I really don't understand how it works.
Thank you for your help in advance!
waldo2188