Results 1 to 4 of 4

Thread: Spring+OpenJPA+MySQL+Tomcat6 Data removing

  1. #1
    Join Date
    Apr 2009
    Posts
    3

    Default 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. #2
    Join Date
    Jun 2006
    Location
    The Netherlands
    Posts
    13,632

    Default

    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).
    Marten Deinum
    Java Consultant / Pragmatist / Open Source Enthousiast / Author


    Pro Spring MVC: With Web Flow
    Conspect

    Have you read the reference guide.
    Use the [ code ] tags, young padawan

  3. #3
    Join Date
    Apr 2009
    Posts
    3

    Default

    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" />

  4. #4
    Join Date
    Apr 2009
    Posts
    3

    Default

    Thanks for all. The problem was closed

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •