Created
July 24, 2015 18:38
-
-
Save dtelaroli/b586469f3956b1f654d9 to your computer and use it in GitHub Desktop.
Get Hibernate Schema Diff Script SQL
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
public class DbSchemaDiffTest { | |
@Test | |
public void load() { | |
HibernateUtil db = new HibernateUtil(); | |
Session session = db.getSession(); | |
session.doWork(new Work() { | |
@Override | |
public void execute(Connection connection) throws SQLException { | |
Configuration configuration = new Configuration(); | |
DatabaseMetadata metadata = new DatabaseMetadata(connection, new H2Dialect(), configuration.configure()); | |
List<SchemaUpdateScript> sa = configuration.generateSchemaUpdateScriptList(new H2Dialect(), metadata); | |
System.out.println("Schema update scripts:"); | |
for (SchemaUpdateScript s : sa) { | |
System.out.println(s.getScript()); | |
} | |
} | |
}); | |
session.close(); | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment