probleme with recursively object

7 views
Skip to first unread message

waldo2188

unread,
Nov 24, 2009, 12:35:36 PM11/24/09
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

Hanson Char

unread,
Nov 25, 2009, 2:39:58 AM11/25/09
to bea...@googlegroups.com
The code looks reasonable to me.  What do you mean by "the copy method kills the code systematically" ?  What is the question or what are you trying to do ? 

Hanson
Reply all
Reply to author
Forward
0 new messages