IBM Support

PI55889: JPA Merge fails intermittently with FOREIGN KEY constraint error

Fixes are available

8.5.5.10: WebSphere Application Server V8.5.5 Fix Pack 10
8.5.5.11: WebSphere Application Server V8.5.5 Fix Pack 11
16.0.0.2: WebSphere Application Server Liberty 16.0.0.2
16.0.0.3: WebSphere Application Server Liberty 16.0.0.3
16.0.0.4: WebSphere Application Server Liberty 16.0.0.4
8.5.5.12: WebSphere Application Server V8.5.5 Fix Pack 12
8.5.5.13: WebSphere Application Server V8.5.5 Fix Pack 13
17.0.0.1: WebSphere Application Server Liberty 17.0.0.1
17.0.0.2: WebSphere Application Server Liberty 17.0.0.2
17.0.0.3: WebSphere Application Server Liberty 17.0.0.3
17.0.0.4: WebSphere Application Server Liberty 17.0.0.4
18.0.0.1: WebSphere Application Server Liberty 18.0.0.1
18.0.0.2: WebSphere Application Server Liberty 18.0.0.2
8.5.5.14: WebSphere Application Server V8.5.5 Fix Pack 14
18.0.0.3: WebSphere Application Server Liberty 18.0.0.3
18.0.0.4: WebSphere Application Server Liberty 18.0.0.4
19.0.0.1: WebSphere Application Server Liberty 19.0.0.1
8.5.5.15: WebSphere Application Server V8.5.5 Fix Pack 15
19.0.0.2: WebSphere Application Server Liberty 19.0.0.2
19.0.0.3: WebSphere Application Server Liberty 19.0.0.3
19.0.0.4: WebSphere Application Server Liberty 19.0.0.4
19.0.0.5: WebSphere Application Server Liberty 19.0.0.5
19.0.0.6: WebSphere Application Server Liberty 19.0.0.6
19.0.0.7: WebSphere Application Server Liberty 19.0.0.7
19.0.0.8: WebSphere Application Server Liberty 19.0.0.8
19.0.0.9: WebSphere Application Server Liberty 19.0.0.9
19.0.0.10: WebSphere Application Server Liberty 19.0.0.10
19.0.0.11: WebSphere Application Server Liberty 19.0.0.11
19.0.0.12: WebSphere Application Server Liberty 19.0.0.12
20.0.0.1: WebSphere Application Server Liberty 20.0.0.1
20.0.0.2: WebSphere Application Server Liberty 20.0.0.2
8.5.5.17: WebSphere Application Server V8.5.5 Fix Pack 17
20.0.0.3: WebSphere Application Server Liberty 20.0.0.3
20.0.0.4: WebSphere Application Server Liberty 20.0.0.4
20.0.0.5: WebSphere Application Server Liberty 20.0.0.5
20.0.0.6: WebSphere Application Server Liberty 20.0.0.6
20.0.0.7: WebSphere Application Server Liberty 20.0.0.7
20.0.0.8: WebSphere Application Server Liberty 20.0.0.8
20.0.0.9: WebSphere Application Server Liberty 20.0.0.9
20.0.0.10: WebSphere Application Server Liberty 20.0.0.10
20.0.0.11: WebSphere Application Server Liberty 20.0.0.11
20.0.0.12: WebSphere Application Server Liberty 20.0.0.12
8.5.5.20: WebSphere Application Server V8.5.5.20
8.5.5.18: WebSphere Application Server V8.5.5 Fix Pack 18
8.5.5.19: WebSphere Application Server V8.5.5 Fix Pack 19
8.5.5.16: WebSphere Application Server V8.5.5 Fix Pack 16
8.5.5.21: WebSphere Application Server V8.5.5.21

Subscribe

You can track all active APARs for this component.

 

APAR status

  • Closed as program error.

