Ok - I think what I need to do to fix this is 1 of 2 things. I can either (1) flush the hibernate session, or (2) instead of using simpleJdbcTemplate to make select statements directly use a Hibernate Session from the EntityManager and do it that way. I don't know how to go about doing either from my current setup.
If I am using a JPA EntityManagerFacotry, how do I get the Hibernate session?
Below is my snippet I'm using to test with:
Code:
<bean id="entityManagerFactory"
class="org.springframework.orm.jpa.LocalContainerEntityManagerFactoryBean">
<property name="dataSource" ref="dataSource" />
<property name="jpaVendorAdapter">
<bean class="org.springframework.orm.jpa.vendor.HibernateJpaVendorAdapter">
<property name="generateDdl" value="true" />
<property name="showSql" value="true" />
<property name="database" value="HSQL" />
</bean>
</property>
<property name="persistenceUnitName" value="persist.name" />
</bean>
<bean id="transactionManager" class="org.springframework.orm.jpa.JpaTransactionManager">
<property name="entityManagerFactory" ref="entityManagerFactory" />
</bean>
<jdbc:embedded-database id="dataSource" type="HSQL" />
<jdbc:initialize-database>
<jdbc:script location="classpath:testData.sql" />
</jdbc:initialize-database>
<jpa:repositories base-package="com.company.app" />
<tx:annotation-driven />