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


##########
openjpa-jdbc/src/main/java/org/apache/openjpa/jdbc/sql/DBDictionary.java:
##########
@@ -2223,6 +2240,43 @@ protected int getDateFractionDigits(Column col, String 
typeName) {
         return dateFractionDigits;
     }
 
+    /**
+     * Return the type name to use as the target of a CAST to a 64 bit integer.
+     * Defaults to {@link #bigintTypeName} unless {@link #longCastTypeName} 
was set explicitly.
+     */
+    public String getLongCastTypeName() {
+        return longCastTypeName != null ? longCastTypeName : bigintTypeName;
+    }
+
+    /**
+     * Return the type name to use as the target of a CAST of a numeric value 
to the given java type.
+     * Any DDL size marker (<code>{0}</code>) is stripped, as CAST targets are 
not sized by the schema.
+     */
+    public String getNumberCastTypeName(Class<?> type) {
+        String name;
+        if (type == int.class || type == Integer.class) {
+            name = integerCastTypeName;
+        } else if (type == long.class || type == Long.class) {
+            name = getLongCastTypeName();
+        } else if (type == float.class || type == Float.class) {
+            name = floatTypeName;
+        } else {
+            name = doubleTypeName;
+        }
+        return insertSize(name, null);

Review Comment:
   Maybe i worth to cache these values instead of calling `insertSize(...)` all 
the time it might be performance unwise ....



##########
openjpa-jdbc/src/main/java/org/apache/openjpa/jdbc/sql/DBDictionary.java:
##########
@@ -511,8 +511,25 @@ public enum DateMillisecondBehaviors { DROP, ROUND, RETAIN 
}
 
     public boolean supportsUnsizedCharOnCast = true;
 
+    /**
+     * Type name used as the target of a CAST to a 32 bit integer.
+     * <p>
+     * Note: this is a field initializer, so it is evaluated before any 
subclass constructor runs.
+     * Dictionaries which change {@link #integerTypeName} do <em>not</em> 
implicitly change this value.
+     * Set it explicitly if the DDL type name is not a valid CAST target.
+     */
     public String integerCastTypeName = integerTypeName;

Review Comment:
   `integerTypeName` is redefined by some DBDictionaries in constructor (lot's 
of them actually)
   So this one also need to be lazy inited



-- 
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