Setting Embeddable That Contains A Relationship To Null Throws DescriptorException Exception

(Doc ID 1464649.1)

Last updated on SEPTEMBER 21, 2017

Applies to:

Oracle TopLink - Version 11.1.1.5.0 to 12.1.1.0 [Release Oracle11g to 12c]
Information in this document applies to any platform.

Symptoms


There is a Many-to-One relationship in an Embeddable object.

Using TopLink 11.1.1.5 version, when a call to entity.setEmbeddable(null) is made, the following  exception happens :

Caused by: Exception [EclipseLink-68] (Eclipse Persistence Services - 2.1.2.v20101206-r8635): org.eclipse.persistence.exceptions.DescriptorException

Exception Description: The value of an aggregate in object [domain.de3537.ContainerPackage@16fdac] is null. Null values not allowed for Aggregate mappings unless "Allow Null" is specified.

Mapping: org.eclipse.persistence.mappings.AggregateObjectMapping[volume]
Descriptor: RelationalDescriptor(domain.de3537.ContainerPackage --> [DatabaseTable(TLG_DE3537_CNTRPKG)])

javax.persistence.RollbackException: Exception [EclipseLink-68] (Eclipse Persistence Services - 2.3.2.v20111125-r10461): org.eclipse.persistence.exceptions.DescriptorException
Exception Description: The value of an aggregate in object [domain.de3537.ContainerPackage@16fdac] is null. Null values not allowed for Aggregate mappings unless "Allow Null" is specified.

Mapping: org.eclipse.persistence.mappings.AggregateObjectMapping[volume]
Descriptor: RelationalDescriptor(domain.de3537.ContainerPackage --> [DatabaseTable(TLG_DE3537_CNTRPKG)])
    at org.eclipse.persistence.internal.jpa.transaction.EntityTransactionImpl.commitInternal(EntityTransactionImpl.java:102)
    at org.eclipse.persistence.internal.jpa.transaction.EntityTransactionImpl.commit(EntityTransactionImpl.java:63)


Also, this issue occurs with Toplink 11.1.1.6 and 12.1.1 versions.

Changes

 See the following JavaDoc link for an important note on Aggregate usage:
  http://www.eclipse.org/eclipselink/api/2.3/org/eclipse/persistence/mappings/AggregateObjectMapping.html
 
 and note that  "Any aggregate that has a relationship mapping automatically does not  allow null" .

public void allowNull()
 
 PUBLIC: If all the fields in the database row for the aggregate object are NULL, then, by default, the mapping will place a null in the appropriate source object (as opposed to an aggregate object filled with nulls).

This behavior can be explicitly set by calling #allowNull(). To change this behavior, call #dontAllowNull(). Then the mapping will build a new instance of the aggregate object that is filled with nulls and place it in the source object.

In either situation, when writing, the mapping will place a NULL in all the fields in the database row for the aggregate object.

Note: Any aggregate that has a relationship mapping automatically does not allow null.

Cause

Sign In with your My Oracle Support account

Don't have a My Oracle Support account? Click to get started

My Oracle Support provides customers with access to over a
Million Knowledge Articles and hundreds of Community platforms