In the Java project I'm working on, I have the following setup for our unit tests:
- I use Spring Test MVC,
@RunWith(SpringJUnit4ClassRunner.class) and @WebAppConfiguration to run unit tests, and I create an instance of MockMvc using webAppContextSetup(webApplicationContext) to test the application. - I have a Hibernate configuration to configure HSQLDB in memory, all tables are created based on @Entity classes.
- In the Hibernate configuration, I set the
hibernate.hbm2ddl.import_files property to load the import.sql file using SQL statements to populate the database (in memory).
Now I have confirmed all these works:
- Tests can be successfully inserted / retrieved from the database in memory.
- The SQL statements in
import.sql are executed, as various tests confirm.
Now the problem . Errors that occur with the operators that I add to import.sql do not appear to be reported anywhere, none of the indications provided that an error occurred at all. Instead, subsequent statements are simply not executed. (I confirmed this by testing.)
Is there a way or to put these errors in messages that I apparently do not suspect? For this there is an additional property Hibernate?
Excerpt from sleep configuration:
<bean id="sessionFactory" name="mySessionFactory" class="org.springframework.orm.hibernate4.LocalSessionFactoryBean"> <property name="dataSource" ref="myDataSource" /> <property name="hibernateProperties"> <props> <prop key="hibernate.archive.autodetection">class,hbm</prop> <prop key="hibernate.dialect">org.hibernate.dialect.HSQLDialect</prop> <prop key="hibernate.show_sql">true</prop> <prop key="hibernate.connection.driver_class">org.hsqldb.jdbcDriver</prop> <prop key="hibernate.connection.username">sa</prop> <prop key="hibernate.connection.password"></prop> <prop key="hibernate.connection.url">jdbc:hsqldb:mem:myschema</prop> <prop key="hibernate.hbm2ddl.auto">create</prop> <prop key="hibernate.hbm2ddl.import_files">configuration/test/import.sql</prop> <prop key="hibernate.hbm2ddl.import_files_sql_extractor">org.hibernate.tool.hbm2ddl.MultipleLinesSqlCommandExtractor</prop> <prop key="hibernate.query.substitutions">true 'Y', false 'N'</prop> </props> </property> </bean>
source share