[infinispan-issues] [JBoss JIRA] (ISPN-3540) Persisting new entity with cached blind-side @OneToMany CMR field fails on transaction flush.

Jari Juslin (JIRA) jira-events at lists.jboss.org
Mon Sep 23 10:24:03 EDT 2013


Jari Juslin created ISPN-3540:
---------------------------------

             Summary: Persisting new entity with cached blind-side @OneToMany CMR field fails on transaction flush.
                 Key: ISPN-3540
                 URL: https://issues.jboss.org/browse/ISPN-3540
             Project: Infinispan
          Issue Type: Bug
    Affects Versions: 5.2.1.Final
         Environment: 64-bit Ubuntu 13.04, JBoss 7.2.0.Final, Hibernate 4.2.4.
            Reporter: Jari Juslin
            Assignee: Mircea Markus


I have two entity beans, both transactionally cached and then n:m relationship between them. The one side maps the CMR relationship as a Set and sets it to be transactionally cached.

Now when I create a new object on the one side, so that the Set containing the other side is empty, the transaction fails during the flush stage with the following message:

WARN  [org.infinispan.transaction.TransactionTable] (http-/0.0.0.0:8080-1:) ISPN000101: Failed synchronization registration: java.lang.IllegalStateException: ARJUNA016082: Synchronizations are not allowed! Transaction status isActionStatus.RUNNING

If I leave the Set field null, it works.

The beans:

@Entity()
@Table(name="k3_run")
@Cache(usage=CacheConcurrencyStrategy.TRANSACTIONAL)
public class Run implements Serializable {

    private Integer id;

    private Set<Restriction>     restrictions = new HashSet<>();
    
    @Id
    @GeneratedValue(strategy=GenerationType.IDENTITY)
    @Column(name = "id")
    public Integer getId() {
        return id;
    }

    public void setId(Integer id) {
        this.id = id;
    }

    @OneToMany
    @JoinColumn(name="run_fk")
    @Cache(usage=CacheConcurrencyStrategy.TRANSACTIONAL)
    public Set<Restriction> getRestrictions() {
        return restrictions;
    }

    public void setRestrictions(Set<Restriction> restrictions) {
        this.restrictions = restrictions;
    }
}


@Entity
@Table(name="k3_restriction")
@Cache(usage=CacheConcurrencyStrategy.TRANSACTIONAL)
public class Restriction  {
    private Integer id;
    
    @Id
    @GeneratedValue(strategy=GenerationType.IDENTITY)
    @Column(name = "id")
    public Integer getId() {
        return id;
    }

    public void setId(Integer id) {
        this.id = id;
    }
}

The RESTeasy service doing the creation:
@Stateless
@LocalBean
@Path("/bug_repro")
@TransactionAttribute(TransactionAttributeType.REQUIRED)
public class RunRest {
    @PersistenceContext(unitName = "persistence_context")
    protected EntityManager entityManager;

    @POST
    @TransactionAttribute(TransactionAttributeType.REQUIRED)
    public String createRun() {
        final Run run = new Run();
        entityManager.persist(run);
        return "New run created with ID " + run.getId();
    }
}

This curl command used to invoke it:
curl -H 'Content-Type: application/xml; charset=UTF-8' -X POST http://localhost:8080/infinispan_bug_reproduction/bug_repro

The persistence.xml:
<?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_2_0.xsd"
    version="2.0">
	<persistence-unit name="persistence_context" transaction-type="JTA">
	    <provider>org.hibernate.ejb.HibernatePersistence</provider>
        <jta-data-source>java:/OperationalDS</jta-data-source>
		<properties>
            <property name="hibernate.hbm2ddl.auto" value="validate"/>
		    <property name="hibernate.cache.use_second_level_cache" value="true"/>
		    <property name="hibernate.cache.use_query_cache" value="true"/>
		</properties>
	</persistence-unit>
</persistence>

The datasource definition:
                <xa-datasource jndi-name="java:/OperationalDS" pool-name="MpkDemoUsDS" enabled="true">
                    <xa-datasource-property name="ServerName">
                        localhost
                    </xa-datasource-property>
                    <xa-datasource-property name="DatabaseName">
                        production
                    </xa-datasource-property>
                    <driver>mysql</driver>
                    <security>
                        <user-name>k3</user-name>
                        <password>********</password>
                    </security>
                    <validation>
                        <check-valid-connection-sql>/* ping */ SELECT 1</check-valid-connection-sql>
                        <exception-sorter class-name="org.jboss.jca.adapters.jdbc.extensions.mysql.MySQLExceptionSorter"/>
                    </validation>
                </xa-datasource>



--
This message is automatically generated by JIRA.
If you think it was sent incorrectly, please contact your JIRA administrators
For more information on JIRA, see: http://www.atlassian.com/software/jira


More information about the infinispan-issues mailing list