Good Morning, I just added this to fix the problem I was having, but I figured it would be pretty unlikely somebody would have a deep enough class inheritance to cause a problem.
Anyway, attached is a loop implementation... Mike On Mon, May 25, 2009 at 5:07 AM, Geert Bevin <gbe...@terracottatech.com> wrote: > Ah, I glanced over that then. Would probably be better to convert it to a > loop instead of recursion though. > > -- > Geert Bevin > Terracotta - http://www.terracotta.org > Uwyn "Use what you need" - http://www.uwyn.com > RIFE Java application framework - http://rifers.org > Music and words - http://gbevin.com > On 25 May 2009, at 13:05, Alex Snaps <asn...@terracottatech.com> wrote: > > Hi, > Geert, as I see it from the unapplied patch, I think > getSuperFields(List<Field>, Class): void is actually recursive. > Though I also was wondering up until where we should walk up the hierachy... > Had that one also in my current working copy, but together with all the > other mess I was working on (and should get started again, sometime!). > Thanks for the involvement, > Alex > > On Mon, May 25, 2009 at 11:25 AM, Geert Bevin <gbe...@terracottatech.com> > wrote: >> >> Hi Mike, >> >> Thanks a lot for your patch, seems very useful. I'm wondering about >> making one small change. >> >> You currently only include the fields of the direct super class. It >> would probably be useful to walk up the entire hierarchy until it hits >> a standard java class and include all the fields of those super >> classes too. What do you think? >> >> Best regards, >> >> Geert >> >> On 25 May 2009, at 05:28, Mike Johnson wrote: >> >> > Hello, >> > >> > I have a simple patch here for Pojoizer against svn trunk. All it does >> > is add super class fields to the array for copying. >> > >> > I'm just learning Hibernate but it appears interfaces aren't >> > supported, so this patch doesn't consider them. >> > >> > Thanks, >> > Mike >> > <pojoizer-super.patch>_______________________________________________ >> > tc-dev mailing list >> > tc-dev@lists.terracotta.org >> > http://lists.terracotta.org/mailman/listinfo/tc-dev >> >> -- >> Geert Bevin >> Terracotta - http://www.terracotta.org >> Uwyn "Use what you need" - http://uwyn.com >> RIFE Java application framework - http://rifers.org >> Flytecase Band - http://flytecase.be >> Music and words - http://gbevin.com >> >> _______________________________________________ >> tc-dev mailing list >> tc-dev@lists.terracotta.org >> http://lists.terracotta.org/mailman/listinfo/tc-dev > > > > -- > Alex Snaps > http://www.jroller.com/page/greenhorn > http://www.linkedin.com/in/alexandersnaps > > _______________________________________________ > tc-dev mailing list > tc-dev@lists.terracotta.org > http://lists.terracotta.org/mailman/listinfo/tc-dev > > _______________________________________________ > tc-dev mailing list > tc-dev@lists.terracotta.org > http://lists.terracotta.org/mailman/listinfo/tc-dev > >
Index: src/main/java/org/terracotta/pojoizer/DetachedBean.java =================================================================== --- src/main/java/org/terracotta/pojoizer/DetachedBean.java (revision 15914) +++ src/main/java/org/terracotta/pojoizer/DetachedBean.java (working copy) @@ -7,6 +7,10 @@ import java.lang.reflect.Field; +import java.util.ArrayList; +import java.util.Arrays; +import java.util.List; + import javassist.Modifier; import org.terracotta.pojoizer.exceptions.PojoizerException; @@ -23,7 +27,16 @@ private DetachedBean(final T attached, final T detached) { super(attached, detached); - fields = attached.getClass().getDeclaredFields(); + List<Field> list = new ArrayList<Field>(); + list.addAll(Arrays.asList(attached.getClass().getDeclaredFields())); + + Class superClass = attached.getClass(); + while((superClass = superClass.getSuperclass()) != null) + list.addAll(Arrays.asList(superClass.getDeclaredFields())); + + fields = new Field[list.size()]; + list.toArray(fields); + advanceToNextUsableField(); }
_______________________________________________ tc-dev mailing list tc-dev@lists.terracotta.org http://lists.terracotta.org/mailman/listinfo/tc-dev