open jpa support

This commit is contained in:
Keith Donald
2007-11-16 21:03:06 +00:00
parent 35d7e3e1bd
commit 4eb9192b70
3 changed files with 22 additions and 29 deletions

View File

@@ -10,7 +10,6 @@
<classpathentry kind="lib" path="lib/buildtime/cglib.jar"/>
<classpathentry kind="lib" path="lib/test/clover.jar"/>
<classpathentry kind="lib" path="lib/buildtime/commons-beanutils.jar"/>
<classpathentry kind="lib" path="lib/buildtime/commons-collections.jar"/>
<classpathentry kind="lib" path="lib/buildtime/commons-digester.jar"/>
<classpathentry kind="lib" path="lib/buildtime/commons-fileupload.jar"/>
<classpathentry kind="lib" path="lib/buildtime/commons-logging.jar"/>
@@ -21,12 +20,7 @@
<classpathentry kind="lib" path="lib/buildtime/ehcache.jar"/>
<classpathentry kind="lib" path="lib/buildtime/el-api.jar"/>
<classpathentry kind="lib" path="lib/buildtime/hibernate.jar"/>
<classpathentry kind="lib" path="lib/test/hibernate-annotations.jar"/>
<classpathentry kind="lib" path="lib/test/hibernate-commons-annotations.jar"/>
<classpathentry kind="lib" path="lib/test/hibernate-entitymanager.jar"/>
<classpathentry kind="lib" path="lib/test/hsqldb.jar"/>
<classpathentry kind="lib" path="lib/test/javassist.jar"/>
<classpathentry kind="lib" path="lib/test/jboss-common-core.jar"/>
<classpathentry kind="lib" path="lib/buildtime/jta.jar"/>
<classpathentry kind="lib" path="lib/buildtime/junit.jar"/>
<classpathentry kind="lib" path="lib/global/ognl.jar"/>
@@ -48,5 +42,9 @@
<classpathentry kind="lib" path="lib/buildtime/spring-webmvc-portlet.jar"/>
<classpathentry kind="lib" path="lib/buildtime/struts.jar"/>
<classpathentry kind="lib" path="lib/buildtime/xalan.jar"/>
<classpathentry kind="lib" path="lib/test/openjpa.jar"/>
<classpathentry kind="lib" path="lib/test/commons-lang.jar"/>
<classpathentry kind="lib" path="lib/test/serp.jar"/>
<classpathentry kind="lib" path="lib/test/commons-collections.jar"/>
<classpathentry kind="output" path="target/classes"/>
</classpath>

View File

@@ -69,9 +69,21 @@
<dependency org="org.springframework" name="spring-jdbc" rev="2.5-rc2" conf="test->default" />
<dependency org="org.springframework" name="spring-test" rev="2.5-rc2" conf="test->default" />
<dependency org="org.hibernate" name="hibernate" rev="3.2.5.ga" conf="buildtime, test->default" />
<dependency org="org.hibernate" name="hibernate-entitymanager" rev="3.3.1.ga" conf="test->default" />
<dependency org="org.hibernate" name="hibernate-commons-annotations" rev="3.3.0.ga" conf="test->default" />
<dependency org="org.apache.openjpa" name="openjpa" rev="1.0.1" conf="test->default">
<!-- Exclusions required because open jpa pom is poorly designed -->
<exclude module="openjpa-lib" />
<exclude module="openjpa-kernel" />
<exclude module="openjpa-kernel-5" />
<exclude module="openjpa-jdbc" />
<exclude module="openjpa-jdbc-5" />
<exclude module="openjpa-persistence" />
<exclude module="openjpa-persistence-jdbc" />
<exclude module="openjpa-xmlstore" />
</dependency>
<!-- lang and serp required by open jpa -->
<dependency org="commons-lang" name="commons-lang" rev="2.1" conf="test->default" />
<dependency org="commons-collections" name="commons-collections" rev="3.2" conf="test->default" />
<dependency org="net.sourceforge.serp" name="serp" rev="1.13.1" conf="test->default" />
</dependencies>
</ivy-module>

View File

@@ -8,13 +8,12 @@ import javax.sql.DataSource;
import junit.framework.TestCase;
import org.hibernate.Hibernate;
import org.springframework.jdbc.core.JdbcTemplate;
import org.springframework.jdbc.datasource.DriverManagerDataSource;
import org.springframework.orm.jpa.JpaTemplate;
import org.springframework.orm.jpa.JpaTransactionManager;
import org.springframework.orm.jpa.LocalContainerEntityManagerFactoryBean;
import org.springframework.orm.jpa.vendor.HibernateJpaVendorAdapter;
import org.springframework.orm.jpa.vendor.OpenJpaVendorAdapter;
import org.springframework.transaction.support.TransactionSynchronizationManager;
import org.springframework.webflow.engine.EndState;
import org.springframework.webflow.execution.FlowExecutionException;
@@ -178,22 +177,6 @@ public class JpaFlowExecutionListenerTests extends TestCase {
assertSessionNotBound();
}
public void testLazilyInitalizedCollection() {
MockRequestContext context = new MockRequestContext();
MockFlowSession flowSession = new MockFlowSession();
flowSession.getDefinitionInternal().getAttributeMap().put("persistenceContext", "true");
jpaListener.sessionStarting(context, flowSession, null);
context.setActiveSession(flowSession);
assertSessionBound();
TestBean bean = (TestBean) jpaTemplate.getReference(TestBean.class, Long.valueOf(0));
assertFalse("addresses should not be initialized", Hibernate.isInitialized(bean.getAddresses()));
jpaListener.paused(context);
assertFalse("addresses should not be initialized", Hibernate.isInitialized(bean.getAddresses()));
Hibernate.initialize(bean.getAddresses());
assertTrue("addresses should be initialized", Hibernate.isInitialized(bean.getAddresses()));
}
private DataSource getDataSource() {
DriverManagerDataSource dataSource = new DriverManagerDataSource();
dataSource.setDriverClassName("org.hsqldb.jdbcDriver");
@@ -236,8 +219,8 @@ public class JpaFlowExecutionListenerTests extends TestCase {
LocalContainerEntityManagerFactoryBean factory = new LocalContainerEntityManagerFactoryBean();
factory.setDataSource(dataSource);
factory.setPersistenceXmlLocation("classpath:org/springframework/webflow/persistence/persistence.xml");
HibernateJpaVendorAdapter hibernate = new HibernateJpaVendorAdapter();
factory.setJpaVendorAdapter(hibernate);
OpenJpaVendorAdapter openJpa = new OpenJpaVendorAdapter();
factory.setJpaVendorAdapter(openJpa);
factory.afterPropertiesSet();
return factory.getObject();
}