Over a million developers have joined DZone.

No Subclass Matches This Class; for This Aggregate Mapping With Inheritance

· Java Zone

Learn more about Kotlin, a new programming language designed to solve problems that software developers face every day brought to you in partnership with JetBrains.

No subclass matches this class [class com.baselogic.test.CustomerFixture$2$1] for this Aggregate mapping with inheritance. I have been writing a chapter for my new book “Java EE6 Cookbook for Securing, Tuning and Extending Enterprise applications” today, and I ran across an interesting error based on a JPA testing pattern.

I have used 2 patterns for seeding data to test some @CollectionTable functionality.
First, I used DBUnit to seed my data, and that seems to work just fine for adding @CollectionTable relationships.

The second seemed fairly straight forward. I wanted to create a Fixture utility to create an entity to insert

Customer customer = CustomerFixture.createSingleCustomer();

My CustomerFixture.createSingleCustomer() is fairly simple

public static Customer createSingleCustomer() {
Customer customer = new Customer();
customer.setDescription("Customer with an Android Device.");
new HashSet<String>() {{

return customer;


I was adding Address’s that looked like this

public static Map<String, Address> createAddresses() {
final int pk = getRandomInt(1, 999);
return new HashMap<String, Address>() {{
put(String.format("%03d", pk),
new Address(){{
setStreet("123 Main Street");
setCity("San Francisco");


Notice that I created the Address with a default constructor…?

When running this, I get a very interesting exception:

Exception Description: No subclass matches this class [class com.baselogic.test.CustomerFixture$2$1] for this Aggregate mapping with inheritance.
Mapping: org.eclipse.persistence.mappings.AggregateCollectionMapping[addresses]
Descriptor: RelationalDescriptor(com.baselogic.chapter02.Customer --> [DatabaseTable(CUSTOMER)])

What I finally tracked this down to was from skimming the XXX codes on http://wiki.eclipse.org/EclipseLink_Exception_Error_Reference_%28ELUG%29

ECLIPSELINK-00068: The value of an aggregate in object [{0}] is null. Null values not allowed for Aggregate mappings unless “Allow Null” is specified.
Cause: The value of the aggregate in the source object object is null. Null values are not allowed for aggregate mappings unless allow null is specified in the aggregate mapping.
Action: Call the mapping method allowNull. Provide parameters only if you are making a distinction between foo() and foo(integer).

Specifically the ‘Action’.
So I started looking at my Fixture, and constructed my Address with a specific Constructor:

public static Map<String, Address> createAddresses(){
final int pk = getRandomInt(1, 999);
return new HashMap<String, Address>(){{
put(String.format("%03d", pk),
new Address(
"123 Main Street",
"San Francisco",

This solved the issue, and the seeding of the Customer succeeded.

From http://www.baselogic.com/blog/development/java-javaee-j2ee/no-subclass-matches-this-class-for-this-aggregate-mapping-with-inheritance

The Java Zone is brought to you in partnership with JetBrains.  Discover how powerful static code analysis and ergonomic design make development not only productive but also an enjoyable experience.


{{ parent.title || parent.header.title}}

{{ parent.tldr }}

{{ parent.urlSource.name }}