Ibrahim Arief
unread,Feb 14, 2013, 11:41:38 AM2/14/13Sign 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 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