3.6.4.4. Autoassign / Identity Strategy Caveats

Generated Value explains how to use JPA’s IDENTITY generation type to automatically assign field values. However, here are some additional caveats you should be aware of when using IDENTITY generation:

  1. Your database must support auto-increment / identity columns, or some equivalent (see OracleDictionary Properties for how to configure a combination of triggers and sequences to fake auto-increment support in Oracle database).

  2. Auto-increment / identity columns must be an integer or long integer type.

  3. Databases support auto-increment / identity columns to varying degrees. Some do not support them at all. Others only allow a single such column per table, and require that it be the primary key column. More lenient databases may allow non-primary key auto-increment columns, and may allow more than one per table. See your database documentation for details.