solomax commented on code in PR #144:
URL: https://github.com/apache/openjpa/pull/144#discussion_r3802364743


##########
openjpa-jdbc/src/main/java/org/apache/openjpa/jdbc/meta/strats/EnumValueHandler.java:
##########
@@ -116,8 +219,26 @@ public Object toDataStoreValue(ValueMapping vm, Object 
val, JDBCStore store) {
     public Object toObjectValue(ValueMapping vm, Object val) {
         if (val == null)
             return null;
-        if (_ordinal)
-            return _vals[((Number) val).intValue()];
-        return Enum.valueOf(vm.getType(), (String) val);
+        if (_useEnumeratedValue) {
+            initEnumeratedValueField(vm.getType());
+            Enum<?> result = _dbToEnum.get(val);
+            if (result == null && val instanceof Number) {
+                result = _dbToEnum.get(((Number) val).intValue());
+            }
+            if (result == null) {
+                result = _dbToEnum.get(val.toString());
+            }
+            return result;

Review Comment:
   @rzo1 I'm afraid this question is for you
   
   Additionally I wonder why `ENUMERATED_VALUE_CLASS` inited with function 
call? `EnumeratedValue.class` looks easier
   
   and later on `if (f.isAnnotationPresent(ENUMERATED_VALUE_CLASS)) {` might 
throw NPE ...



-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: [email protected]

For queries about this service, please contact Infrastructure at:
[email protected]

Reply via email to