OpenJPA seems inconsistent in handling the version field when inheritance is involved. In some situations, the following error message is thrown from ColumnVersionStrategy:
not-base-vers: Type "
" specifies a version strategy, but has a mapped \
persistence capable superclass or is embedded. Subclasses and embedded \
values must use the version strategy of the base or embedding class.
In other situations (the one reported in this JIRA and org.apache.openjpa.persistence.inheritance.TestDefaultInheritanceStrategy), this error condition is not detected. These test cases have one thing in common: the parent class does not have version field, while the child class has. In this scenarios, the version column is not created in the child table nor in the parent table, and the version field is totally ignored by the OpenJPA. The attached patch attempts to detect the error condition and issues the error message if the condition is found true. However, this breaks the test case (mentioned above) of the OpenJPA regression bucket and may potentially break existing applications. Adding independent version support for child only, on the other hand, will have bigger impact and is not compatible with the current OpenJPA version handling.
Weighing the pros and cons, the better approach to this problem seems to move the version field from the child to the parent to gain full version support from OpenJPA. Please let me know what you think.