Show TOC

Versioning and Dirty ReadsLocate this document in the navigation structure

Use

You can enable JPA versioning on data sources that have read_uncommitted isolation level. The JPA specification requires that you use data sources with read_committed isolation level to avoid inconsistencies in concurrency control due to the “dirtily read” version column. Despite this requirement, version control can be used safely on data sources with isolation level read_uncommitted because the SAP implementation of JPA provides an alternative and safe dirty-read mechanism - this is a table based “version generator” .

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.

Note

If you are using a table-based version generator, you can set a custom value for the allocation size of the version generator. The allocation size determines how frequently the table-based version generator accesses the database table to obtain a new range of version numbers.

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.

Version Generator Table

You can choose an arbitrary name and allocation size of the version generator table. However, the column names and their corresponding types are fixed.

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

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 consider these details to define the version generator table, using Java Dictionary.

For more information, see Creating Tables .

Note

If you use the forward mapping capability of the SAP implementation of the JPA platform, this table is created automatically.