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

  • Spring+OpenJPA+MySQL+Tomcat6 Data removing

    Hi,

    I'm trying to configure OpenJPA. My configuration is below
    Code:
    <bean id="jpa.vendor.JpaAdaptor"
              class="org.springframework.orm.jpa.vendor.OpenJpaVendorAdapter">
            <property name="showSql" value="true"/>
            <property name="generateDdl" value="true" />
            <property name="database" value="MYSQL"/>
            <property name="databasePlatform"
                      value="org.apache.openjpa.jdbc.sql.MySQLDictionary">
            </property>
        </bean>
    
        <bean id="facebookEntityManagerFactory"
              class="org.springframework.orm.jpa.LocalContainerEntityManagerFactoryBean">
            <property name="dataSource" ref="facebookDataSource"/>
            <property name="loadTimeWeaver">
                  <bean class="org.springframework.instrument.classloading.ReflectiveLoadTimeWeaver"/>
            </property>
            <property name="persistenceUnitManager" ref="jpa.persistence.unit.Manager"/>
            <property name="persistenceUnitName" value="jpa.persistence.unit.facebook"/>
            <property name="jpaDialect">
                  <bean class="org.springframework.orm.jpa.vendor.OpenJpaDialect"/>
            </property>
            <property name="jpaVendorAdapter">
                  <ref bean="jpa.vendor.JpaAdaptor"/>
            </property>
        </bean>
    All works fine but the data modification and removing.
    When I'm calling method remove(), nothing really happens

    Code:
    @Transactional
        public void removeFacebookCustomer(final String id){
            logger.info("Trying to remove customer with id " + customer.getCustomerFacebookId());        
            Customer c = new Customer();
            c.setCustomerFacebookId(id);
            this.getJpaTemplate().remove(c);
            return;
        }
    Also, in the log file there is a SELECT instead of DELETE query.

    Code:
    20.04.2009 17:12:12 com.donriver.mfs.facebook.pojo.FacebookPersistanceManagerImpl removeFacebookCustomer
    INFO: Trying to remove customer with id 000000
    892342  jpa.persistence.unit.facebook  TRACE  [http-8081-1] openjpa.jdbc.SQL - <t 161080, conn 22923041> executing prepstmnt 13825521 SELECT t0.customer_facebook_email, t0.customer_id, t0.status FROM CUSTOMER t0 WHERE t0.customer_facebook_id = ? [params=(String) 000000]
    892342  jpa.persistence.unit.facebook  TRACE  [http-8081-1] openjpa.jdbc.SQL - <t 161080, conn 22923041> [0 ms] spent
    What I do wrong?

    Appreciate any help. Thanks

  • #2
    Modifying (insert/delete/update) anything in the database without transactions is useless. It does nothing. Configure a transactionmanager and provide some transaction configuration (read chapter 9 of the reference guide).

    Comment


    • #3
      The transaction manager is defined i did not include the part of the code as i suppose there is no problem with it. Sorry.


      Code:
          <bean id="facebookTransactionManager" class="org.springframework.orm.jpa.JpaTransactionManager">
              <property name="dataSource" ref="facebookDataSource" />
              <property name="entityManagerFactory" ref="facebookEntityManagerFactory"/>
          </bean>
      
          <!-- enable the configuration of transactional behavior based on annotations -->
          <tx:annotation-driven transaction-manager="facebookTransactionManager" />

      Comment


      • #4
        Thanks for all. The problem was closed

        Comment

        Working...
        X