Polymorphic Configuration Bug?

21 views
Skip to first unread message

Ibrahim Arief

unread,
Feb 14, 2013, 11:41:38 AM2/14/13
to twig-p...@googlegroups.com
Hi John,


I'm trying to use the polymorphic embed on my entities, with the following class structures:

public class A
{
    @Embedded( polymorphic = true )
    private List<B> bees;
}

public interface B
{
}

@Entity( polymorphic = true)
public class C implements B
{
}


However, the persisted entities does not seem to have the class defined as one of their property, causing the decode process to throw an "java.lang.IllegalArgumentException: Could not find no args constructor in interface B."

After going through the debugger, I think the "polymorphic(Class<?> instance)" method in AnnotationConfiguration did a mistake in extracting the annotation out of the class. I extended the configuration class, and override the method from the previous implementation:

Entity annotation = instance.getClass().getAnnotation(Entity.class);

to

Entity annotation = instance.getAnnotation(Entity.class);

And it works as I expected, I could persist and load the A entity without any problem. I use Twig 2.0 beta 5, but checking the latest codebase, it appears that the method's implementation is still the same.

So my question would be, is this an inadvertent bug? Or does I use the @Embedded and @Entity annotations incorrectly? If it is the latter, what would be the recommended structure to persist an object with a list of interfaces as its member?

Kind Regards,
Ibam

John Patterson

unread,
Feb 17, 2013, 3:41:52 PM2/17/13
to twig-p...@googlegroups.com
Wow thanks that was a very obvious bug!

--
You received this message because you are subscribed to the Google Groups "twig-persist" group.
To unsubscribe from this group and stop receiving emails from it, send an email to twig-persist...@googlegroups.com.
For more options, visit https://groups.google.com/groups/opt_out.
 
 

Reply all
Reply to author
Forward
0 new messages