For public reference here is an answer I came up with:
Code:
public static void restoreDatabase() throws HibernateException
{
String backupPath = "c:/databaseBackup";
HibernateUtil.currentSession().flush();
HibernateUtil.currentSession().disconnect();
HibernateUtil.closeSession();
try {
DriverManager.getConnection("jdbc:derby:sampleDB;shutdown=true");
}
catch (SQLException ex) {
System.out.println(ex.toString());
}
sessionFactory.close();
Configuration configuration = new Configuration().configure();
String value = configuration.getProperty("hibernate.connection.url");
configuration.setProperty("hibernate.connection.url", value + ";restoreFrom=" + backupPath + "/sampleDB");
sessionFactory = configuration.buildSessionFactory();
}