JPOX
JPOX
 Project  |  Ver 1.1  |  Ver 1.2  |  JDO  |  JPA  |  Guides  |  Tools
1.2 | Persistence | JDO ORM | JPA ORM | Runtime | JDO Runtime | JPA Runtime | Extensions | Developer
O/R Mapping
Relationships
JPA Versioning

JPA1 allows objects of classes to be versioned. The version is typically used as a way of detecting if the object has been updated by another thread or EntityManager since retrieval using the current EntityManager - for use by Optimistic Transactions. JPA1s mechanism for versioning of objects in RDBMS datastores is to mark a field of the class to store the version. The field must be Integer/Long based.

With JPA1 you can specify the details of this version field as follows.

<entity name="mydomain.User">
    <attributes>
        <id name="id"/>
        <version name="version"/>
    </attributes>
</entity>
            

or alternatively using annotations

@Entity
public class User
{
    @Id
    long id;

    @Version
    int version;

    ...
}

The specification above will use the "version" field for storing the version of the object. JPOX will use a "version-number" strategy for populating the value (see JDO2 Versioning for details of the strategies that JDO2 allows).