0 Replies Latest reply on Oct 22, 2007 5:12 AM by Lars Andreasen

    Changing DB from mySql - oracle having persistance problems

    Lars Andreasen Newbie

      Hey.

      We had our tests with EJB3 in an mysql db and it worked fine, but we have to change db to Oracle now, and that caused alot of problems.
      I hope someone can give me some pointers to what i am doing wrong, and what i am doing right, i have tried with transaktions, but without any effect.

      The error i get is:

      10:53:10,147 ERROR [STDERR] javax.ejb.EJBException: javax.persistence.PersistenceException: org.hibernate.HibernateException: this instance does not yet exist as a row in the database
      10:53:10,147 ERROR [STDERR] at org.jboss.ejb3.tx.Ejb3TxPolicy.handleExceptionInOurTx(Ejb3TxPolicy.java:69)
      10:53:10,147 ERROR [STDERR] at org.jboss.aspects.tx.TxPolicy.invokeInOurTx(TxPolicy.java:83)
      10:53:10,147 ERROR [STDERR] at org.jboss.aspects.tx.TxInterceptor$Required.invoke(TxInterceptor.java:191)
      10:53:10,147 ERROR [STDERR] at org.jboss.aop.joinpoint.MethodInvocation.invokeNext(MethodInvocation.java:101)


      At this point of my code after the Sysout 4:

      public CustomerBean addNewCustomerBean(ServiceProviderBean serviceProviderBean, CustomerBean customerBean) throws Exception {
      System.out.println("1");
      serviceProviderBean = em.find(ServiceProviderBean.class, serviceProviderBean.getId());
      System.out.println("2");
      serviceProviderBean.getCustomerBeans().add(customerBean);
      System.out.println("3");
      em.persist(customerBean);
      System.out.println("4");
      em.refresh(customerBean);
      System.out.println("5");
      em.merge(serviceProviderBean);
      System.out.println("6");
      return customerBean;
      }




      Here is the DS file:
      <xa-datasource>
      <jndi-name>OracleDS</jndi-name>
      <track-connection-by-tx/>
      <isSameRM-override-value>false</isSameRM-override-value>
      <xa-datasource-class>oracle.jdbc.xa.client.OracleXADataSource</xa-datasource-class>
      <xa-datasource-property name="URL">jdbc:oracle:thin:@url ending (this is correct at my end)UK</xa-datasource-property>
      <xa-datasource-property name="User">***Username***</xa-datasource-property>
      <xa-datasource-property name="Password">***password***</xa-datasource-property>
      <!-- Uses the pingDatabase method to check a connection is still valid before handing it out from the
      pool -->
      <valid-connection-checker-class-name>org.jboss.resource.adapter.jdbc.vendor.OracleValidConnectionChecker</valid-connection-checker-class-name>
      <!-- Checks the Oracle error codes and messages for fatal errors -->
      <exception-sorter-class-name>org.jboss.resource.adapter.jdbc.vendor.OracleExceptionSorter</exception-sorter-class-name>
      <!-- Oracles XA datasource cannot reuse a connection outside a transaction once enlisted in a global
      transaction and vice-versa -->
      <no-tx-separate-pools/>

      <!-- corresponding type-mapping in the standardjbosscmp-jdbc.xml -->
      <metadata>
      <type-mapping>Oracle9i</type-mapping>
      </metadata>
      <min-pool-size>1</min-pool-size>
      <max-pool-size>10</max-pool-size>
      <blocking-timeout-millis>5000</blocking-timeout-millis>
      <idle-timeout-minutes>2</idle-timeout-minutes>
      </xa-datasource>


      And here is the Persistance file:
      <?xml version="1.0" encoding="UTF-8"?>
      <persistence 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" version="1.0">

      <persistence-unit name="forums" transaction-type="JTA">
      <jta-data-source>java:/OracleDS</jta-data-source>
      <properties>
      <property name="hibernate.dialect" value="org.hibernate.dialect.Oracle10gDialect"/>
      <property name="hibernate.hbm2ddl.auto" value="update"/>
      </properties>
      </persistence-unit>
      </persistence>