Announcement Announcement Module
Collapse
No announcement yet.
Spring + Spring Data JPA Configuration Page Title Module
Move Remove Collapse
X
Conversation Detail Module
Collapse
  • Filter
  • Time
  • Show
Clear All
new posts

  • Spring + Spring Data JPA Configuration

    currently I'm fooling around with my Spring setup. My goal is to use JPA to get access to a Websphere datasource using it's JNDI name. I'm using Spring Data JPA to make life easier for me and worked through some tutorials to get the basic idea.

    Bad thing: none of those is talking about the Spring configuration for my JPA szenario + I never worked with JPA / JDBC before. So I hope you can help me out here. I got 2 configuration files:

    applicationContext.xml
    Code:
    <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'm using the @Transactual annotion within my code, i'm using the annotation-driven tag for the txManager. I'm just not really sure what else i should configure for the txManager and what the sessionFactory tag is doing. Is there any documentation for all supported XML tags and XML configuration at all (API is just talking about the programatic way of doing, user manual is using different examples)? Am I missing a importent tag for my szenario?

    Same about eManager - not sure if thats right in any way or if i even need a EntityManager since i'm using the repository.

    persistence.xml
    Code:
    <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 here: don't really know what i'm doing. I know i need a persistence unit / provider. I know that many are using hibernate for this, but i would like to stay native and use pure JavaEE / Spring if possible. I'm just not sure how to configure that. Currently my project is crashing, telling me: "JPA PersistenceProvider returned null"
Working...
X