IBM Support

PI34779: IMPLEMENT A WAY TO CONFIGURE THE DEFAULT REPRESENTATION OF JPA BOOLEAN FIELDS

Subscribe

You can track all active APARs for this component.

 

APAR status

  • Closed as program error.

Error description

  • An application may use CHAR(1) as representation for boolean
    values in an Oracle database.
    There may also exist many JPA entities which contain Java
    Boolean or boolean fields.  In WebSphere Application Server,
    this internally gets treated as numbers.
    This leads to a select * from SOMETABLE where somebooleanfield
    = 1;
    If the application has somebooleanfield defined as CHAR(2) this
    will not use any index but instead will force a full table
    space scan with using toNumber(somebooleanfield) for every
    single row.
    This results in performance degradation.
    OpenJPA jira OPENJPA-2558 was created to address the problem in
    OpenJPA...
    Implement a way to select the db representation of Boolean
    values
    https://issues.apache.org/jira/browse/OPENJPA-2558
    

Local fix

Problem summary

  • ****************************************************************
    * USERS AFFECTED:  All users of IBM WebSphere Application      *
    *                  Server V8.5.5 who make use of Boolean       *
    *                  values and would like their own             *
    *                  representation of the Boolean value.        *
    ****************************************************************
    * PROBLEM DESCRIPTION: Implement a way to select the database  *
    *                      representation of Boolean values.       *
    ****************************************************************
    * RECOMMENDATION:                                              *
    ****************************************************************
    Many Databases do not natively support the SQL-99 BOOLEAN
    datatype. Boolean and boolean fields in JPA entities will thus
    get represented as another type in the database. OpenJPA
    currently has a hardcoded mapping to int 1/0 in the base
    DBDictionary.  However, many existing databases don't use
    NUMBER(1) as column type, rather a database may use CHAR(1)
    (because it uses less space in the index). There are also
    many other possible representations where one of those is
    usually consistently used throughout a customer application,
    for example:
    Native Boolean -> PreparedStatement#setBoolean
    Int 0/1 -> PreparedStatement#setInt
    String "Y"/"N" -> PreparedStatement#setString
    String "T"/"F" -> PreparedStatement#setString
    String "y"/"n" -> PreparedStatement#setString
    String "t"/"f" -> PreparedStatement#setString
    Some users might us translated ones like: "J"/"N" in German
    apps for "Ja"/ "Nein" (yes/no).
    Given this it should be possible to add a custom Boolean
    representation.
    

Problem conclusion

  • With this fix, code has been added to OpenJPA to allow a user
    to define their own Boolean representation. OpenJPA defines a
    number of built in options which are defined in the class
    org.apache.openjpa.jdbc.sql.BooleanRepresentationFactory.
    
    To use one of the values defined in
    BooleanRepresentationFactory, for example "STRING_10", set the
    following property in the persistence.xml file:
    
    <property name="openjpa.jdbc.DBDictionary"
    value="BooleanRepresentation=STRING_10"/>
    
    A user can implement the
    org.apache.openjpa.jdbc.sql.BooleanRepresentation and then use
    this implementation as follows by setting the following in a
    persistence.xml:
    
     <property name="openjpa.jdbc.DBDictionary"
    value="(BooleanRepresentation=com.mycompany.MyOwnBoolRepresentat
    ion)"/>
    
    Where, in this example,
    "com.mycompany.MyOwnBoolRepresentation" is an implementation
    of BooleanRepresentation
    
    The fix for this APAR is currently targeted for
    inclusion in Service Level (Fix Pack) 8.5.5.8 of WebSphere
    Application Server version 8.5.5.
    
    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

    PI34779

  • Reported component name

    WEBSPHERE APP S

  • Reported component ID

    5724J0800

  • Reported release

    850

  • Status

    CLOSED PER

  • PE

    NoPE

  • HIPER

    NoHIPER

  • Special Attention

    NoSpecatt / Xsystem

  • Submitted date

    2015-02-11

  • Closed date

    2015-06-25

  • Last modified date

    2015-08-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

    WEBSPHERE APP S

  • Fixed component ID

    5724J0800

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:
11 January 2022