Same behavior with RequiresNew ?

Regards
JB

On 16/05/2018 19:44, Alex Soto wrote:
With Karaf version 4.2.0, Rollback is not working with MariaDB and InnoDB tables.
I deployed these features (from Karaf’s enterprise  repository):


<feature>aries-blueprint</feature>
<feature>transaction</feature>
<feature>jndi</feature>
<feature>jdbc</feature>
<feature>jpa</feature>
<feature>pax-jdbc-mariadb</feature>
         <feature>pax-jdbc-config</feature>
<feature>pax-jdbc-pool-dbcp2</feature>
<feature>hibernate</feature>

My Data Source is configured in the file /org.ops4j.datasource-responder.cfg/

    osgi.jdbc.driver.name = mariadb
    dataSourceName=responder
    url
    = 
jdbc:mariadb://mariadb.local:3306/responder?characterEncoding=UTF-8&useServerPrepStmts=true&autocommit=false

    user=XXXX
    password=XXXX
    databaseName=responder

    #Pool Config
    pool=dbcp2
    xa=true


My persistence.xml:

    <persistence version="2.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_2_0.xsd";>
  <persistence-unit name="responderPersistenUnit" transaction-type="JTA">   <provider>org.hibernate.jpa.HibernatePersistenceProvider</provider>
             <!-- Only used when transaction-type=JTA -->
  <jta-data-source>osgi:service/javax.sql.DataSource/(osgi.jndi.service.name=responder)</jta-data-source>
             <!-- Only used when transaction-type=RESOURCE_LOCAL -->
  <non-jta-data-source>osgi:service/javax.sql.DataSource/(osgi.jndi.service.name=responder)</non-jta-data-source>
             <properties>
  <property name=“hibernate.dialect" value="org.hibernate.dialect.MySQL5Dialect" />
                 <property name="hibernate.show_sql" value="true" />
                 <property name="hibernate.format_sql" value="true" />
                 <property name="hibernate.hbm2ddl.auto" value="none"/>
             </properties>
         </persistence-unit>
    </persistence>


My blueprint.xml:

    <blueprint xmlns="http://www.osgi.org/xmlns/blueprint/v1.0.0";
    xmlns:jpa="http://aries.apache.org/xmlns/jpa/v2.0.0";
    xmlns:tx="http://aries.apache.org/xmlns/transactions/v2.0.0";
    xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance";
    xsi:schemaLocation="http://www.osgi.org/xmlns/blueprint/v1.0.0
    https://osgi.org/xmlns/blueprint/v1.0.0/blueprint.xsd";>

    <jpa:enable />
    <tx:enable />

    <bean id="userService" class="org.data.impl.UserServiceImpl" />
    <service ref="userService" interface="org.data.UserService" />

    </blueprint>


For testing I throw exception in my DAO:

@Transactional(REQUIRED)
public void addUser(User user) {
em.persist(user);
em.flush();
throw new RuntimeException("On Purpose");
}

I expect the record not to be in the table due to rollback of the transaction, but it still shows up in my database table.

Best regards,
Alex soto




Reply via email to