Java 类org.hibernate.tool.hbm2ddl.SchemaUpdateScript 实例源码

项目:hibernate-conventions    文件:DDLConventions.java   
public List<String> generateUpdateScript() {
    List<String> sqls = new ArrayList<String>();
    List<SchemaUpdateScript> scripts = configuration.generateSchemaUpdateScriptList(dialect, getData());
    for (SchemaUpdateScript schemaUpdateScript : scripts) {
        sqls.add(schemaUpdateScript.getScript());
    }
    return sqls;
}
项目:pm-persistence-utils    文件:HibernateDDL.java   
protected static void updateCommand(String[] args) {
    String unitName, filename=null, url, username, password;
    if(args.length<5) System.out.println("Expected unitName jdbcUrl jdbcUsername jdbcPassword [filename]");
    else {
        unitName = args[1];
        url = args[2];
        username = args[3];
        password = args[4];
        if(args.length>5) filename = args[5];

        Configuration config = getConfiguration(unitName);
        Dialect dialect = Dialect.getDialect(config.getProperties());

        try {
            Connection conn = DriverManager.getConnection(url, username, password);

            DatabaseMetadata meta = new DatabaseMetadata(conn, dialect, config, true);

            List<SchemaUpdateScript> updateScriptList = config.generateSchemaUpdateScriptList(dialect, meta);
            String[] updateSQL = SchemaUpdateScript.toStringArray(updateScriptList);

            stringToStream(updateSQL, filename);
        } catch (SQLException e) {
            e.printStackTrace();
        }
    }
}
项目:lams    文件:Configuration.java   
/**
 * @param dialect The dialect for which to generate the creation script
 * @param databaseMetadata The database catalog information for the database to be updated; needed to work out what
 * should be created/altered
 *
 * @return The sequence of DDL commands to apply the schema objects
 *
 * @throws HibernateException Generally indicates a problem calling {@link #buildMappings()}
 *
 * @see org.hibernate.tool.hbm2ddl.SchemaUpdate
 * 
 * @deprecated Use {@link #generateSchemaUpdateScriptList(Dialect, DatabaseMetadata)} instead
 */
@SuppressWarnings({ "unchecked" })
@Deprecated
public String[] generateSchemaUpdateScript(Dialect dialect, DatabaseMetadata databaseMetadata)
        throws HibernateException {
    List<SchemaUpdateScript> scripts = generateSchemaUpdateScriptList( dialect, databaseMetadata );
    return SchemaUpdateScript.toStringArray( scripts );
}