0

I'm using Hibernate 4.2.21.Final. My Entity uses TABLE identifier generator

@Id
@GeneratedValue(generator = "SEQUENCEGENERATOR",strategy=GenerationType.TABLE)
@TableGenerator(name="SEQUENCEGENERATOR", table = "SEQUENCE_GENERATOR",pkColumnName="PK_ID", valueColumnName = "PK_ID_VALUE",
        pkColumnValue = "SOME_ID", allocationSize=1)
@Column(name = "SOME_ID", nullable = false, unique = true)
private Long id;

The application is deployed on WAS 8.5.5.x and we use org.springframework.transaction.jta.WebSphereUowTransactionManager for CMT.

The problem is, when the TableGenerator#generate method is called, it delegates the task to JtaIsolationDelegate which tries to suspend the current transaction as per the below code

public <T> T delegateWork(WorkExecutorVisitable<T> work, boolean transacted) throws HibernateException {
    TransactionManager transactionManager = transactionManager();

    try {
        // First we suspend any current JTA transaction
        Transaction surroundingTransaction = transactionManager.suspend();
        LOG.debugf( "Surrounding JTA transaction suspended [%s]", surroundingTransaction );

        boolean hadProblems = false;
        try {
            // then perform the requested work
            if ( transacted ) {
                return doTheWorkInNewTransaction( work, transactionManager );
            }
            else {
                return doTheWorkInNoTransaction( work );
            }
        }

This is causing an exception UnsupportedOperationException

java.lang.UnsupportedOperationException
at org.hibernate.service.jta.platform.internal.WebSphereExtendedJtaPlatform$TransactionManagerAdapter.suspend(WebSphereExtendedJtaPlatform.java:149)
at org.hibernate.engine.transaction.internal.jta.JtaIsolationDelegate.delegateWork(JtaIsolationDelegate.java:83)
at org.hibernate.id.enhanced.TableGenerator$1.getNextValue(TableGenerator.java:476)
at org.hibernate.id.enhanced.OptimizerFactory$NoopOptimizer.generate(OptimizerFactory.java:258)
at org.hibernate.id.enhanced.TableGenerator.generate(TableGenerator.java:472)

Any suggestion to sort this out?

neo83
  • 29
  • 8

1 Answers1

0

Was able to resolve this after using org.hibernate.service.jta.platform.internal.WebSphereJtaPlatform rather than org.hibernate.service.jta.platform.internal.WebSphereExtendedJtaPlatform even though the latter is supposed to be used for WAS > 6

<prop key="hibernate.transaction.jta.platform">org.hibernate.service.jta.platform.internal.WebSphereJtaPlatform</prop>

got help from here https://stackoverflow.com/a/22212658/5432388

neo83
  • 29
  • 8