From: <one...@us...> - 2003-01-17 23:53:01
|
Update of /cvsroot/hibernate/Hibernate2/src/net/sf/hibernate/tool/hbm2ddl In directory sc8-pr-cvs1:/tmp/cvs-serv19525/sf/hibernate/tool/hbm2ddl Modified Files: SchemaExport.java Log Message: fixed a bug where delimiter was sometimes not appended Index: SchemaExport.java =================================================================== RCS file: /cvsroot/hibernate/Hibernate2/src/net/sf/hibernate/tool/hbm2ddl/SchemaExport.java,v retrieving revision 1.3 retrieving revision 1.4 diff -C2 -d -r1.3 -r1.4 *** SchemaExport.java 5 Jan 2003 02:11:23 -0000 1.3 --- SchemaExport.java 17 Jan 2003 23:52:57 -0000 1.4 *************** *** 2,8 **** package net.sf.hibernate.tool.hbm2ddl; ! import java.io.*; ! import java.sql.*; ! import java.util.*; import net.sf.hibernate.Environment; --- 2,13 ---- package net.sf.hibernate.tool.hbm2ddl; ! import java.io.FileInputStream; ! import java.io.FileWriter; ! import java.io.IOException; ! import java.sql.Connection; ! import java.sql.SQLException; ! import java.sql.Statement; ! import java.util.Properties; ! import java.util.StringTokenizer; import net.sf.hibernate.Environment; *************** *** 10,16 **** import net.sf.hibernate.HibernateException; import net.sf.hibernate.cfg.Datastore; ! import net.sf.hibernate.connection.*; ! import net.sf.hibernate.util.JDBCExceptionReporter; import net.sf.hibernate.dialect.Dialect; /** --- 15,22 ---- import net.sf.hibernate.HibernateException; import net.sf.hibernate.cfg.Datastore; ! import net.sf.hibernate.connection.ConnectionProvider; ! import net.sf.hibernate.connection.ConnectionProviderFactory; import net.sf.hibernate.dialect.Dialect; + import net.sf.hibernate.util.JDBCExceptionReporter; /** *************** *** 102,106 **** try { String formatted = dropSQL[i]; ! if (delimiter!=null) formatted+=delimiter; if (script) System.out.println(formatted); if (outputFile != null) fileOutput.write( formatted + "\n" ); --- 108,112 ---- try { String formatted = dropSQL[i]; ! if (delimiter!=null) formatted += delimiter; if (script) System.out.println(formatted); if (outputFile != null) fileOutput.write( formatted + "\n" ); *************** *** 124,128 **** for(int j = 0; j < createSQL.length; j++) { try { ! String formatted = format ? format( createSQL[j], delimiter ) : createSQL[j]; if (script) System.out.println( formatted ); if (outputFile != null) fileOutput.write( formatted + "\n" ); --- 130,135 ---- for(int j = 0; j < createSQL.length; j++) { try { ! String formatted = format ? format( createSQL[j] ) : createSQL[j]; ! if (delimiter!=null) formatted += delimiter; if (script) System.out.println( formatted ); if (outputFile != null) fileOutput.write( formatted + "\n" ); *************** *** 179,187 **** * a) Insert newline after each comma; * b) Indent three spaces after each inserted newline; - * c) Append an optional delimiter to the SQL statement. * If the statement contains single/double quotes return unchanged, * it is too complex and could be broken by simple formatting. */ ! private static String format(String sql, String delimiter) { if ( sql.indexOf("\"") > 0 || sql.indexOf("'") > 0) { --- 186,193 ---- * a) Insert newline after each comma; * b) Indent three spaces after each inserted newline; * If the statement contains single/double quotes return unchanged, * it is too complex and could be broken by simple formatting. */ ! private static String format(String sql) { if ( sql.indexOf("\"") > 0 || sql.indexOf("'") > 0) { *************** *** 189,193 **** } ! final String formatted; if ( sql.toLowerCase().startsWith("create table") ) { --- 195,199 ---- } ! String formatted; if ( sql.toLowerCase().startsWith("create table") ) { *************** *** 219,223 **** } ! return (delimiter!=null) ? formatted + delimiter : formatted; } --- 225,229 ---- } ! return formatted; } |