I was wondering if there is a way to get the default schema name from session factory, somehow? The reason I need to get it is because I have to use a one native SQL and I have
This will do the trick:
SessionFactoryImplementor sfi = (SessionFactoryImplementor) getSessionFactory();
Settings settings = sfi.getSettings();
ConnectionProvider connectionProvider = settings.getConnectionProvider();
try {
Connection connection = connectionProvider.getConnection();
DatabaseMetaData databaseMetaData = connection.getMetaData();
String url = databaseMetaData.getURL();
//substring the string to what you want
System.out.println(url);
} catch (SQLException e) {
//throw something
}