[hibernate-commits] Hibernate SVN: r10493 - trunk/HibernateExt/tools/src/java/org/hibernate/cfg/reveng/dialect

hibernate-commits at lists.jboss.org hibernate-commits at lists.jboss.org
Tue Sep 19 12:02:16 EDT 2006


Author: max.andersen at jboss.com
Date: 2006-09-19 12:02:12 -0400 (Tue, 19 Sep 2006)
New Revision: 10493

Added:
   trunk/HibernateExt/tools/src/java/org/hibernate/cfg/reveng/dialect/AbstractMetaDataDialect.java
Modified:
   trunk/HibernateExt/tools/src/java/org/hibernate/cfg/reveng/dialect/JDBCMetaDataDialect.java
   trunk/HibernateExt/tools/src/java/org/hibernate/cfg/reveng/dialect/OracleMetaDataDialect.java
Log:
HBX-758 OracleMetaDataDialect
 fix class casting error
 create abstractmetadatadialect to share the relevant code

Added: trunk/HibernateExt/tools/src/java/org/hibernate/cfg/reveng/dialect/AbstractMetaDataDialect.java
===================================================================
--- trunk/HibernateExt/tools/src/java/org/hibernate/cfg/reveng/dialect/AbstractMetaDataDialect.java	2006-09-18 21:48:12 UTC (rev 10492)
+++ trunk/HibernateExt/tools/src/java/org/hibernate/cfg/reveng/dialect/AbstractMetaDataDialect.java	2006-09-19 16:02:12 UTC (rev 10493)
@@ -0,0 +1,137 @@
+package org.hibernate.cfg.reveng.dialect;
+
+import java.sql.Connection;
+import java.sql.DatabaseMetaData;
+import java.sql.ResultSet;
+import java.sql.SQLException;
+import java.util.Iterator;
+
+import org.apache.commons.logging.Log;
+import org.apache.commons.logging.LogFactory;
+import org.hibernate.cfg.JDBCBinderException;
+import org.hibernate.connection.ConnectionProvider;
+import org.hibernate.exception.SQLExceptionConverter;
+
+/**
+ * abstract base class for the metadatadialects to hold the
+ * basic setup classes.
+ *  
+ * @author max
+ *
+ */
+abstract public class AbstractMetaDataDialect implements MetaDataDialect {
+
+	protected final Log log = LogFactory.getLog(this.getClass());
+
+	private SQLExceptionConverter sec;
+	private ConnectionProvider provider;
+	
+	private Connection connection;
+	private DatabaseMetaData metaData;
+
+	public void configure(ConnectionProvider provider, SQLExceptionConverter sec) {
+		this.provider = provider;
+		this.sec = sec;		
+	}
+	
+	public void close() {
+		metaData = null;
+		if(connection != null) {
+			try {
+				provider.closeConnection(connection);
+			}
+			catch (SQLException e) {
+				getSQLExceptionConverter().convert(e, "Problem while closing connection", null);
+			}
+		}
+		provider = null;
+		sec = null;
+	}
+	
+	protected DatabaseMetaData getMetaData() throws JDBCBinderException {
+		if (metaData == null) {
+			try {
+				metaData = getConnection().getMetaData();				
+			} 
+			catch (SQLException e) {
+				throw getSQLExceptionConverter().convert(e, "Getting database metadata", null);
+			}
+		}
+		return metaData;
+	}
+	
+	protected String getDatabaseStructure(String catalog, String schema) {
+	      ResultSet schemaRs = null;
+	      ResultSet catalogRs = null;
+	      String nl = System.getProperty("line.separator");
+	      StringBuffer sb = new StringBuffer(nl);
+	      // Let's give the user some feedback. The exception
+	      // is probably related to incorrect schema configuration.
+	      sb.append("Configured schema:").append(schema).append(nl);
+	      sb.append("Configured catalog:").append(catalog ).append(nl);
+
+	      try {
+	         schemaRs = getMetaData().getSchemas();
+	         sb.append("Available schemas:").append(nl);
+	         while (schemaRs.next() ) {
+	            sb.append("  ").append(schemaRs.getString("TABLE_SCHEM") ).append(nl);
+	         }
+	      } 
+	      catch (SQLException e2) {
+	         log.warn("Could not get schemas", e2);
+	         sb.append("  <SQLException while getting schemas>").append(nl);
+	      } 
+	      finally {
+	         try {
+	            schemaRs.close();
+	         } 
+	         catch (Exception ignore) {
+	         }
+	      }
+
+	      try {
+	         catalogRs = getMetaData().getCatalogs();
+	         sb.append("Available catalogs:").append(nl);
+	         while (catalogRs.next() ) {
+	            sb.append("  ").append(catalogRs.getString("TABLE_CAT") ).append(nl);
+	         }
+	      } 
+	      catch (SQLException e2) {
+	         log.warn("Could not get catalogs", e2);
+	         sb.append("  <SQLException while getting catalogs>").append(nl);
+	      } 
+	      finally {
+	         try {
+	            catalogRs.close();
+	         } 
+	         catch (Exception ignore) {
+	         }
+	      }
+	      return sb.toString();
+	   }
+
+	protected Connection getConnection() throws SQLException {
+		if(connection==null) {
+			connection = provider.getConnection();
+		}
+		return connection;
+	}
+	
+	public void close(Iterator iterator) {
+		if(iterator instanceof ResultSetIterator) {
+			((ResultSetIterator)iterator).close();
+		}
+	}
+	
+	protected SQLExceptionConverter getSQLExceptionConverter() {
+		return sec;
+	}
+	
+	public boolean needQuote(String name) {
+		
+		// TODO: use jdbc metadata to decide on this. but for now we just handle the most typical cases.
+		if(name.indexOf('-')>0) return true;
+		if(name.indexOf(' ')>0) return true;
+		return false;
+	}
+}

