Hello,
I posted the following in the EclipseLink-Forum, where apparently nobody was able to help me. So I repost my question in the Dali-Forum, as the Bug actually shows itself, using the Dali Table Generation. Maybe someone here can help me. Here is my original post:
I have an @Embeddable class (let's call it EmbeddableParent). EmbeddableParent is subclassed by another class, also annotated with @Embeddable (let's call this class EmbeddableChild). EmbeddableParent also embeds a third class EmbeddableC. To clear things up, a piece of sample code:
@Embeddable
public class EmbeddableC implements Serializable {
private String stringA;
private String stringB;
...
}
@Embeddable
public class EmbeddableParent implements Serializable {
@Embedded
private EmbeddableC embedded;
...
}
@Embeddable
public class EmbeddableChild extends EmbeddableParent implements Serializable {
...
}
I now used the DescriptorCustomizer and InheritancePolicy to make inheritance for Embeddables work, as suggested by en.wikibooks.org/wiki/Java_Persistence/Embeddables#Inheritance (Apparently I cannot post links, unless I have posted more than 5 messages.).
The code I wrote looks like this:
@Customizer(EmbeddableParent.class)
@Embeddable
public class EmbeddableParent implements Serializable, DescriptorCustomizer {
@Embedded
private EmbeddableC embedded;
...
@Override
public void customize(ClassDescriptor descriptor) throws Exception {
descriptor.getInheritancePolicy().setSingleTableStrategy();
DatabaseField indicatorField = new DatabaseField();
indicatorField.setName("QTYPE");
indicatorField.setLength(20);
indicatorField.setType(java.lang.String.class);
descriptor.getInheritancePolicy().setClassIndicatorField(indicatorField);
descriptor.getInheritancePolicy().useClassNameAsIndicator();
}
}
@Embeddable
@Customizer(EmbeddableChild.class)
public class EmbeddableChild extends EmbeddableParent implements Serializable, DescriptorCustomizer {
...
@Override
public void customize(ClassDescriptor descriptor) {
descriptor.getInheritancePolicy().setParentClass(EmbeddableParent.class);
}
}
Using this code, generation of tables from entities fails with a NullPointerException:
java.lang.NullPointerException
at org.eclipse.persistence.descriptors.InheritancePolicy.updateTables(InheritancePolicy.java:1847)
1847 Vector<DatabaseTable> parentTables = getParentDescriptor().getTables();
java.lang.NullPointerException
at org.eclipse.persistence.descriptors.InheritancePolicy.postInitialize(InheritancePolicy.java:1122)
1121 ClassDescriptor parent = getParentDescriptor();
1122 if (parent.hasPreDeleteMappings()) {
It seems, parentDescriptor is not set correctly. What am I doing wrong? Did I miss something? Or is it a bug? Any help is appreciated.