From: <one...@us...> - 2003-01-24 13:38:40
|
Update of /cvsroot/hibernate/Hibernate2/src/net/sf/hibernate/tool/hbm2ddl In directory sc8-pr-cvs1:/tmp/cvs-serv32375 Modified Files: SchemaUpdate.java Log Message: applied Michael Locher's patch to allow SchemaUpdate to configure Dialect correctly Index: SchemaUpdate.java =================================================================== RCS file: /cvsroot/hibernate/Hibernate2/src/net/sf/hibernate/tool/hbm2ddl/SchemaUpdate.java,v retrieving revision 1.3 retrieving revision 1.4 diff -C2 -d -r1.3 -r1.4 *** SchemaUpdate.java 5 Jan 2003 02:11:24 -0000 1.3 --- SchemaUpdate.java 24 Jan 2003 13:38:36 -0000 1.4 *************** *** 23,51 **** * (C) 2002 Christoph Sturm */ ! public class SchemaUpdate{ ! Log log = LogFactory.getLog( getClass() ); private ConnectionProvider cp; Datastore store; ! public SchemaUpdate(Datastore store) throws HibernateException, SQLException { this.store = store; cp = ConnectionProviderFactory.newConnectionProvider(); - } ! public SchemaUpdate(Datastore store, Properties connectionProperties) throws HibernateException { this.store = store; cp = ConnectionProviderFactory.newConnectionProvider(connectionProperties); } ! public static void main(String[] args) { try { ! Datastore ds = Hibernate.createDatastore(); ! boolean script = true; String propFile = null; ! for ( int i=0; i<args.length; i++ ) { if( args[i].startsWith("--") ) { --- 23,53 ---- * (C) 2002 Christoph Sturm */ ! public class SchemaUpdate { ! Log log = LogFactory.getLog( getClass() ); private ConnectionProvider cp; Datastore store; ! Dialect dialect; ! public SchemaUpdate(Datastore store) throws HibernateException, SQLException { this.store = store; + dialect = Dialect.getDialect(); cp = ConnectionProviderFactory.newConnectionProvider(); } ! public SchemaUpdate(Datastore store, Properties connectionProperties) throws HibernateException { this.store = store; + dialect = Dialect.getDialect(connectionProperties); cp = ConnectionProviderFactory.newConnectionProvider(connectionProperties); } ! public static void main(String[] args) { try { ! Datastore ds = Hibernate.createDatastore(); ! boolean script = true; String propFile = null; ! for ( int i=0; i<args.length; i++ ) { if( args[i].startsWith("--") ) { *************** *** 60,64 **** ds.storeFile(args[i]); } ! } if(propFile!=null) { --- 62,66 ---- ds.storeFile(args[i]); } ! } if(propFile!=null) { *************** *** 76,97 **** } } ! public void execute(boolean script) throws SQLException, HibernateException { - Dialect dialect = Dialect.getDialect(); Connection connection = cp.getConnection(); JdbcDatabaseInfo info = new JdbcDatabaseInfo(connection, dialect); Statement stmt; stmt = connection.createStatement(); ! boolean jdbc2 = false; ! String[] createSQL; createSQL = store.generateSchemaUpdateScript(dialect, info); for (int j = 0; j < createSQL.length; j++) { ! final String sql = createSQL[j]; try { if (script) System.out.println( createSQL[j] ); ! if (jdbc2) { stmt.addBatch( sql ); --- 78,98 ---- } } ! public void execute(boolean script) throws SQLException, HibernateException { Connection connection = cp.getConnection(); JdbcDatabaseInfo info = new JdbcDatabaseInfo(connection, dialect); Statement stmt; stmt = connection.createStatement(); ! boolean jdbc2 = false; ! String[] createSQL; createSQL = store.generateSchemaUpdateScript(dialect, info); for (int j = 0; j < createSQL.length; j++) { ! final String sql = createSQL[j]; try { if (script) System.out.println( createSQL[j] ); ! if (jdbc2) { stmt.addBatch( sql ); *************** *** 100,104 **** stmt.executeUpdate( sql ); } ! } catch (SQLException e) { --- 101,105 ---- stmt.executeUpdate( sql ); } ! } catch (SQLException e) { *************** *** 106,110 **** } } ! if (jdbc2) stmt.executeBatch(); stmt.close(); --- 107,111 ---- } } ! if (jdbc2) stmt.executeBatch(); stmt.close(); |