openjpa-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From awh...@apache.org
Subject svn commit: r497866 - in /incubator/openjpa/trunk/openjpa-jdbc/src/main/java/org/apache/openjpa/jdbc: meta/MappingInfo.java meta/ReverseMappingTool.java schema/Column.java schema/DynamicSchemaFactory.java sql/DBDictionary.java
Date Fri, 19 Jan 2007 16:33:09 GMT
Author: awhite
Date: Fri Jan 19 08:33:08 2007
New Revision: 497866

URL: http://svn.apache.org/viewvc?view=rev&rev=497866
Log:
Expand Column.isCompatible method parameters to also take type name and 
decimal digits so that DynamicSchemaFactory can set this information when
building up its internal schema representation.


Modified:
    incubator/openjpa/trunk/openjpa-jdbc/src/main/java/org/apache/openjpa/jdbc/meta/MappingInfo.java
    incubator/openjpa/trunk/openjpa-jdbc/src/main/java/org/apache/openjpa/jdbc/meta/ReverseMappingTool.java
    incubator/openjpa/trunk/openjpa-jdbc/src/main/java/org/apache/openjpa/jdbc/schema/Column.java
    incubator/openjpa/trunk/openjpa-jdbc/src/main/java/org/apache/openjpa/jdbc/schema/DynamicSchemaFactory.java
    incubator/openjpa/trunk/openjpa-jdbc/src/main/java/org/apache/openjpa/jdbc/sql/DBDictionary.java

