OpenJPA
  1. OpenJPA
  2. OPENJPA-578

Specifying a default for VersionStrategy in persistence.xml has no effect when a version field is present in the entity class.

    Details

    • Type: Improvement Improvement
    • Status: Closed
    • Priority: Major Major
    • Resolution: Fixed
    • Affects Version/s: 1.0.2
    • Fix Version/s: 1.2.0
    • Component/s: jdbc
    • Labels:
      None

      Description

      Specifying a default for VersionStrategy in persistence.xml has no effect when a version field is present in the entity class.

      According the OpenJPA documentation the following property should override the default value of VersionStrategy and the specified RowChangeTimestampStrategy should be applied for all entity classes.

      <property name="openjpa.jdbc.MappingDefaults"
      value="jpa(VersionStrategy=com.ibm.websphere.persistence.RowChangeTimestampStrategy)" />

      JPA accepts this property but then it has no effect on Entity mappings if the version field is present.

      import javax.persistence.*;
      import org.apache.openjpa.persistence.jdbc.VersionStrategy;

      @Entity
      public class EntityA {
      @Id int id;
      String name;
      double amt;
      @Version java.sql.Timestamp lastUpdate;

      For EntityA, the version strategy should be RowChangeTimestampStrategy. Instead, the NumberVersionStrategy is adopted.
      If the @Version is removed from EntityA, the version strategy becomes RowChangeTimestampStrategy.

        Activity

        Fay Wang created issue -
        Fay Wang made changes -
        Field Original Value New Value
        Attachment openjpa.patch [ 12380592 ]
        Fay Wang made changes -
        Issue Type Bug [ 1 ] Improvement [ 4 ]
        Fay Wang made changes -
        Status Open [ 1 ] Resolved [ 5 ]
        Resolution Fixed [ 1 ]
        Donald Woods made changes -
        Status Resolved [ 5 ] Closed [ 6 ]

          People

          • Assignee:
            Unassigned
            Reporter:
            Fay Wang
          • Votes:
            0 Vote for this issue
            Watchers:
            0 Start watching this issue

            Dates

            • Created:
              Updated:
              Resolved:

              Development