[tjdo-commits] [CVS tjdo] Corrected Oracle validation errors caused by JDBC driver reporting the si
Brought to you by:
jackknifebarber
From: Damon W. <da...@us...> - 2008-07-01 15:36:27
|
<html> <head> <style><!-- body {background-color:#ffffff;} .file {border:1px solid #eeeeee;margin-top:1em;margin-bottom:1em;} .pathname {font-family:monospace; float:right;} .fileheader {margin-bottom:.5em;} .diff {margin:0;} .tasklist {padding:4px;border:1px dashed #000000;margin-top:1em;} .tasklist ul {margin-top:0;margin-bottom:0;} tr.alt {background-color:#eeeeee} #added {background-color:#ddffdd;} #addedchars {background-color:#99ff99;font-weight:bolder;} tr.alt #added {background-color:#ccf7cc;} #removed {background-color:#ffdddd;} #removedchars {background-color:#ff9999;font-weight:bolder;} tr.alt #removed {background-color:#f7cccc;} #info {color:#888888;} #context {background-color:#eeeeee;} td {padding-left:.3em;padding-right:.3em;} tr.head {border-bottom-width:1px;border-bottom-style:solid;} tr.head td {padding:0;padding-top:.2em;} .task {background-color:#ffff00;} .comment {white-space:-moz-pre-wrap;white-space:-pre-wrap;white-space:-o-pre-wrap;white-space:pre-wrap;word-wrap:break-word;padding:4px;border:1px dashed #000000;background-color:#ffffdd} .error {color:red;} hr {border-width:0px;height:2px;background:black;} --></style> </head> <body> <table cellspacing="0" cellpadding="0" border="0" rules="cols"> <tr class="head"><td colspan="4">Commit in <b><tt>tjdo/src/com/triactive/jdo/store</tt></b><span id="info"> on MAIN</span></td></tr> <tr><td><tt>sql/<a href="#file1">Column.java</a></tt></td><td align="right" id="added">+5</td><td align="right" id="removed">-5</td><td nowrap="nowrap" align="center">1.8 -> 1.9</td></tr> <tr class="alt"><td><tt> /<a href="#file2">View.java</a></tt></td><td align="right" id="added">+11</td><td align="right" id="removed">-3</td><td nowrap="nowrap" align="center">1.7 -> 1.8</td></tr> <tr><td><tt>adapter/<a href="#file3"><span id="added">OracleColumnInfo.java</span></a></tt></td><td align="right" id="added">+68</td><td></td><td nowrap="nowrap" align="right">added 1.1</td></tr> <tr class="alt"><td><tt> /<a href="#file4">ColumnInfo.java</a></tt></td><td align="right" id="added">+13</td><td align="right" id="removed">-2</td><td nowrap="nowrap" align="center">1.4 -> 1.5</td></tr> <tr><td><tt> /<a href="#file5">OracleAdapter.java</a></tt></td><td align="right" id="added">+15</td><td align="right" id="removed">-2</td><td nowrap="nowrap" align="center">1.13 -> 1.14</td></tr> <tr><td></td><td align="right" id="added">+112</td><td align="right" id="removed">-12</td><td></td></tr> </table> <small id="info">1 added + 4 modified, total 5 files</small><br /> <pre class="comment"> Corrected Oracle validation errors caused by JDBC driver reporting the size of columns in bytes when using VARCHAR2(N CHAR) or CHAR(1 CHAR) types. </pre> <hr /><a name="file1" /><div class="file"> <span class="pathname">tjdo/src/com/triactive/jdo/store/sql</span><br /> <div class="fileheader"><big><b>Column.java</b></big> <small id="info">1.8 -> 1.9</small></div> <pre class="diff"><small id="info">diff -u -r1.8 -r1.9 --- Column.java 30 Nov 2007 19:42:25 -0000 1.8 +++ Column.java 1 Jul 2008 15:36:35 -0000 1.9 @@ -5,7 +5,7 @@ </small></pre><pre class="diff" id="context"> * This software is distributed under the terms of the TJDO License version 1.0. * See the terms of the TJDO License in the documentation provided with this software. * </pre><pre class="diff" id="removed">- * $Id: Column.java,v 1.8 2007/11/30 19:42:25 jackknifebarber Exp $ </pre><pre class="diff" id="added">+ * $Id: Column.java,v 1.9 2008/07/01 15:36:35 damonew Exp $ </pre><pre class="diff" id="context"> */ package com.triactive.jdo.store.sql; </pre><pre class="diff"><small id="info">@@ -32,7 +32,7 @@ </small></pre><pre class="diff" id="context"> * The column attributes, including SQL type, are usually set by the Mapping. * * @author <a href="mailto:jac...@us...">Mike Martin</a> </pre><pre class="diff" id="removed">- * @version $Revision: 1.<span id="removedchars">8</span> $ </pre><pre class="diff" id="added">+ * @version $Revision: 1.<span id="addedchars">9</span> $ </pre><pre class="diff" id="context"> */ public class Column implements Comparable </pre><pre class="diff"><small id="info">@@ -243,8 +243,8 @@ </small></pre><pre class="diff" id="context"> if (sqlPrecision > 0 && actualPrecision > 0) { </pre><pre class="diff" id="removed">- if (sqlPrecision != actualPrecision) - throw new WrongPrecisionException(this, sqlPrecision, actualPrecision); </pre><pre class="diff" id="added">+ if (!(ci.isValidLength(sqlPrecision))) + throw new WrongPrecisionException(this, sqlPrecision, actualPrecision); </pre><pre class="diff" id="context"> } if (scale >= 0 && actualScale >= 0) </pre><pre class="diff"><small id="info">@@ -575,4 +575,4 @@ </small></pre><pre class="diff" id="context"> { return table.getName() + "." + name; } </pre><pre class="diff" id="removed">-} </pre><pre class="diff" id="added">+} </pre><pre class="diff"><small id="info">\ No newline at end of file </small></pre></div> <hr /><a name="file2" /><div class="file"> <span class="pathname">tjdo/src/com/triactive/jdo/store/sql</span><br /> <div class="fileheader"><big><b>View.java</b></big> <small id="info">1.7 -> 1.8</small></div> <pre class="diff"><small id="info">diff -u -r1.7 -r1.8 --- View.java 30 Nov 2007 19:42:25 -0000 1.7 +++ View.java 1 Jul 2008 15:36:35 -0000 1.8 @@ -5,7 +5,7 @@ </small></pre><pre class="diff" id="context"> * This software is distributed under the terms of the TJDO License version 1.0. * See the terms of the TJDO License in the documentation provided with this software. * </pre><pre class="diff" id="removed">- * $Id: View.java,v 1.7 2007/11/30 19:42:25 jackknifebarber Exp $ </pre><pre class="diff" id="added">+ * $Id: View.java,v 1.8 2008/07/01 15:36:35 damonew Exp $ </pre><pre class="diff" id="context"> */ package com.triactive.jdo.store.sql; </pre><pre class="diff"><small id="info">@@ -13,6 +13,7 @@ </small></pre><pre class="diff" id="context"> import com.triactive.jdo.SchemaManagementOptions; import com.triactive.jdo.store.StoreManager.MgmtTransaction; import com.triactive.jdo.store.adapter.ColumnInfo; </pre><pre class="diff" id="added">+import com.triactive.jdo.store.adapter.OracleColumnInfo; </pre><pre class="diff" id="context"> import com.triactive.jdo.store.adapter.DatabaseAdapter; import java.sql.SQLException; import java.util.ArrayList; </pre><pre class="diff"><small id="info">@@ -96,8 +97,15 @@ </small></pre><pre class="diff" id="context"> } else { </pre><pre class="diff" id="added">+ if (!(ci instanceof OracleColumnInfo)) + { </pre><pre class="diff" id="context"> col.validate(ci); </pre><pre class="diff" id="removed">- unvalidated.remove(colName); </pre><pre class="diff" id="added">+ } + else + { + LOG.debug("View validation of columns not supported for Oracle databases."); + } + unvalidated.remove(colName); </pre><pre class="diff" id="context"> } } </pre><pre class="diff"><small id="info">@@ -132,4 +140,4 @@ </small></pre><pre class="diff" id="context"> return stmts; } </pre><pre class="diff" id="removed">-} </pre><pre class="diff" id="added">+} </pre><pre class="diff"><small id="info">\ No newline at end of file </small></pre></div> <hr /><a name="file3" /><div class="file"> <span class="pathname" id="added">tjdo/src/com/triactive/jdo/store/adapter</span><br /> <div class="fileheader" id="added"><big><b>OracleColumnInfo.java</b></big> <small id="info">added at 1.1</small></div> <pre class="diff"><small id="info">diff -N OracleColumnInfo.java --- /dev/null 1 Jan 1970 00:00:00 -0000 +++ OracleColumnInfo.java 1 Jul 2008 15:36:35 -0000 1.1 @@ -0,0 +1,68 @@ </small></pre><pre class="diff" id="added">+/* + * Copyright 2008 (C) TJDO. + * All rights reserved. + * + * This software is distributed under the terms of the TJDO License version 1.0. + * See the terms of the TJDO License in the documentation provided with this software. + */ +package com.triactive.jdo.store.adapter; + +import java.sql.ResultSet; +import java.sql.SQLException; + +/** + * Represents the metadata of a specific table column in Oracle. Additionally, + * provides an Oracle column length validation method. + * + * @author <a href="mailto:dwi...@tr...">Damon Williams</a> + * @version $Revision: 1.1 $ + */ +public class OracleColumnInfo extends ColumnInfo +{ + public static final int BYTE = 1; + public static final int CHARACTER_SIZE = 4; + + /** + * Constructs a column information object from the current row of the given + * result set. The {@link ResultSet} object passed must have been obtained + * from a call to DatabaseMetaData.getColumns(). + * <p> + * This method only retrieves the values from the current row; the caller + * is required to advance to the next row with {@link ResultSet#next}. + * + * @param rs + * The result set returned from DatabaseMetaData.getColumns(). + */ + public OracleColumnInfo(ResultSet rs) throws SQLException + { + super(rs); + } + + /** + * Perform Oracle column length validation. This method deals with validation + * problems when the JDBC driver reports the size of columns in bytes when using + * VARCHAR2(N CHAR) or CHAR(1 CHAR) types. + * + * @param expectedPrecision the TJDO sql precision value to validate. + * @return true if is valid length, false otherwise. + */ + public boolean isValidLength(int expectedPrecision) + { + if (super.dataType == java.sql.Types.CHAR) + { + return (expectedPrecision == BYTE)||(expectedPrecision == CHARACTER_SIZE); + } + + if (super.dataType == java.sql.Types.VARCHAR) + { + if (expectedPrecision <= 1000) + { + return (expectedPrecision == super.columnSize) || + (expectedPrecision == (super.columnSize/CHARACTER_SIZE)); + } + //Ensure capacity is less than or equal to column size + return (expectedPrecision <= super.columnSize); + } + return super.isValidLength(expectedPrecision); + } +} </pre></div> <hr /><a name="file4" /><div class="file"> <span class="pathname">tjdo/src/com/triactive/jdo/store/adapter</span><br /> <div class="fileheader"><big><b>ColumnInfo.java</b></big> <small id="info">1.4 -> 1.5</small></div> <pre class="diff"><small id="info">diff -u -r1.4 -r1.5 --- ColumnInfo.java 30 Nov 2007 19:42:24 -0000 1.4 +++ ColumnInfo.java 1 Jul 2008 15:36:35 -0000 1.5 @@ -5,7 +5,7 @@ </small></pre><pre class="diff" id="context"> * This software is distributed under the terms of the TJDO License version 1.0. * See the terms of the TJDO License in the documentation provided with this software. * </pre><pre class="diff" id="removed">- * $Id: ColumnInfo.java,v 1.4 2007/11/30 19:42:24 jackknifebarber Exp $ </pre><pre class="diff" id="added">+ * $Id: ColumnInfo.java,v 1.5 2008/07/01 15:36:35 damonew Exp $ </pre><pre class="diff" id="context"> */ package com.triactive.jdo.store.adapter; </pre><pre class="diff"><small id="info">@@ -29,7 +29,7 @@ </small></pre><pre class="diff" id="context"> * metadata or correct faulty metadata obtained from that DBMS's JDBC driver(s). * * @author <a href="mailto:jac...@us...">Mike Martin</a> </pre><pre class="diff" id="removed">- * @version $Revision: 1.<span id="removedchars">4</span> $ </pre><pre class="diff" id="added">+ * @version $Revision: 1.<span id="addedchars">5</span> $ </pre><pre class="diff" id="context"> * * @see DatabaseAdapter#newColumnInfo * @see DatabaseMetaData#getColumns </pre><pre class="diff"><small id="info">@@ -216,6 +216,17 @@ </small></pre><pre class="diff" id="context"> { return tableName; } </pre><pre class="diff" id="added">+ + /** + * Compare the expected column size to the actual database column size. + * + * @param expected the sql expected column size. + * @return true if valid length, false otherwise. + */ + public boolean isValidLength(int expectedPrecision) + { + return (this.columnSize == expectedPrecision); + } </pre><pre class="diff" id="context"> /** * Indicates whether some object is "equal to" this one. </pre></div> <hr /><a name="file5" /><div class="file"> <span class="pathname">tjdo/src/com/triactive/jdo/store/adapter</span><br /> <div class="fileheader"><big><b>OracleAdapter.java</b></big> <small id="info">1.13 -> 1.14</small></div> <pre class="diff"><small id="info">diff -u -r1.13 -r1.14 --- OracleAdapter.java 30 Nov 2007 19:42:24 -0000 1.13 +++ OracleAdapter.java 1 Jul 2008 15:36:35 -0000 1.14 @@ -5,7 +5,7 @@ </small></pre><pre class="diff" id="context"> * This software is distributed under the terms of the TJDO License version 1.0. * See the terms of the TJDO License in the documentation provided with this software. * </pre><pre class="diff" id="removed">- * $Id: OracleAdapter.java,v 1.13 2007/11/30 19:42:24 jackknifebarber Exp $ </pre><pre class="diff" id="added">+ * $Id: OracleAdapter.java,v 1.14 2008/07/01 15:36:35 damonew Exp $ </pre><pre class="diff" id="context"> */ package com.triactive.jdo.store.adapter; </pre><pre class="diff"><small id="info">@@ -35,7 +35,7 @@ </small></pre><pre class="diff" id="context"> * Provides methods for adapting SQL language elements to the Oracle database. * * @author <a href="mailto:jac...@us...">Mike Martin</a> </pre><pre class="diff" id="removed">- * @version $Revision: 1.1<span id="removedchars">3</span> $ </pre><pre class="diff" id="added">+ * @version $Revision: 1.1<span id="addedchars">4</span> $ </pre><pre class="diff" id="context"> * * @see DatabaseAdapter */ </pre><pre class="diff"><small id="info">@@ -126,6 +126,19 @@ </small></pre><pre class="diff" id="context"> return ti; } </pre><pre class="diff" id="added">+ + /** + * Get a new Oracle <code>ColumnInfo</code> for a provide <code>ResultSet</code> + * + * @see OracleColumnInfo + * @param rs ResultSet + * @return ColumnInfo an OracleColumnInfo object + * @throws SQLException + */ + public ColumnInfo newColumnInfo(ResultSet rs) throws SQLException + { + return new OracleColumnInfo(rs); + } </pre><pre class="diff" id="context"> protected Class mappingClassFor(FieldMetaData fmd) { </pre></div> <center><small><a href="http://www.badgers-in-foil.co.uk/projects/cvsspam/" title="commit -> email">CVSspam</a> 0.2.12</small></center> </body></html> |