
Originally Posted by
Marten Deinum
Can you post your full configuration and your dao...
Persistence.xml
HTML Code:
<?xml version="1.0" encoding="UTF-8"?>
<persistence xmlns="http://java.sun.com/xml/ns/persistence"
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xsi:schemaLocation="http://java.sun.com/xml/ns/persistence
http://java.sun.com/xml/ns/persistence/persistence_1_0.xsd"
version="1.0">
<persistence-unit name="milins-domain"
transaction-type="RESOURCE_LOCAL">
<provider>
org.eclipse.persistence.jpa.PersistenceProvider
</provider>
<!-- <jta-data-source>jdbc/milinsDataSource</jta-data-source>-->
<class>myPackage.myClass1</class>
<class>myPackage.myClass2</class>
<class>myPackage.myClass3</class>
</persistence-unit>
<persistence-unit name="levfr-domain"
transaction-type="RESOURCE_LOCAL">
<provider>
org.eclipse.persistence.jpa.PersistenceProvider
</provider>
<class>myPackage.myClass4</class>
</persistence-unit>
</persistence>
Spring-master.xml
HTML Code:
<?xml version="1.0" encoding="UTF-8"?>
<beans xmlns="http://www.springframework.org/schema/beans"
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns:aop="http://www.springframework.org/schema/aop"
xmlns:context="http://www.springframework.org/schema/context"
xmlns:jdbc="http://www.springframework.org/schema/jdbc" xmlns:jee="http://www.springframework.org/schema/jee"
xmlns:tx="http://www.springframework.org/schema/tx" xmlns:util="http://www.springframework.org/schema/util"
xsi:schemaLocation="http://www.springframework.org/schema/beans http://www.springframework.org/schema/beans/spring-beans-3.0.xsd
http://www.springframework.org/schema/aop http://www.springframework.org/schema/aop/spring-aop-3.0.xsd
http://www.springframework.org/schema/context http://www.springframework.org/schema/context/spring-context-3.0.xsd
http://www.springframework.org/schema/jdbc http://www.springframework.org/schema/jdbc/spring-jdbc-3.0.xsd
http://www.springframework.org/schema/jee http://www.springframework.org/schema/jee/spring-jee-3.0.xsd
http://www.springframework.org/schema/tx http://www.springframework.org/schema/tx/spring-tx-3.0.xsd
http://www.springframework.org/schema/util http://www.springframework.org/schema/util/spring-util-3.0.xsd">
<bean
class="org.springframework.beans.factory.config.PropertyPlaceholderConfigurer">
<property name="locations">
<list>
<!-- <value>classpath:projectsettings.properties</value> -->
<value>file:${user.home}/milins.properties</value>
<value>file:${user.home}/milins.test.properties</value>
</list>
</property>
<property name="ignoreResourceNotFound" value="false" />
</bean>
<context:component-scan base-package="se.lantmateriet.milins">
<!-- <context:exclude-filter expression="org.springframework.stereotype.Controller" type="annotation"/>-->
<context:exclude-filter expression="org.springframework.stereotype.Repository" type="annotation"/>
</context:component-scan>
<!-- This will ensure that hibernate or jpa exceptions are automatically translated into
Spring's generic DataAccessException hierarchy -->
<bean class="org.springframework.dao.annotation.PersistenceExceptionTranslationPostProcessor"/>
<import resource="spring-datasource.xml"/>
<!--We should import spring-jpa.xml if we would like to use JPA (EntityManager)-->
<import resource="spring-eclipselink.xml" />
</beans>
Spring-datasource.xml
HTML Code:
<?xml version="1.0" encoding="UTF-8" standalone="no"?>
<beans xmlns="http://www.springframework.org/schema/beans"
xmlns:p="http://www.springframework.org/schema/p" xmlns:jee="http://www.springframework.org/schema/jee"
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xsi:schemaLocation="http://www.springframework.org/schema/beans http://www.springframework.org/schema/beans/spring-beans-3.0.xsd
http://www.springframework.org/schema/jee http://www.springframework.org/schema/jee/spring-jee-3.0.xsd">
<bean id="milinsDataSource"
class="org.springframework.jdbc.datasource.SingleConnectionDataSource"
p:driverClassName="${jdbc.driverclassname}"
p:url="${milins.jdbc.url}"
p:suppressClose="true"
p:username="${milins.jdbc.username}"
p:password="${milins.jdbc.password}"/>
<!--This setting should be used when we will start using JBoss (an AS)-->
<!-- <bean id="milinsDataSource" class="org.springframework.jndi.JndiObjectFactoryBean"-->
<!-- p:jndiName="jdbc/milinsDataSource" p:resourceRef="true" />-->
<bean id="levfrDataSource"
autowire-candidate="false"
class="org.springframework.jdbc.datasource.SingleConnectionDataSource"
p:driverClassName="${jdbc.driverclassname}"
p:url="${levfr.jdbc.url}"
p:suppressClose="true"
p:username="${levfr.jdbc.username}"
p:password="${levfr.jdbc.password}"/>
<!-- <bean id="levfrDataSource" class="org.springframework.jndi.JndiObjectFactoryBean"-->
<!-- p:jndiName="jdbc/levfrDataSource" p:resourceRef="true" />-->
</beans>
Spring.eclipselink.xml
HTML Code:
<?xml version="1.0" encoding="UTF-8" standalone="no"?>
<beans xmlns="http://www.springframework.org/schema/beans"
xmlns:p="http://www.springframework.org/schema/p" xmlns:tx="http://www.springframework.org/schema/tx"
xmlns:aop="http://www.springframework.org/schema/aop" xmlns:context="http://www.springframework.org/schema/context"
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xsi:schemaLocation="http://www.springframework.org/schema/beans
http://www.springframework.org/schema/beans/spring-beans-3.0.xsd
http://www.springframework.org/schema/context
http://www.springframework.org/schema/context/spring-context-3.0.xsd
http://www.springframework.org/schema/tx
http://www.springframework.org/schema/tx/spring-tx-3.0.xsd">
<bean id="jpaVendorAdapter"
class="org.springframework.orm.jpa.vendor.EclipseLinkJpaVendorAdapter"
p:databasePlatform="org.eclipse.persistence.platform.database.OraclePlatform"
p:generateDdl="false" p:showSql="true" />
<!-- Milins Hibernate EntityManagerFactory -->
<bean id="milinsEntityManagerFactory"
class="org.springframework.orm.jpa.LocalContainerEntityManagerFactoryBean"
p:persistenceXmlLocation="classpath*:META-INF/persistence.xml"
p:dataSource-ref="milinsDataSource" p:jpaVendorAdapter-ref="jpaVendorAdapter"
p:persistenceUnitName="milins-domain">
<property name="jpaDialect">
<bean class="org.springframework.orm.jpa.vendor.EclipseLinkJpaDialect" />
</property>
<property name="jpaProperties">
<props>
<prop key="eclipselink.weaving">false</prop><!-- <prop key="eclipselink.ddl-generation">drop-and-create-tables</prop>
<prop key="eclipselink.ddl-generation.output-mode">sql-script</prop> -->
<prop key="eclipselink.application-location">src/test/resources/</prop>
<!-- Make us participate in JBoss JTA transactions -->
<!-- <prop key="eclipselink.target-server">org.eclipse.persistence.platform.server.jboss.JBossPlatform</prop> -->
</props>
</property>
</bean>
<bean id="milinsEntityManager"
class="org.springframework.orm.jpa.support.SharedEntityManagerBean"
p:entityManagerFactory-ref="milinsEntityManagerFactory" />
<bean id="milinsTransactionManager" class="org.springframework.orm.jpa.JpaTransactionManager"
p:entityManagerFactory-ref="milinsEntityManagerFactory" />
<!-- LevFR Hibernate SessionFactory -->
<bean id="levfrEntityManagerFactory"
class="org.springframework.orm.jpa.LocalContainerEntityManagerFactoryBean"
p:persistenceXmlLocation="classpath*:META-INF/persistence.xml"
p:dataSource-ref="levfrDataSource" p:jpaVendorAdapter-ref="jpaVendorAdapter"
p:persistenceUnitName="levfr-domain">
<property name="jpaDialect">
<bean class="org.springframework.orm.jpa.vendor.EclipseLinkJpaDialect" />
</property>
<property name="jpaProperties">
<props>
<prop key="eclipselink.weaving">false</prop><!-- <prop key="eclipselink.ddl-generation">drop-and-create-tables</prop>
<prop key="eclipselink.ddl-generation.output-mode">sql-script</prop> -->
<prop key="eclipselink.application-location">src/test/resources/</prop>
<!-- Make us participate in JBoss JTA transactions -->
<!-- <prop key="eclipselink.target-server">org.eclipse.persistence.platform.server.jboss.JBossPlatform</prop> -->
</props>
</property>
</bean>
<bean id="levfrEntityManager"
class="org.springframework.orm.jpa.support.SharedEntityManagerBean"
p:entityManagerFactory-ref="levFREntityManagerFactory" />
<bean id="levfrTransactionManager" class="org.springframework.orm.jpa.JpaTransactionManager"
p:entityManagerFactory-ref="levFREntityManagerFactory" />
<!-- Read in DAOs from the eclipselink package -->
<context:component-scan base-package="se.lantmateriet.milins.dao.eclipselink" />
<!-- Enable @Repository, @PersistenceContext support -->
<bean
class="org.springframework.orm.jpa.support.PersistenceAnnotationBeanPostProcessor" />
<!-- Enable @Transactional support -->
<tx:annotation-driven />
</beans>
one of my dao in next post....