Modified: trunk/HibernateExt/tools/src/java/org/hibernate/cfg/reveng/dialect/JDBCMetaDataDialect.java
===================================================================
--- trunk/HibernateExt/tools/src/java/org/hibernate/cfg/reveng/dialect/JDBCMetaDataDialect.java	2006-09-18 21:48:12 UTC (rev 10492)
+++ trunk/HibernateExt/tools/src/java/org/hibernate/cfg/reveng/dialect/JDBCMetaDataDialect.java	2006-09-19 16:02:12 UTC (rev 10493)
@@ -1,7 +1,5 @@
 package org.hibernate.cfg.reveng.dialect;
 
-import java.sql.Connection;
-import java.sql.DatabaseMetaData;
 import java.sql.ResultSet;
 import java.sql.ResultSetMetaData;
 import java.sql.SQLException;
@@ -9,11 +7,6 @@
 import java.util.Iterator;
 import java.util.Map;
 
-import org.apache.commons.logging.Log;
-import org.apache.commons.logging.LogFactory;
-import org.hibernate.cfg.JDBCBinderException;
-import org.hibernate.connection.ConnectionProvider;
-import org.hibernate.exception.SQLExceptionConverter;
 import org.hibernate.mapping.Table;
 
 /**
@@ -22,54 +15,15 @@
  * @author Max Rydahl Andersen
  *
  */