Error description

  • The following errors are seen.
    
    JPA Merge issue for nested parent child relationships
    
    Look out for String - "The INSERT statement conflicted with the
    FOREIGN KEY constraint "FK_Address_Contact".
    
    
    As said earlier, this error is intermittent, so hard to
    replicate. It  occurs under load for similar type of message.
    
    The errors occurs when we have Parent-->Paren1
    (Child of Parent)-->Child1(Child of Parent1)
    kind of relationship in the objects.
    
    [9/8/15 20:28:08:391 EDT] 0000032c LocalExceptio E
    CNTR0020E: EJB threw an unexpected (non-declared) exception
    during invocation of method "onMessage" on bean
    
    
    "BeanId(updateService#pdateService.jar#UpdateListen er,
    null)". Exception data:
    
    com.xx.xx.exception.ApplicationListenerException:
    
    javax.ejb.EJBTransactionRolledbackException: nested exception
    is:
    javax.ejb.EJBException: See nested exception; nested exception
    is:
    com.xx.xxx.exception.XXXPersistenceException:
    
    <openjpa-2.2.3-SNAPSHOT-r422266:1564471 fatal store error>
    
    org.apache.openjpa.persistence.EntityExistsException: The
    transaction has been rolled back.  See the nested exceptions
    for details on
    the  errors that occurred.
    
    
    FailedObject: com.XX.XXXX.entities.Address@7a85d521
    at
    
    com.XX.XXX.listener.XXUpdateListener.onMessage(XXXUpdateLis
    tener.ja va:66)
    
    
    Begin backtrace for Nested Throwables
    
    com.microsoft.sqlserver.jdbc.SQLServerException: The INSERT
    statement conflicted with the FOREIGN KEY constraint
    "FK_Address_Contact". The conflict occurred in database
    "XXXXRepository", table  "XXX.Contact". at
    
    
    com.microsoft.sqlserver.jdbc.SQLServerException.makeFromDatabase
    Error(SQLServerException.java:216)
    

Local fix

  • JPA entities should be persisted in proper order.
    

Problem summary

  • ****************************************************************
    * USERS AFFECTED:  All users of IBM WebSphere Application      *
    *                  Server V8.5.0 and V8.5.5 who make use of    *
    *                  openjpa.jdbc.SchemaFactory for Foreign Key  *
    *                  detection.                                  *
    ****************************************************************
    * PROBLEM DESCRIPTION: Using openjpa.jdbc.SchemaFactory for    *
    *                      Foreign Key detection can yield a       *
    *                      column type mismatch.                   *
    ****************************************************************
    * RECOMMENDATION:                                              *
    ****************************************************************
    Take the following property which tells OpenJPA to search a
    user's database schema for foreign keys:
    <property
    name="openjpa.jdbc.SchemaFactory
    "value="native(ForeignKeys=true)"/>
    With this property set, there are cases where OpenJPA throws
    this exception:
    org.apache.openjpa.persistence.ArgumentException:
    "com.xxx.yyy.Parent.phone" declares a column that is not
    compatible with the expected type "varchar". Column details:
    Full Name: Parent.phone
    Type: varbinary
    This message details the fact that the column for 'phone' is
    defined as varbinary in the database.  The JPA entity defines
    'phone' as a String.  Therefore, from OpenJPA's point of view,
    this is a mismatch.  This exception only occurs when the above
    property is set, without this property OpenJPA doesn't do the
    schema validation as such this goes unchecked and all works
    fine.  While OpenJPA views this as a mismatch and doesn't
    allow the scenario to continue, the JDBC driver and database
    allows the String to be stored into a varbinary.
    

Problem conclusion

  • In this situation, the obvious solution is to change the
    column type to match the JPA domain model.  However, it may
    not be possible for a user to change a databases column type.
    The other solution is for OpenJPA to tolerate the column type
    mismatch since the JDBC driver allows the column type
    mismatch.  To that end, this APAR provides a new OpenJPA
    property to tell OpenJPA to ignore column type mismatches when
    doing schema validation.  The property is named
    "disableSchemaFactoryColumnTypeErrors", and can be set to true
    to disable column type mismatches during schema validation.
    To set the property, set the following in the persistence.xml
    file:
    
    <property name="openjpa.jdbc.DBDictionary
    "value="disableSchemaFactoryColumnTypeErrors=true"/>
    
    This can also be set as a JVM system property.
    
    
    The fix for this APAR is currently targeted for
    inclusion in Service Level (Fix Pack) 8.5.5.10 of WebSphere
    Application Server version 8.5.5 and fix pack 16.0.0.2 for
    WebSphere Liberty.
    
    Please refer to the recommended updates page for delivery
    information:
    http://www.ibm.com/support/docview.wss?rs=180&uid=swg27004980
    

Temporary fix

Comments

APAR Information

  • APAR number

    PI55889

  • Reported component name

    WEBS APP SERV N

  • Reported component ID

    5724H8800

  • Reported release

    850

  • Status

    CLOSED PER

  • PE

    NoPE

  • HIPER

    NoHIPER

  • Special Attention

    NoSpecatt / Xsystem

  • Submitted date

    2016-01-22

  • Closed date

    2016-05-11

  • Last modified date

    2016-06-09

  • 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

  • R850 PSY

       UP

[{"Business Unit":{"code":"BU059","label":"IBM Software w\/o TPS"},"Product":{"code":"SSEQTP","label":"WebSphere Application Server"},"Platform":[{"code":"PF025","label":"Platform Independent"}],"Version":"8.5","Line of Business":{"code":"LOB45","label":"Automation"}}]

Document Information

Modified date:
28 April 2022