Note that there are some explanatory texts on larger screens.

plurals
  1. POSpring integration test- database schema generation from another project
    text
    copied!<p>This is my setup for integration testing with spring and embedded database H2</p> <pre><code>&lt;?xml version="1.0" encoding="UTF-8"?&gt; &lt;beans xmlns="http://www.springframework.org/schema/beans" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns:jdbc="http://www.springframework.org/schema/jdbc" xsi:schemaLocation="http://www.springframework.org/schema/beans http://www.springframework.org/schema/beans/spring-beans-3.1.xsd http://www.springframework.org/schema/jdbc http://www.springframework.org/schema/jdbc/spring-jdbc.xsd"&gt; &lt;jdbc:embedded-database id="dataSource" type="H2" /&gt; &lt;jdbc:initialize-database data-source="dataSource"&gt; &lt;jdbc:script location="classpath:sql/globalParams.sql"/&gt; &lt;jdbc:script location="classpath:sql/customersGroupView.sql"/&gt; &lt;jdbc:script location="classpath:sql/recentIntegrationsTableAndTrigger.sql"/&gt; &lt;jdbc:script location="classpath:sql/insertIntegrationDate.sql"/&gt; &lt;jdbc:script location="classpath:sql/toCharRoutine.sql"/&gt; &lt;/jdbc:initialize-database&gt; &lt;/beans&gt; </code></pre> <p>Abstract parent of integration tests</p> <pre><code>@ContextConfiguration(locations = [ "classpath:com/dhl/dcc/dcc-core.xml", "classpath:com/dhl/dcc/test-security.xml", "classpath:com/dhl/dcc/dcc-audit.xml", "classpath:com/dhl/dcc/test-dataSource.xml", "classpath:com/dhl/dcc/test-beans.xml", "classpath:com/dhl/dcc/dcc-forms.xml" ]) public abstract class AbstractIntegrationTestCase extends AbstractTransactionalJUnit4SpringContextTests { </code></pre> <p>and in core cofiguration of entity manager factory</p> <pre><code>&lt;property name="generateDdl" value="${dcc.orm.generateDdl:false}"/&gt; </code></pre> <p>property dcc.orm.generateDdl is set to true in properties.</p> <p>It worked well (database schema was generated from classes annotated @Entity) but now i separated domain model into its own project and added this project as dependency in Maven. After that my integration tests starting to fail because of missing db schema. How do i configure where should embedded database look for a domain model? Thanks.</p> <p>edit: entity factory configuration</p> <pre><code>&lt;bean id="entityManagerFactory" class="org.springframework.orm.jpa.LocalContainerEntityManagerFactoryBean"&gt; &lt;property name="dataSource" ref="dataSource"/&gt; &lt;property name="persistenceUnitName" value="DCC"/&gt; &lt;property name="jpaVendorAdapter"&gt; &lt;bean class="org.springframework.orm.jpa.vendor.HibernateJpaVendorAdapter"&gt; &lt;property name="generateDdl" value="${dcc.orm.generateDdl:false}"/&gt; &lt;property name="showSql" value="${dcc.orm.showSql:false}"/&gt; &lt;property name="databasePlatform" value="${dcc.orm.dialect}"/&gt; &lt;/bean&gt; &lt;/property&gt; &lt;/bean&gt; </code></pre>
 

Querying!

 
Guidance

SQuiL has stopped working due to an internal error.

If you are curious you may find further information in the browser console, which is accessible through the devtools (F12).

Reload