Show TOC Start of Content Area

Procedure documentation Versioning with read_uncommitted Isolation Level  Locate the document in its SAP Library structure

Use

You use this procedure to enable JPA versioning on DataSources that have read_uncommitted isolation level. The JPA specification requires that in order to use versioning, you must use a DataSource with a read_committed isolation level. To resolve the difference between the specification requirement and the DataSource isolation level, you use a version generator. Thus, you can use JPA versioning on DataSources with read_uncommitted level. The version generator has the following behavior:

DataSource Isolation Level

read_committed

read_uncommitted

With Generator Table

The container recognizes the table and uses it. Versioning works fine.

The container recognizes the table and uses it. Versioning works fine.

Without Generator Table

Versioning works fine.

The container recognizes the difference in isolation levels and throws an exception.

Caution

The version generator resolves the read_uncommitted versioning problem only. If you use read_uncommitted, other dirty read effects may occur as well. We recommend that you use read_committed isolation level.

Prerequisites

      You have created your entity.

      Your entity uses versioning.

Procedure

...

       1.      To use JPA versioning on DataSources with read_uncommitted isolation, you use a version generator. The version generator needs a database table to work with. You can choose an arbitrary name of the version generator table (in the example below, table name is TMP_VERSION_GEN). However, the column names and their corresponding types are fixed (as shown in the table below).

Example

The following table lists the required columns and corresponding types for the version generator table with name TMP_VERSION_GEN:

Column Name

Key

Built-in Type

JDBC Type

Length

Not Null

GEN_KEY

Yes

String

VARCHAR

256

Yes

GEN_VALUE

No

Long

BIGINT

 

Yes

You should use the details above to define the version generator table using Java Dictionary.

More information: Creating Tables

       2.      For the version generator to work, you must also specify the name of your version generator table as value of the com.sap.engine.services.orpersistence.generator.versiontablename property in the persistence.xml:

Example 

<persistence-unit name="demos/myDemoApp">

      <description> Persistence Unit</description>   

      <jta-data-source>sapdemo</jta-data-source>

      <properties>

         <property name="com.sap.engine.services.orpersistence.generator.versiontablename" value="TMP_VERSION_GEN"/>

      </properties>

   </persistence-unit>

End of Content Area