Added...

On Mon, May 25, 2009 at 9:03 AM, Geert Bevin <gbe...@terracottatech.com> wrote:
> Yeah, walk up until a standard java package is hit java. or javax.
>
> On 25 May 2009, at 14:52, Alex Snaps wrote:
>
>> Indeed. Should anyone actually do things like this, I'd love it to
>> break...
>> So we can get more explanation on the use case ;-)
>>
>> On Mon, May 25, 2009 at 2:33 PM, Alex Miller <amil...@terracottatech.com
>> > wrote:
>> I think I would aim for covering the cases we know about (grabbing
>> fields from super classes you wrote yourself) and not speculate
>> about cases you can invent but have never seen (like possibly
>> extending from Date).
>>
>> ----- Original Message -----
>> From: "Alex Snaps" <alex.sn...@gmail.com>
>> To: tc-dev@lists.terracotta.org
>> Sent: Monday, May 25, 2009 7:24:11 AM GMT -06:00 US/Canada Central
>> Subject: Re: [tc-dev] Pojoizer patch for super class fields
>>
>>
>> That and to what level...
>> While a none-MappedSuperclass can hardely have mapped fields, some
>> callback methods could still change some field... So the question is
>> should we walk up the entire hierarchy or until we hit some
>> java(x).* packaged class? Sort of unclear to me so far (Would
>> someone write and map a Day extends java.util.Date class?!.. and go
>> through the burden of having the unmapped superclass fields
>> maintained properly through callback?!)
>> I'm writing this out of the top of my head right now... But if
>> someone has an opinion, I'd happily hear it ;)
>> Alex
>>
>>
>> On Mon, May 25, 2009 at 2:07 PM, 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
>>
>>
>>
>>
>> --
>> Alexander Snaps < alex.sn...@gmail.com >
>> 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
>>
>>
>>
>> --
>> Alexander Snaps <alex.sn...@gmail.com>
>> 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
>
> --
> 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
>
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,20 @@
   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) {
+      String pack = superClass.getPackage().getName();
+      if(pack.startsWith("java.") || pack.startsWith("javax."))
+        break;
+      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

Reply via email to