Skip to content

Commit

Permalink
Use HibernateUtil instead of Factory to get hibernate properties for …
Browse files Browse the repository at this point in the history
…database migration
  • Loading branch information
GenieTim committed Nov 12, 2019
1 parent 4241aac commit b9d4261
Show file tree
Hide file tree
Showing 2 changed files with 11 additions and 2 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -31,6 +31,7 @@
import java.util.Iterator;
import java.util.List;
import java.util.Map;
import java.util.Properties;

/**
*
Expand Down Expand Up @@ -94,12 +95,16 @@ public static String listAllowedVersions() {
*/
public static void upgrade() {
// Load the Configuration from hibernate.cfg.xml
SessionFactoryImpl sessionFactory =
/*SessionFactoryImpl sessionFactory =
(SessionFactoryImpl) HibernateUtil.getSessionFactory();
Map<String, Object> properties = sessionFactory.getProperties();
String url = (String) properties.get("connection.url");
String username = (String) properties.get("connection.username");
String password = (String) properties.get("connection.password");
String password = (String) properties.get("connection.password");*/
Properties properties = HibernateUtil.getProperties();
String url = properties.getProperty("hibernate.connection.url");
String username = properties.getProperty("hibernate.connection.username");
String password = properties.getProperty("hibernate.connection.username");
// Create the Flyway instance and point it to the database
Flyway flyway =
Flyway.configure().dataSource(url, username, password).load();
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -54,6 +54,10 @@ public static void restartSessionFactory() {
sessionFactory = configuration.buildSessionFactory();
}

public static Properties getProperties() {
return HibernateUtil.properties;
}


/**
* Using the Hibernate configuration in Configuration from hibernate.cfg.xml
Expand Down

0 comments on commit b9d4261

Please sign in to comment.