HsqlDbUtils.java 文件源码

java
阅读 23 收藏 0 点赞 0 评论 0

项目:elpaaso-core 作者:
/**
 * make an hsql database snapshot (txt file)
 * SCRIPT native query is used
 *    doc : http://www.hsqldb.org/doc/2.0/guide/management-chapt.html#N144AE
 * @param deleteIfExists
 * @return
 * @throws Exception
 */
@Transactional(propagation = Propagation.REQUIRED, isolation = Isolation.DEFAULT)
public DbSnapshot makeDatabaseSnapshot(boolean deleteIfExists) throws Exception {
    File snapshotfile = new File(giveMeSnapshotName());
    if (snapshotfile.exists() && deleteIfExists) {
        snapshotfile.delete();
    }
    if (snapshotfile.exists()) {
        throw new Exception("unable to snapshot : file already exists " + snapshotfile.getAbsolutePath());
    }
    // String exportFileAbsolutePath = snapshotfile.getAbsolutePath();
    // String hsqldbExport = "SCRIPT " + exportFileAbsolutePath.replaceAll("\\\\","/");
    String hsqldbExport = "SCRIPT '" + snapshotfile.getName() + "'";
    logger.info("export query :{}", hsqldbExport);
    Query nativeQuery = em.createNativeQuery(hsqldbExport);
    nativeQuery.executeUpdate();
    return new DbSnapshot(snapshotfile);
}
评论列表
文章目录


问题


面经


文章

微信
公众号

扫码关注公众号