Modified: incubator/openjpa/trunk/openjpa-jdbc/src/main/java/org/apache/openjpa/jdbc/meta/MappingInfo.java
URL: http://svn.apache.org/viewvc/incubator/openjpa/trunk/openjpa-jdbc/src/main/java/org/apache/openjpa/jdbc/meta/MappingInfo.java?view=diff&rev=497866&r1=497865&r2=497866
==============================================================================
--- incubator/openjpa/trunk/openjpa-jdbc/src/main/java/org/apache/openjpa/jdbc/meta/MappingInfo.java
(original)
+++ incubator/openjpa/trunk/openjpa-jdbc/src/main/java/org/apache/openjpa/jdbc/meta/MappingInfo.java
Fri Jan 19 08:33:08 2007
@@ -608,7 +608,8 @@
             // the expected column type
             if (given.getType() != Types.OTHER) {
                 ttype = false;
-                if (compat && !given.isCompatible(type, size)) {
+                if (compat && !given.isCompatible(type, typeName, size, 
+                    decimals)) {
                     Log log = repos.getLog();
                     if (log.isWarnEnabled())
                         log.warn(_loc.get(prefix + "-incompat-col",
@@ -643,7 +644,8 @@
         if (col == null) {
             col = table.addColumn(colName);
             col.setType(type);
-        } else if ((compat || !ttype) && !col.isCompatible(type, size)) {
+        } else if ((compat || !ttype) && !col.isCompatible(type, typeName, 
+            size, decimals)) {
             // if existing column isn't compatible with desired type, die if
             // can't adapt, else warn and change the existing column type
             Message msg = _loc.get(prefix + "-bad-col", context,

Modified: incubator/openjpa/trunk/openjpa-jdbc/src/main/java/org/apache/openjpa/jdbc/meta/ReverseMappingTool.java
URL: http://svn.apache.org/viewvc/incubator/openjpa/trunk/openjpa-jdbc/src/main/java/org/apache/openjpa/jdbc/meta/ReverseMappingTool.java?view=diff&rev=497866&r1=497865&r2=497866
==============================================================================
--- incubator/openjpa/trunk/openjpa-jdbc/src/main/java/org/apache/openjpa/jdbc/meta/ReverseMappingTool.java
(original)
+++ incubator/openjpa/trunk/openjpa-jdbc/src/main/java/org/apache/openjpa/jdbc/meta/ReverseMappingTool.java
Fri Jan 19 08:33:08 2007
@@ -1085,7 +1085,7 @@
         Column[] pks = table.getPrimaryKey().getColumns();
         cls.setPrimaryKeyColumns(pks);
         if (pks.length == 1 && _datastore
-            && pks[0].isCompatible(Types.BIGINT, 0)) {
+            && pks[0].isCompatible(Types.BIGINT, null, 0, 0)) {
             cls.setObjectIdType(null, false);
             cls.setIdentityType(ClassMapping.ID_DATASTORE);
         } else if (pks.length == 1 && _builtin)

Modified: incubator/openjpa/trunk/openjpa-jdbc/src/main/java/org/apache/openjpa/jdbc/schema/Column.java
URL: http://svn.apache.org/viewvc/incubator/openjpa/trunk/openjpa-jdbc/src/main/java/org/apache/openjpa/jdbc/schema/Column.java?view=diff&rev=497866&r1=497865&r2=497866
==============================================================================
--- incubator/openjpa/trunk/openjpa-jdbc/src/main/java/org/apache/openjpa/jdbc/schema/Column.java
(original)
+++ incubator/openjpa/trunk/openjpa-jdbc/src/main/java/org/apache/openjpa/jdbc/schema/Column.java
Fri Jan 19 08:33:08 2007
@@ -548,7 +548,8 @@
      * Return true if this column is compatible with the given JDBC type
      * from {@link Types} and size.
      */
-    public boolean isCompatible(int type, int size) {
+    public boolean isCompatible(int type, String typeName, int size, 
+        int decimals) {
         if (type == Types.OTHER || getType() == Types.OTHER)
             return true;
 
@@ -662,7 +663,8 @@
 
         if (!getFullName().equalsIgnoreCase(col.getFullName()))
             return false;
-        if (!isCompatible(col.getType(), col.getSize()))
+        if (!isCompatible(col.getType(), col.getTypeName(), col.getSize(),
+            col.getDecimalDigits()))
             return false;
         if (getType() == Types.VARCHAR && getSize() > 0 && col.getSize()
> 0
             && getSize() != col.getSize())

Modified: incubator/openjpa/trunk/openjpa-jdbc/src/main/java/org/apache/openjpa/jdbc/schema/DynamicSchemaFactory.java
URL: http://svn.apache.org/viewvc/incubator/openjpa/trunk/openjpa-jdbc/src/main/java/org/apache/openjpa/jdbc/schema/DynamicSchemaFactory.java?view=diff&rev=497866&r1=497865&r2=497866
==============================================================================
--- incubator/openjpa/trunk/openjpa-jdbc/src/main/java/org/apache/openjpa/jdbc/schema/DynamicSchemaFactory.java
(original)
+++ incubator/openjpa/trunk/openjpa-jdbc/src/main/java/org/apache/openjpa/jdbc/schema/DynamicSchemaFactory.java
Fri Jan 19 08:33:08 2007
@@ -129,14 +129,19 @@
             super(name, table);
         }
 
-        public boolean isCompatible(int type, int size) {
+        public boolean isCompatible(int type, String typeName, int size,
+            int decimals) {
             if (getType() != Types.OTHER)
-                return super.isCompatible(type, size);
+                return super.isCompatible(type, typeName, size, decimals);
 
             if (type == Types.VARCHAR && size <= 0)
                 size = _dict.characterColumnSize;
             setType(type);
             setSize(size);
+            if (typeName != null)
+                setTypeName(typeName);
+            if (decimals >= 0)
+                setDecimalDigits(decimals);
             return true;
         }
     }

Modified: incubator/openjpa/trunk/openjpa-jdbc/src/main/java/org/apache/openjpa/jdbc/sql/DBDictionary.java
URL: http://svn.apache.org/viewvc/incubator/openjpa/trunk/openjpa-jdbc/src/main/java/org/apache/openjpa/jdbc/sql/DBDictionary.java?view=diff&rev=497866&r1=497865&r2=497866
==============================================================================
--- incubator/openjpa/trunk/openjpa-jdbc/src/main/java/org/apache/openjpa/jdbc/sql/DBDictionary.java
(original)
+++ incubator/openjpa/trunk/openjpa-jdbc/src/main/java/org/apache/openjpa/jdbc/sql/DBDictionary.java
Fri Jan 19 08:33:08 2007
@@ -751,7 +751,7 @@
     public void setBigDecimal(PreparedStatement stmnt, int idx, BigDecimal val,
         Column col)
         throws SQLException {
-        if ((col != null && col.isCompatible(Types.VARCHAR, 0))
+        if ((col != null && col.isCompatible(Types.VARCHAR, null, 0, 0))
             || (col == null && storeLargeNumbersAsStrings))
             setString(stmnt, idx, val.toString(), col);
         else
@@ -764,7 +764,7 @@
     public void setBigInteger(PreparedStatement stmnt, int idx, BigInteger val,
         Column col)
         throws SQLException {
-        if ((col != null && col.isCompatible(Types.VARCHAR, 0))
+        if ((col != null && col.isCompatible(Types.VARCHAR, null, 0, 0))
             || (col == null && storeLargeNumbersAsStrings))
             setString(stmnt, idx, val.toString(), col);
         else
@@ -833,7 +833,7 @@
      */
     public void setChar(PreparedStatement stmnt, int idx, char val, Column col)
         throws SQLException {
-        if ((col != null && col.isCompatible(Types.INTEGER, 0))
+        if ((col != null && col.isCompatible(Types.INTEGER, null, 0, 0))
             || (col == null && storeCharsAsNumbers))
             setInt(stmnt, idx, (int) val, col);
         else



Mime
View raw message