Skip to main content



      Home
Home » Eclipse Projects » Dali » Table Generation from Entities with Embeddable Inheritance
Table Generation from Entities with Embeddable Inheritance [message #725412] Wed, 14 September 2011 13:42 Go to next message
Eclipse UserFriend
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.
Re: Table Generation from Entities with Embeddable Inheritance [message #727587 is a reply to message #725412] Wed, 21 September 2011 11:18 Go to previous message
Eclipse UserFriend
I would follow up with James back on the EclipseLink forum. They should be able to help you figure out the problem. My guess is that he was waiting to hear back from you.

Neil
Previous Topic:long & BigDecimal mappings in entities from tables
Next Topic:validation error
Goto Forum:
  


Current Time: Tue Jul 08 00:29:48 EDT 2025

Powered by FUDForum. Page generated in 0.03509 seconds
.:: Contact :: Home ::.

Powered by: FUDforum 3.0.2.
Copyright ©2001-2010 FUDforum Bulletin Board Software

Back to the top