我的应用程序中有entitymanager问题。它不会保留对象DB ../java/resources/META-INF/persistence.xmlEntitymanager不会持续
<persistence-unit name="dataSource" transaction-type="RESOURCE_LOCAL">
</persistence-unit>
../java/resources/database/DataSource.xml
<bean class="org.springframework.beans.factory.config.PropertyPlaceholderConfigurer">
<property name="location">
<value>classpath:properties/database.properties</value>
</property>
</bean>
<bean id="dataSource" class="org.springframework.jdbc.datasource.DriverManagerDataSource">
<property name="driverClassName" value="${jdbc.driverClassName}" />
<property name="url" value="${jdbc.url}" />
<property name="username" value="${jdbc.username}" />
<property name="password" value="${jdbc.password}" />
</bean>
。 ./java/webapp/WEB-INF/applicationContext.xml
<context:annotation-config />
<context:component-scan base-package="com.springapp.mvc" />
<mvc:annotation-driven/>
<import resource="classpath:database/DataSource.xml"/>
<bean class="org.springframework.orm.jpa.support.PersistenceAnnotationBeanPostProcessor" />
<bean id="entityManagerFactory" class="org.springframework.orm.jpa.LocalContainerEntityManagerFactoryBean">
<property name="jpaVendorAdapter">
<bean class="org.springframework.orm.jpa.vendor.HibernateJpaVendorAdapter">
<property name="showSql" value="true" />
<property name="generateDdl" value="true" />
<property name="databasePlatform" value="org.hibernate.dialect.PostgreSQL82Dialect" />
</bean>
</property>
<property name="dataSource" ref="dataSource" />
</bean>
<tx:annotation-driven transaction-manager="transactionManager" />
<bean id="transactionManager" class="org.springframework.orm.jpa.JpaTransactionManager">
<property name="dataSource" ref="dataSource" />
<property name="entityManagerFactory" ref="entityManagerFactory" />
</bean>
</beans>
它有什么问题?
给定的代码是否在事务中运行?是否有任何异常抛出 – 2013-04-30 03:19:18
代码正在运行,没有例外,但它不会持续 – Yeynno 2013-04-30 09:23:12