I am currently fooling myself with a Spring installation. My goal is to use JPA to access the Websphere data source using this JNDI name. I use Data JPA to make life easier for me and have worked with some tutorials to get the basic idea.
The bad: none of them talk about Spring configuration for my JPA szenario +. I have never worked with JPA / JDBC before. Therefore, I hope you can help me here. I have two configuration files:
applicationContext.xml
<bean id="txManager"
class="org.springframework.orm.jpa.JpaTransactionManager">
<property name="sessionFactory" ref="sessionFactory" />
</bean>
<tx:annotation-driven transaction-manager="txManager" />
<bean id="eManager" class="org.springframework.orm.jpa.LocalEntityManagerFactoryBean"></bean>
Since I use @Transactual annotion in my code, I use an annotation-driven tag for txManager. I'm just not sure what else I need to configure for txManager and what the sessionFactory tag does. Is there any documentation for all supported XML tags? Am I missing a shortcut for my szenario?
The same goes for eManager - not sure if it is.
persistence.xml
<persistence version="1.0"
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">
<persistence-unit name="spring-jpa">
<jta-data-source>jdbc/myJNDI</jta-data-source>
</persistence-unit>
</persistence>
Same thing: I don't know what I'm doing. I know that I need a persistence block / provider. I know that many use hibernate for this, but I would like to stay native and use pure JavaEE / Spring, if possible. I just don’t know how to set it up. My project is currently crashing, telling me: "JPA PersistenceProvider returned null"
source
share