非トランザクションInformixDBv。11.50を使用して、JavaSE7.0環境でEclipseLink3.0を備えたJPA2.0を使用してテーブルを更新する必要があります。persistence.xmlは次のとおりです。
<persistence-unit name="pp_pu" transaction-type="RESOURCE_LOCAL">
<provider>org.eclipse.persistence.jpa.PersistenceProvider</provider>
<class>...</class>
<class>...</class>
<properties>
<property name="javax.persistence.jdbc.url"
value="jdbc:informix-sqli://10.191.78.230:40494/ptpr:informixserver=online_ptpr"/>
<property name="javax.persistence.jdbc.driver" value="com.informix.jdbc.IfxDriver"/>
<property name="javax.persistence.jdbc.user" value="test"/>
<property name="javax.persistence.jdbc.password" value="test"/>
</properties>
</persistence-unit>
そして、更新しようとすると、次のエラーが発生します。
Exception in thread "main" javax.persistence.TransactionRequiredException:
Exception Description: No transaction is currently active
at org.eclipse.persistence.internal.jpa.transaction.EntityTransactionWrapper.throwCheckTransactionFailedException(EntityTransactionWrapper.java:113)
at org.eclipse.persistence.internal.jpa.transaction.EntityTransactionWrapper.checkForTransaction(EntityTransactionWrapper.java:50)
at org.eclipse.persistence.internal.jpa.EntityManagerImpl.checkForTransaction(EntityManagerImpl.java:1776)
at org.eclipse.persistence.internal.jpa.EJBQueryImpl.executeUpdate(EJBQueryImpl.java:533)
それから私は次のようにエラーを解決しようとします:
em.getTransaction().begin();
// Update query
em.getTransaction().commit();
そして今、私は次のエラーを受け取ります:
Internal Exception: java.sql.SQLException: Transactions not supported
Error Code: -79744
Exception in thread "main" Local Exception Stack:
Exception [EclipseLink-4002] (Eclipse Persistence Services - 2.3.0.v20110604-r9504): org.eclipse.persistence.exceptions.DatabaseException
Internal Exception: java.sql.SQLException: Transactions not supported
Error Code: -79744
Query: DataModifyQuery(sql="update tg_proteccion_cv
set i_eq_validados=?,
i_eq_a_protegidos=?
where v_id_proteccion=?
and v_cve_cliente=?")
at org.eclipse.persistence.exceptions.DatabaseException.sqlException(DatabaseException.java:324)
at org.eclipse.persistence.internal.databaseaccess.DatabaseAccessor.basicBeginTransaction(DatabaseAccessor.java:230)
at org.eclipse.persistence.internal.databaseaccess.DatasourceAccessor.beginTransaction(DatasourceAccessor.java:239)
at org.eclipse.persistence.internal.sessions.AbstractSession.basicBeginTransaction(AbstractSession.java:479)
at org.eclipse.persistence.sessions.server.ClientSession.addWriteConnection(ClientSession.java:646)
at org.eclipse.persistence.sessions.server.ServerSession.acquireClientConnection(ServerSession.java:246)
at org.eclipse.persistence.sessions.server.ClientSession.executeCall(ClientSession.java:226)
at org.eclipse.persistence.internal.queries.DatasourceCallQueryMechanism.executeCall(DatasourceCallQueryMechanism.java:207)
at org.eclipse.persistence.internal.queries.DatasourceCallQueryMechanism.executeCall(DatasourceCallQueryMechanism.java:193)
at org.eclipse.persistence.internal.queries.DatasourceCallQueryMechanism.executeNoSelectCall(DatasourceCallQueryMechanism.java:236)
at org.eclipse.persistence.internal.queries.DatasourceCallQueryMechanism.executeNoSelect(DatasourceCallQueryMechanism.java:216)
at org.eclipse.persistence.queries.DataModifyQuery.executeDatabaseQuery(DataModifyQuery.java:85)
at org.eclipse.persistence.queries.DatabaseQuery.execute(DatabaseQuery.java:829)
at org.eclipse.persistence.queries.DatabaseQuery.executeInUnitOfWork(DatabaseQuery.java:728)
at org.eclipse.persistence.internal.sessions.UnitOfWorkImpl.internalExecuteQuery(UnitOfWorkImpl.java:2863)
at org.eclipse.persistence.internal.sessions.AbstractSession.executeQuery(AbstractSession.java:1501)
at org.eclipse.persistence.internal.sessions.AbstractSession.executeQuery(AbstractSession.java:1483)
at org.eclipse.persistence.internal.sessions.AbstractSession.executeQuery(AbstractSession.java:1457)
at org.eclipse.persistence.internal.jpa.EJBQueryImpl.executeUpdate(EJBQueryImpl.java:540)
at com.telcel.gsa.dsiee.pprecios.amb_alt.FixProtsCv.updateCV(FixProtsCv.java:70)
at com.telcel.gsa.dsiee.pprecios.amb_alt.FixProtsCv.fix(FixProtsCv.java:88)
at com.telcel.gsa.dsiee.pprecios.amb_alt.FixProtsCv.main(FixProtsCv.java:42)
at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:57)
at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43)
at java.lang.reflect.Method.invoke(Method.java:601)
at com.intellij.rt.execution.application.AppMain.main(AppMain.java:120)
Caused by: java.sql.SQLException: Transactions not supported
at com.informix.util.IfxErrMsg.getSQLException(IfxErrMsg.java:348)
at com.informix.jdbc.IfxSqliConnect.setAutoCommit(IfxSqliConnect.java:1333)
at org.eclipse.persistence.internal.databaseaccess.DatabaseAccessor.basicBeginTransaction(DatabaseAccessor.java:223)
... 25 more
JDBCを使用して更新を行うのに問題はありません。¿JPAは非トランザクションDBをサポートしていますか?パフォーマンス上の理由から、DBAはInformixでのトランザクションサポートをオフにしましたが、それは変更されません。それで、私が欠けているものはありますか?どうしたの?
PDトランザクション対応のInformixDBを使用して同じ更新を行いましたが、機能します。