Spring 3 MVC Hibernate Hsqldb Embedded database

In this tutorial we will create simple Spring 3 MVC application with Hsqldb as embedded database.
We will start with project created in previuos tutorial, where we were using H2 database.

All we need to do is just add maven dependency:

<!-- HSQL -->

and tell Spring and Hibernate to use it:

<!-- Use in-memory embedded HSQL database -->
<jdbc:embedded-database id="dataSource" type="HSQL">

<!-- Database managed by Hibernate -->
<bean id="entityManagerFactory" class="org.springframework.orm.jpa.LocalContainerEntityManagerFactoryBean">
    <property name="persistenceUnitName" value="UsersPU" />
    <property name="dataSource" ref="dataSource" />
    <property name="packagesToScan" >
    <property name="persistenceProvider">
        <bean class="org.hibernate.jpa.HibernatePersistenceProvider" />
    <property name="jpaProperties">
            <entry key="hibernate.dialect" value="org.hibernate.dialect.HSQLDialect" />
            <entry key="hibernate.hbm2ddl.auto" value="create" />
            <entry key="hibernate.hbm2ddl.import_files" value="import_data.sql" />
            <entry key="hibernate.show_sql" value="true" />

<bean id="transactionManager"
    <property name="entityManagerFactory" ref="entityManagerFactory" />

<tx:annotation-driven transaction-manager="transactionManager" />

The project sources can be downloaded here.

Leave a Reply

Your email address will not be published. Required fields are marked *