Announcement Announcement Module
No announcement yet.
Jpa inserts not committing Page Title Module
Move Remove Collapse
Conversation Detail Module
  • Filter
  • Time
  • Show
Clear All
new posts

  • Jpa inserts not committing

    I'm using Spring 3.0.2.RELEASE with EclipseLink 2.0 and running inside of GlassFish 3. I'm building with Maven, although that shouldn't matter and running my unit tests with JUnit. I'm using a Dao patter that is leveraging the JpaTemplate by holding onto a reference of the JpaTemplate within my BaseDao and delegating all calls to it. My Unit Test is simple; insert 6 entities, but none appear in the database table. I've tried this with both a Derby in-memory database and a server instance of Derby. Both result in the same: no data being inserted. I can see EclipseLink being loaded and creating the database tables, so I know that there is connectivity to the database, but I can't seem to figure out why my inserts are not appearing.

    I've configured EclipseLink to log all statements, but I don't see the insert statements in the log file, which leads me to believe that they are actually not executing against the database.

    Below is my configuration:

    Base Dao:
    public abstract class BaseDaoImpl<T, PK extends>
        implements BaseDao<T, PK> {
        protected JpaTemplate jpaTemplate;
        public void setEntityManager(EntityManager entityManager) {
            jpaTemplate = new JpaTemplate(entityManager);
        public void create(T entity) {
    My Spring configuration:
        <context:annotation-config />
        <jee:jndi-lookup id="myDataSource" jndi-name="jdbc/myDataSource"/>
    	<bean id="transactionManager" class="org.springframework.orm.jpa.JpaTransactionManager">
    		<property name="entityManagerFactory" ref="entityManagerFactory" />
    		<property name="dataSource" ref="myDataSOurce"/>
    	<bean id="entityManagerFactory" class="org.springframework.orm.jpa.LocalContainerEntityManagerFactoryBean">
              <property name="jpaVendorAdapter">
                  <bean class="org.springframework.orm.jpa.vendor.EclipseLinkJpaVendorAdapter">
                      <property name="showSql" value="true" />
              <property name="jpaDialect">
                  <bean class="org.springframework.orm.jpa.vendor.EclipseLinkJpaDialect" />
              <property name="persistenceUnitName" value="my-pu"/>
    <persistence version="2.0" xmlns="" xmlns:xsi="" xsi:schemaLocation="">
      <persistence-unit name="my-pu" transaction-type="JTA">
          <property name="eclipselink.weaving" value="static" />
          <property name="eclipselink.ddl-generation" value="create-tables"/>
          <property name="eclipselink.logging.level" value="ALL"/>
          <property name="eclipselink.logging.exceptions" value="true" />
          <property name="eclipselink.jdbc.native-sql" value="true"/>
          <property name="eclipselink.jdbc.cache-statements" value="true"/>
          <property name="" value="Auto"/>
          <property name="eclipselink.jdbc.exclusive-connection.mode" value="Transactional"/>
          <property name="eclipselink.logging.logger" value="ServerLogger"/>
          <property name="eclipselink.weaving" value="static"/>      

    Thank you for the help...

  • #2
    I resolved it. It seems that I had two transaction managers defined that was causing some confusion as to which one was used.


    <bean id="transactionManager" class="org.springframework.orm.jpa.JpaTransactionManager">
    		<property name="entityManagerFactory" ref="entityManagerFactory" />
    		<property name="dataSource" ref="myDataSOurce"/>
    Now I only need to figure out how to configure everything to work with JTA.