IBM Support

PH02992: ECLIPSELINK: ADD SUPPORT FOR NULL FOREIGNKEYS WITH UNIDIRECTIONAL ONETOMANY RELATIONSHIP

Subscribe

You can track all active APARs for this component.

 

APAR status

  • Closed as program error.

Error description

  • EclipseLink performs an INSERT followed by an UPDATE when
    persisting a unidirectional OneToMany mapping. However, if the
    mapping is not nullable, EclipseLink attempts to INSERT a null
    value, causing a SQLIntegrityConstraintViolationException.
    

Local fix

  • N/A
    

Problem summary

  • ****************************************************************
    * USERS AFFECTED:  All users of IBM WebSphere Application      *
    *                  Server Liberty - Java Persistence APA -     *
    *                  JPA 2.1 & EclipseLink                       *
    ****************************************************************
    * PROBLEM DESCRIPTION: EclipseLink attempts to INSERT NULL     *
    *                      values for Unidirectional @OneToMany    *
    *                      relationships that are                  *
    *                      'nullable=false'                        *
    ****************************************************************
    * RECOMMENDATION:                                              *
    ****************************************************************
    Example:
    @Entity @Table(name="COMMENT")
    public class Comment {
    @Id @Column(name="COMMENT_PK", nullable=false, updatable=false)
    private Long id;
    }
    @Entity @Table(name = "POST")
    public class Post {
    @Id
    @Column(name = "POST_PK", nullable = false, updatable = false)
    private Long id;
    @OneToMany(cascade = CascadeType.ALL, orphanRemoval = true)
    @JoinColumn(name = "POST_FK", nullable = false)
    private List<Comment> comments;
    }
    Observe that the @JoinColumn on POST annotates a OneToMany
    Unidirectional relationship with COMMENT. Also, this
    relationship describes the foreign key (POST_FK) as
    'nullable=false'
    Exception:
    [EL Warning]: 2018-05-16
    11:37:44.234--UnitOfWork(-427968753)--
    Thread(Thread[main,5,main]
    )--Local Exception Stack:
    Exception [EclipseLink-4002] (Eclipse Persistence Services -
    2.6.6.WAS):
    org.eclipse.persistence.exceptions.DatabaseException
    Internal Exception:
    java.sql.SQLIntegrityConstraintViolationException: Column
    'POST_FK'  cannot accept a NULL value.
    Error Code: 20000
    Call: INSERT INTO COMMENT (COMMENT_PK) VALUES (?)
    bind => [3]
    Query: InsertObjectQuery(model.Comment@8a02a358)
    at
    org.eclipse.persistence.exceptions.DatabaseException.sqlExceptio
    n(DatabaseException.java:331)
    at
    org.eclipse.persistence.internal.databaseaccess.DatabaseAccessor
    .executeDirectNoSelect(DatabaseAccessor.java:902)
    EclipseLink is attempting to INSERT into the COMMENT table as
    value of NULL for POST_FK. The table was created with 'NOT
    NULL', so this violates the contraint on this column and
    throws an exception.
    

Problem conclusion

Temporary fix

Comments

APAR Information

  • APAR number

    PH02992

  • Reported component name

    WEBS APP SERV N

  • Reported component ID

    5724H8800

  • Reported release

    900

  • Status

    CLOSED PER

  • PE

    NoPE

  • HIPER

    NoHIPER

  • Special Attention

    NoSpecatt / Xsystem

  • Submitted date

    2018-09-19

  • Closed date

    2018-12-10

  • Last modified date

    2018-12-10

  • APAR is sysrouted FROM one or more of the following:

  • APAR is sysrouted TO one or more of the following:

Fix information

  • Fixed component name

    WEBS APP SERV N

  • Fixed component ID

    5724H8800

Applicable component levels

  • R900 PSY

       UP

[{"Business Unit":{"code":"BU053","label":"Cloud \u0026 Data Platform"},"Product":{"code":"SSEQTP","label":"WebSphere Application Server"},"Platform":[{"code":"PF025","label":"Platform Independent"}],"Version":"900","Line of Business":{"code":"LOB36","label":"IBM Automation"}}]

Document Information

Modified date:
16 October 2021