Könnten Sie mir bitte einige Beispiele für die Aktualisierung von Datenbanktabellen aus Java-Code mit Hibernate Entity-Klassen und Liquibase geben.Liquibase Hibernate-Tabellen-Update von Java-Code
Etwas Ähnliches, aber für die Klassen kommentierten
Connection connection = null;
try {
connection = DriverManager.getConnection("jdbc:postgresql://localhost:5432/dvdrental", "postgres", "admin");
Database database = DatabaseFactory.getInstance().findCorrectDatabaseImplementation(new JdbcConnection(connection));
Liquibase liquibase = new Liquibase("C:/changelog.xml", new FileSystemResourceAccessor(), database);
liquibase.update(new Contexts());
} catch (SQLException | LiquibaseException e) {
e.printStackTrace();
} finally {
if (connection != null) {
try {
connection.rollback();
connection.close();
} catch (SQLException e) {
e.printStackTrace();
}
}
}
hibernate.hbm2ddl.auto = Update ist keine gute Idee http hilfreich sein://stackoverflow.com/questions/221379/hibernate-hbm2ddl-auto-update-in-production. java -cp hibernate_classpaths org.hibernate.tool.hbm2ddl.SchemaExport Optionen mapping_files - wir dynamisch erweiterbare entwickeln, es ist also keine Option –
kann sein, wird dieser Link hilfreich sein http://www.baeldung.com/liquibase -Refaktor-Schema-von-Java-App – vexan