How to initialize in-memory HSQLDB using script via Spring

前端 未结 5 1501
死守一世寂寞
死守一世寂寞 2020-12-12 15:29

I am attempting to do unit testing of my DAO (using Spring and Hibernate). I am using HSQLDB per this tutorial. The tutorial states that the in-memory HSQLDB database can be

5条回答
  •  盖世英雄少女心
    2020-12-12 16:35

    You could get around this by creating a subclass of BasicDataSource with getters/setters for two new properties, initExecuteSqlFile and destroyExecuteSqlFile, that can have a comma-seperated list of SQL files to execute. The subclass would have init() and destroy() methods that handle the init/destroy SQL files.

    Then use the following bean definition:

    
        
            h2-destroy-01.sql
        
        
            h2-init-01.sql,h2-init-02.sql,h2-init-03.sql
        
        
    
    

提交回复
热议问题