-public class JDBCMetaDataDialect implements MetaDataDialect {
+public class JDBCMetaDataDialect extends AbstractMetaDataDialect {
 
-	private static final Log log = LogFactory.getLog(JDBCMetaDataDialect.class);
-
-	private SQLExceptionConverter sec;
-	private ConnectionProvider provider;
 	
-	private Connection connection;
-	private DatabaseMetaData metaData;
-
-		
-	public void configure(ConnectionProvider provider, SQLExceptionConverter sec) {
-		this.provider = provider;
-		this.sec = sec;		
-	}
-	
-	public void close() {
-		metaData = null;
-		if(connection != null) {
-			try {
-				provider.closeConnection(connection);
-			}
-			catch (SQLException e) {
-				sec.convert(e, "Problem while closing connection", null);
-			}
-		}
-		provider = null;
-		sec = null;
-	}
-	
-	protected DatabaseMetaData getMetaData() throws JDBCBinderException {
-		if (metaData == null) {
-			try {
-				metaData = getConnection().getMetaData();				
-			} 
-			catch (SQLException e) {
-				throw sec.convert(e, "Getting database metadata", null);
-			}
-		}
-		return metaData;
-	}
-	
 	public Iterator getTables(final String catalog, final String schema, String table) {
 		try {		
 			log.debug("getTables(" + catalog + "." + schema + "." + table + ")");
 			ResultSet tableRs = getMetaData().getTables(catalog , schema , table, new String[] { "TABLE", "VIEW" });
 			
-			return new ResultSetIterator(tableRs, sec) {
+			return new ResultSetIterator(tableRs, getSQLExceptionConverter()) {
 				
 				Map element = new HashMap();
 				protected Object convertRow(ResultSet tableRs) throws SQLException {
@@ -83,7 +37,7 @@
 					// schemaRs and catalogRs are only used for error reporting if
 					// we get an exception
 					String databaseStructure = getDatabaseStructure( catalog, schema );
-					throw sec.convert( e,
+					throw getSQLExceptionConverter().convert( e,
 							"Could not get list of tables from database. Probably a JDBC driver problem. "
 									+ databaseStructure, null );					
 				}
@@ -91,7 +45,7 @@
 		} catch (SQLException e) {
 			// schemaRs and catalogRs are only used for error reporting if we get an exception
 			String databaseStructure = getDatabaseStructure(catalog,schema);
-			throw sec.convert(e, "Could not get list of tables from database. Probably a JDBC driver problem. " + databaseStructure, null);		         
+			throw getSQLExceptionConverter().convert(e, "Could not get list of tables from database. Probably a JDBC driver problem. " + databaseStructure, null);		         
 		} 		
 	}
 	
@@ -116,68 +70,15 @@
 		   System.out.println();
 	}
 
-    private String getDatabaseStructure(String catalog, String schema) {
-	      ResultSet schemaRs = null;
-	      ResultSet catalogRs = null;
-	      String nl = System.getProperty("line.separator");
-	      StringBuffer sb = new StringBuffer(nl);
-	      // Let's give the user some feedback. The exception
-	      // is probably related to incorrect schema configuration.
-	      sb.append("Configured schema:").append(schema).append(nl);
-	      sb.append("Configured catalog:").append(catalog ).append(nl);
+    
+	
 
-	      try {
-	         schemaRs = getMetaData().getSchemas();
-	         sb.append("Available schemas:").append(nl);
-	         while (schemaRs.next() ) {
-	            sb.append("  ").append(schemaRs.getString("TABLE_SCHEM") ).append(nl);
-	         }
-	      } 
-	      catch (SQLException e2) {
-	         log.warn("Could not get schemas", e2);
-	         sb.append("  <SQLException while getting schemas>").append(nl);
-	      } 
-	      finally {
-	         try {
-	            schemaRs.close();
-	         } 
-	         catch (Exception ignore) {
-	         }
-	      }
-
-	      try {
-	         catalogRs = getMetaData().getCatalogs();
-	         sb.append("Available catalogs:").append(nl);
-	         while (catalogRs.next() ) {
-	            sb.append("  ").append(catalogRs.getString("TABLE_CAT") ).append(nl);
-	         }
-	      } 
-	      catch (SQLException e2) {
-	         log.warn("Could not get catalogs", e2);
-	         sb.append("  <SQLException while getting catalogs>").append(nl);
-	      } 
-	      finally {
-	         try {
-	            catalogRs.close();
-	         } 
-	         catch (Exception ignore) {
-	         }
-	      }
-	      return sb.toString();
-	   }
-
-	public void close(Iterator iterator) {
-		if(iterator instanceof ResultSetIterator) {
-			((ResultSetIterator)iterator).close();
-		}
-	}
-
 	public Iterator getIndexInfo(final String catalog, final String schema, final String table) {
 		try {		
 			log.debug("getIndexInfo(" + catalog + "." + schema + "." + table + ")");
 			ResultSet tableRs = getMetaData().getIndexInfo(catalog , schema , table, false, true);
 			
-			return new ResultSetIterator(tableRs, sec) {
+			return new ResultSetIterator(tableRs, getSQLExceptionConverter()) {
 				
 				Map element = new HashMap();
 				protected Object convertRow(ResultSet rs) throws SQLException {
@@ -190,11 +91,11 @@
 					return element;					
 				}
 				protected Throwable handleSQLException(SQLException e) {
-					throw sec.convert(e, "Exception while getting index info for " + Table.qualify(catalog, schema, table), null);
+					throw getSQLExceptionConverter().convert(e, "Exception while getting index info for " + Table.qualify(catalog, schema, table), null);
 				}
 			};
 		} catch (SQLException e) {
-			throw sec.convert(e, "Exception while getting index info for " + Table.qualify(catalog, schema, table), null);
+			throw getSQLExceptionConverter().convert(e, "Exception while getting index info for " + Table.qualify(catalog, schema, table), null);
 		} 		
 	}
 
@@ -209,7 +110,7 @@
 			log.debug("getColumns(" + catalog + "." + schema + "." + table + "." + column + ")");
 			ResultSet tableRs = getMetaData().getColumns(catalog, schema, table, column);
 			
-			return new ResultSetIterator(tableRs, sec) {
+			return new ResultSetIterator(tableRs, getSQLExceptionConverter()) {
 				
 				Map element = new HashMap();
 				protected Object convertRow(ResultSet rs) throws SQLException {
@@ -225,11 +126,11 @@
 					return element;					
 				}
 				protected Throwable handleSQLException(SQLException e) {
-					throw sec.convert(e, "Error while reading column meta data for " + Table.qualify(catalog, schema, table), null);
+					throw getSQLExceptionConverter().convert(e, "Error while reading column meta data for " + Table.qualify(catalog, schema, table), null);
 				}
 			};
 		} catch (SQLException e) {
-			throw sec.convert(e, "Error while reading column meta data for " + Table.qualify(catalog, schema, table), null);
+			throw getSQLExceptionConverter().convert(e, "Error while reading column meta data for " + Table.qualify(catalog, schema, table), null);
 		}	
 	}
 
@@ -238,7 +139,7 @@
 			log.debug("getPrimaryKeys(" + catalog + "." + schema + "." + table + ")");
 			ResultSet tableRs = getMetaData().getPrimaryKeys(catalog, schema, table);
 			
-			return new ResultSetIterator(tableRs, sec) {
+			return new ResultSetIterator(tableRs, getSQLExceptionConverter()) {
 				
 				Map element = new HashMap();
 				protected Object convertRow(ResultSet rs) throws SQLException {
@@ -250,11 +151,11 @@
 					return element;					
 				}
 				protected Throwable handleSQLException(SQLException e) {
-					throw sec.convert(e, "Error while reading primary key meta data for " + Table.qualify(catalog, schema, table), null);
+					throw getSQLExceptionConverter().convert(e, "Error while reading primary key meta data for " + Table.qualify(catalog, schema, table), null);
 				}
 			};
 		} catch (SQLException e) {
-			throw sec.convert(e, "Error while reading primary key meta data for " + Table.qualify(catalog, schema, table), null);
+			throw getSQLExceptionConverter().convert(e, "Error while reading primary key meta data for " + Table.qualify(catalog, schema, table), null);
 		}	
 	}
 
@@ -263,7 +164,7 @@
 			log.debug("getExportedKeys(" + catalog + "." + schema + "." + table + ")");
 			ResultSet tableRs = getMetaData().getExportedKeys(catalog, schema, table);
 			
-			return new ResultSetIterator(tableRs, sec) {
+			return new ResultSetIterator(tableRs, getSQLExceptionConverter()) {
 				
 				Map element = new HashMap();
 				protected Object convertRow(ResultSet rs) throws SQLException {
@@ -281,25 +182,13 @@
 					return element;					
 				}
 				protected Throwable handleSQLException(SQLException e) {
-					throw sec.convert(e, "Error while reading exported keys meta data for " + Table.qualify(catalog, schema, table), null);
+					throw getSQLExceptionConverter().convert(e, "Error while reading exported keys meta data for " + Table.qualify(catalog, schema, table), null);
 				}
 			};
 		} catch (SQLException e) {
-			throw sec.convert(e, "Error while reading exported keys meta data for " + Table.qualify(catalog, schema, table), null);
+			throw getSQLExceptionConverter().convert(e, "Error while reading exported keys meta data for " + Table.qualify(catalog, schema, table), null);
 		}	
 	}
 	
-	protected Connection getConnection() throws SQLException {
-		if(connection==null) {
-			connection = provider.getConnection();
-		}
-		return connection;
-	}
-
-	public boolean needQuote(String name) {
-		// TODO: use jdbc metadata to decide on this. but for now we just handle the most typical cases.
-		if(name.indexOf('-')>0) return true;
-		if(name.indexOf(' ')>0) return true;
-		return false;
-	}
+	
 }

Modified: trunk/HibernateExt/tools/src/java/org/hibernate/cfg/reveng/dialect/OracleMetaDataDialect.java
===================================================================
--- trunk/HibernateExt/tools/src/java/org/hibernate/cfg/reveng/dialect/OracleMetaDataDialect.java	2006-09-18 21:48:12 UTC (rev 10492)
+++ trunk/HibernateExt/tools/src/java/org/hibernate/cfg/reveng/dialect/OracleMetaDataDialect.java	2006-09-19 16:02:12 UTC (rev 10493)
@@ -1,8 +1,6 @@
 
 package org.hibernate.cfg.reveng.dialect;
 
-import java.sql.Connection;
-import java.sql.DatabaseMetaData;
 import java.sql.ResultSet;
 import java.sql.SQLException;
 import java.sql.Statement;
@@ -10,11 +8,6 @@
 import java.util.Iterator;
 import java.util.Map;
 
-import org.apache.commons.logging.Log;
-import org.apache.commons.logging.LogFactory;
-import org.hibernate.cfg.JDBCBinderException;
-import org.hibernate.connection.ConnectionProvider;
-import org.hibernate.exception.SQLExceptionConverter;
 import org.hibernate.mapping.Table;
 
 /**
@@ -23,48 +16,11 @@
  * 
  * @author David Channon
  */
-public class OracleMetaDataDialect implements MetaDataDialect {
+public class OracleMetaDataDialect extends AbstractMetaDataDialect {
 
-	private static final Log log = LogFactory.getLog(OracleMetaDataDialect.class);
-
-	private SQLExceptionConverter sec;
-	private ConnectionProvider provider;
 	
-	private Connection connection;
-	private DatabaseMetaData metaData;
-
-		
-	public void configure(ConnectionProvider provider, SQLExceptionConverter sec) {
-		this.provider = provider;
-		this.sec = sec;		
-	}
 	
-	public void close() {
-		metaData = null;
-		if(connection != null) {
-			try {
-				provider.closeConnection(connection);
-			}
-			catch (SQLException e) {
-				sec.convert(e, "Problem while closing connection", null);
-			}
-		}
-		provider = null;
-		sec = null;
-	}
 	
-	protected DatabaseMetaData getMetaData() throws JDBCBinderException {
-		if (metaData == null) {
-			try {
-				metaData = getConnection().getMetaData();				
-			} 
-			catch (SQLException e) {
-				throw sec.convert(e, "Getting database metadata", null);
-			}
-		}
-		return metaData;
-	}
-	
 	public Iterator getTables(final String catalog, final String schema, String table) {
 		try {		
 			log.debug("getTables(" + catalog + "." + schema + "." + table + ")");
@@ -100,7 +56,7 @@
 			
 	        ResultSet tableRs = stmt.executeQuery(query.toString());
 			
-			return new ResultSetIterator(tableRs, sec) {
+			return new ResultSetIterator(tableRs, getSQLExceptionConverter()) {
 				
 				Map element = new HashMap();
 				protected Object convertRow(ResultSet tableRs) throws SQLException {
@@ -116,7 +72,7 @@
 					// schemaRs and catalogRs are only used for error reporting if
 					// we get an exception
 					String databaseStructure = getDatabaseStructure( catalog, schema );
-					throw sec.convert( e,
+					throw getSQLExceptionConverter().convert( e,
 							"Could not get list of tables from database. Probably a JDBC driver problem. "
 									+ databaseStructure, null );					
 				}
@@ -124,66 +80,10 @@
 		} catch (SQLException e) {
 			// schemaRs and catalogRs are only used for error reporting if we get an exception
 			String databaseStructure = getDatabaseStructure(catalog,schema);
-			throw sec.convert(e, "Could not get list of tables from database. Probably a JDBC driver problem. " + databaseStructure, null);		         
+			throw getSQLExceptionConverter().convert(e, "Could not get list of tables from database. Probably a JDBC driver problem. " + databaseStructure, null);		         
 		} 		
 	}
 
-    private String getDatabaseStructure(String catalog, String schema) {
-	      ResultSet schemaRs = null;
-	      ResultSet catalogRs = null;
-	      String nl = System.getProperty("line.separator");
-	      StringBuffer sb = new StringBuffer(nl);
-	      // Let's give the user some feedback. The exception
-	      // is probably related to incorrect schema configuration.
-	      sb.append("Configured schema:").append(schema).append(nl);
-	      sb.append("Configured catalog:").append(catalog ).append(nl);
-
-	      try {
-	         schemaRs = getMetaData().getSchemas();
-	         sb.append("Available schemas:").append(nl);
-	         while (schemaRs.next() ) {
-	            sb.append("  ").append(schemaRs.getString("TABLE_SCHEM") ).append(nl);
-	         }
-	      } 
-	      catch (SQLException e2) {
-	         log.warn("Could not get schemas", e2);
-	         sb.append("  <SQLException while getting schemas>").append(nl);
-	      } 
-	      finally {
-	         try {
-	            schemaRs.close();
-	         } 
-	         catch (Exception ignore) {
-	         }
-	      }
-
-	      try {
-	         catalogRs = getMetaData().getCatalogs();
-	         sb.append("Available catalogs:").append(nl);
-	         while (catalogRs.next() ) {
-	            sb.append("  ").append(catalogRs.getString("TABLE_CAT") ).append(nl);
-	         }
-	      } 
-	      catch (SQLException e2) {
-	         log.warn("Could not get catalogs", e2);
-	         sb.append("  <SQLException while getting catalogs>").append(nl);
-	      } 
-	      finally {
-	         try {
-	            catalogRs.close();
-	         } 
-	         catch (Exception ignore) {
-	         }
-	      }
-	      return sb.toString();
-	   }
-
-	public void close(Iterator iterator) {
-		if(iterator instanceof ResultSetIterator) {
-			((ResultSetIterator)iterator).close();
-		}
-	}
-
 	public Iterator getIndexInfo(final String catalog, final String schema, final String table) {
 		try {		
 			log.debug("getIndexInfo(" + catalog + "." + schema + "." + table + ")");
@@ -208,14 +108,14 @@
 			
 	        ResultSet indexRs = stmt.executeQuery(query.toString());
 						
-			return new ResultSetIterator(indexRs, sec) {
+			return new ResultSetIterator(indexRs, getSQLExceptionConverter()) {
 				
 				Map element = new HashMap();
 				protected Object convertRow(ResultSet rs) throws SQLException {
 					element.clear();
 					element.put("COLUMN_NAME", rs.getString(1));
 					element.put("TYPE", new Short((short)1));		// CLUSTERED INDEX	
-					element.put("NON_UNIQUE", rs.getString(2));
+					element.put("NON_UNIQUE", Boolean.valueOf( rs.getString(2) ));
 					element.put("TABLE_SCHEM", rs.getString(3));
 					element.put("INDEX_NAME", rs.getString(4));					
 					element.put("TABLE_CAT", null);
@@ -224,11 +124,11 @@
 					return element;					
 				}
 				protected Throwable handleSQLException(SQLException e) {
-					throw sec.convert(e, "Exception while getting index info for " + Table.qualify(catalog, schema, table), null);
+					throw getSQLExceptionConverter().convert(e, "Exception while getting index info for " + Table.qualify(catalog, schema, table), null);
 				}
 			};
 		} catch (SQLException e) {
-			throw sec.convert(e, "Exception while getting index info for " + Table.qualify(catalog, schema, table), null);
+			throw getSQLExceptionConverter().convert(e, "Exception while getting index info for " + Table.qualify(catalog, schema, table), null);
 		} 		
 	}
 
@@ -269,7 +169,7 @@
 			
 	        ResultSet columnRs = stmt.executeQuery(query.toString());
 			
-			return new ResultSetIterator(columnRs, sec) {
+			return new ResultSetIterator(columnRs, getSQLExceptionConverter()) {
 				
 				Map element = new HashMap();
 				protected Object convertRow(ResultSet rs) throws SQLException {
@@ -287,11 +187,11 @@
 					return element;
 				}
 				protected Throwable handleSQLException(SQLException e) {
-					throw sec.convert(e, "Error while reading column meta data for " + Table.qualify(catalog, schema, table), null);
+					throw getSQLExceptionConverter().convert(e, "Error while reading column meta data for " + Table.qualify(catalog, schema, table), null);
 				}
 			};
 		} catch (SQLException e) {
-			throw sec.convert(e, "Error while reading column meta data for " + Table.qualify(catalog, schema, table), null);
+			throw getSQLExceptionConverter().convert(e, "Error while reading column meta data for " + Table.qualify(catalog, schema, table), null);
 		}	
 	}
 
@@ -321,7 +221,7 @@
 			
 	        ResultSet pkeyRs = stmt.executeQuery(query.toString());	
 	        
-			return new ResultSetIterator(pkeyRs, sec) {
+			return new ResultSetIterator(pkeyRs, getSQLExceptionConverter()) {
 				
 				Map element = new HashMap();
 				protected Object convertRow(ResultSet rs) throws SQLException {
@@ -335,11 +235,11 @@
 					return element;					
 				}
 				protected Throwable handleSQLException(SQLException e) {
-					throw sec.convert(e, "Error while reading primary key meta data for " + Table.qualify(catalog, schema, table), null);
+					throw getSQLExceptionConverter().convert(e, "Error while reading primary key meta data for " + Table.qualify(catalog, schema, table), null);
 				}
 			};
 		} catch (SQLException e) {
-			throw sec.convert(e, "Error while reading primary key meta data for " + Table.qualify(catalog, schema, table), null);
+			throw getSQLExceptionConverter().convert(e, "Error while reading primary key meta data for " + Table.qualify(catalog, schema, table), null);
 		}	
 	}
 
@@ -377,7 +277,7 @@
 			
 	        ResultSet pExportRs = stmt.executeQuery(query.toString());	
 			
-			return new ResultSetIterator(pExportRs, sec) {
+			return new ResultSetIterator(pExportRs, getSQLExceptionConverter()) {
 				
 				Map element = new HashMap();
 				protected Object convertRow(ResultSet rs) throws SQLException {
@@ -395,25 +295,12 @@
 					return element;					
 				}
 				protected Throwable handleSQLException(SQLException e) {
-					throw sec.convert(e, "Error while reading exported keys meta data for " + Table.qualify(catalog, schema, table), null);
+					throw getSQLExceptionConverter().convert(e, "Error while reading exported keys meta data for " + Table.qualify(catalog, schema, table), null);
 				}
 			};
 		} catch (SQLException e) {
-			throw sec.convert(e, "Error while reading exported keys meta data for " + Table.qualify(catalog, schema, table), null);
+			throw getSQLExceptionConverter().convert(e, "Error while reading exported keys meta data for " + Table.qualify(catalog, schema, table), null);
 		}	
 	}
 	
-	protected Connection getConnection() throws SQLException {
-		if(connection==null) {
-			connection = provider.getConnection();
-		}
-		return connection;
-	}
-
-	public boolean needQuote(String name) {
-		// TODO: use jdbc metadata to decide on this. but for now we just handle the most typical cases.
-		if(name.indexOf('-')>0) return true;
-		if(name.indexOf(' ')>0) return true;
-		return false;
-	}
 }




More information about the hibernate-commits mailing list