[ 
https://issues.apache.org/jira/browse/OPENJPA-2967?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel&focusedCommentId=18109511#comment-18109511
 ] 

ASF subversion and git services commented on OPENJPA-2967:
----------------------------------------------------------

Commit cff73f127a835f453bf3f261019eb20ff6ec125c in openjpa's branch 
refs/heads/OPENJPA-2967 from Richard Zowalla
[ https://gitbox.apache.org/repos/asf?p=openjpa.git;h=cff73f127 ]

[OPENJPA-2967] Make VERSION() work for surrogate versions

VersionVal.getType() returned null for a type whose version is mapped by
the version strategy rather than by a @Version field. initialize() admits
such a type on purpose, since its version columns exist, so the null
escaped into JPQLExpressionBuilder (type.isPrimitive() for SELECT
VERSION(e)) and into Filters.wrap (for WHERE VERSION(e) = :v), both of
which failed with a NullPointerException. getType() now falls back to
Object.class, the same answer the in-memory VersionVal gives, and
toDataStoreValue() converts through the version column's java type.

initialize() also reported an invalid VERSION() argument with the
bad-getobjectid message, which describes an object id failure and whose
argument is null for a bare identification variable. It now uses a
dedicated message naming the path.

Known limitations, each worth its own issue: a multi-column surrogate
version still compares and loads through the first column only, and a
subclass of a versioned entity is rejected because SuperclassVersionStrategy
maps no columns of its own.


> VersionVal NPEs on surrogate or missing version
> -----------------------------------------------
>
>                 Key: OPENJPA-2967
>                 URL: https://issues.apache.org/jira/browse/OPENJPA-2967
>             Project: OpenJPA
>          Issue Type: Sub-task
>          Components: jpa
>    Affects Versions: 4.2.0
>            Reporter: Maxim Solodovnik
>            Assignee: Richard Zowalla
>            Priority: Major
>             Fix For: 4.2.0
>
>
> Discussion thread: 
> https://github.com/apache/openjpa/pull/144#discussion_r3683002730
> **(medium)** `getColumns()` NPEs when the entity has a surrogate version or 
> no version at all (`getVersionFieldMapping()` returns null), so `VERSION(e)` 
> on such an entity dies with NullPointerException instead of a meaningful 
> error - `initialize` should validate this like it validates the class 
> mapping. The error at line 99 also reuses the `bad-getobjectid` message, 
> which is misleading for a VERSION() failure.



--
This message was sent by Atlassian Jira
(v8.20.10#820010)

Reply via email to