在选择查询期间收到错误'在postgresql中使用hibernate

时间:2014-07-15 13:16:57

标签: postgresql-9.3 hibernate3 enterprisedb

我们在项目中使用ppas9.3数据库和hibernate3。我们正在使用一种已经调用其他两种方法的方法。在一种方法中,我们正在执行'选择'查询(由于'column doesn't exist'而无法执行)并且在关闭此连接(即jdbc连接)之后,我们正在调用第一个在第一次失败后执行的方法,这次我们使用{{1}进行连接并且当执行select查询(即在数据库中成功执行)时,会出现以下错误: -

'HibernateUtils.getCurrentSession().connection'

当第一个语句没有抛出任何错误时,第二个也正常工作。我检查的是: - 1.我在执行第一个语句之前使用了一个保存点,如果出现错误则回滚到该保存点。 2.试图在没有保存点的情况下回滚。 但每次在第二种方法中都会出错。 方法代码是: -

BasicAction: a0028c9:d2ba:53c51ef5:6e4 status: ActionStatus.ABORT_ONLY > cannot proceed STATUS_MARKED_ROLLBACK; - nested throwable: (javax.tra
nsaction.RollbackException: Transaction TransactionImple < ac, BasicAction: a0028c9:d2ba:53c51ef5:6e4 status: ActionStatus.ABORT_ONLY > cannot proceed STATUS
_MARKED_ROLLBACK)
18:14:08,475 ERROR [SOAPFaultHelperJAXWS] SOAP request exception
javax.ejb.EJBTransactionRolledbackException: [2] An exception has occurred: ERROR: current transaction is aborted, commands ignored until end of transaction
block
        at org.jboss.ejb3.tx.Ejb3TxPolicy.handleInCallerTx(Ejb3TxPolicy.java:87)
        at org.jboss.aspects.tx.TxPolicy.invokeInCallerTx(TxPolicy.java:130)
        at org.jboss.aspects.tx.TxInterceptor$Supports.invoke(TxInterceptor.java:148)
        at org.jboss.aop.joinpoint.MethodInvocation.invokeNext(MethodInvocation.java:101)
        at org.jboss.aspects.tx.TxPropagationInterceptor.invoke(TxPropagationInterceptor.java:95)
        at org.jboss.aop.joinpoint.MethodInvocation.invokeNext(MethodInvocation.java:101)
        at org.jboss.ejb3.stateless.StatelessInstanceInterceptor.invoke(StatelessInstanceInterceptor.java:62)
        at org.jboss.aop.joinpoint.MethodInvocation.invokeNext(MethodInvocation.java:101)
        at org.jboss.aspects.security.AuthenticationInterceptor.invoke(AuthenticationInterceptor.java:77)
        at org.jboss.ejb3.security.Ejb3AuthenticationInterceptor.invoke(Ejb3AuthenticationInterceptor.java:110)
        at org.jboss.aop.joinpoint.MethodInvocation.invokeNext(MethodInvocation.java:101)
        at org.jboss.ejb3.ENCPropagationInterceptor.invoke(ENCPropagationInterceptor.java:46)
        at org.jboss.aop.joinpoint.MethodInvocation.invokeNext(MethodInvocation.java:101)
        at org.jboss.ejb3.asynchronous.AsynchronousInterceptor.invoke(AsynchronousInterceptor.java:106)
        at org.jboss.aop.joinpoint.MethodInvocation.invokeNext(MethodInvocation.java:101)
        at org.jboss.ejb3.stateless.StatelessContainer.dynamicInvoke(StatelessContainer.java:304)
        at org.jboss.ejb3.remoting.IsLocalInterceptor.invokeLocal(IsLocalInterceptor.java:81)
        at org.jboss.ejb3.remoting.IsLocalInterceptor.invoke(IsLocalInterceptor.java:72)
        at org.jboss.aop.joinpoint.MethodInvocation.invokeNext(MethodInvocation.java:101)
        at org.jboss.ejb3.stateless.StatelessRemoteProxy.invoke(StatelessRemoteProxy.java:107)
        at $Proxy145.checkHistory(Unknown Source)
        at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
        at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:39)
        at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:25)
        at java.lang.reflect.Method.invoke(Method.java:597)
        at com.datagenic.infra.WebServiceAdapterInterceptor.executeCall(WebServiceAdapterInterceptor.java:178)
        at com.datagenic.infra.WebServiceAdapterInterceptor.intercept(WebServiceAdapterInterceptor.java:82)
        at sun.reflect.GeneratedMethodAccessor375.invoke(Unknown Source)
        at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:25)
        at java.lang.reflect.Method.invoke(Method.java:597)
        at org.jboss.ejb3.interceptor.InvocationContextImpl.proceed(InvocationContextImpl.java:118)
        at org.jboss.ejb3.interceptor.EJB3InterceptorsInterceptor.invoke(EJB3InterceptorsInterceptor.java:63)
        at org.jboss.aop.joinpoint.MethodInvocation.invokeNext(MethodInvocation.java:101)
        at org.jboss.ejb3.entity.TransactionScopedEntityManagerInterceptor.invoke(TransactionScopedEntityManagerInterceptor.java:54)
        at org.jboss.aop.joinpoint.MethodInvocation.invokeNext(MethodInvocation.java:101)

第一种方法是: -

private String buildItems() {
        try {
            loadItemsForInfos();
            addItems();
        } catch (RuntimeException e) {
            e.getPrintStack();
        }
    }

和第二种方法是: -

public void loadValueForInfos(){
    ResultSet rs = null;
    Connection conn = getDSConnection(); // we are taking connection through JNDI name.
    PreparedStatement pst = conn.prepareStatement("select * from items where id = ?")//this query by default fails to execute.
    pst.setObject(1,12);
    try{
    rs = executeQuery();
    while (rs.next()){
    //have some code..
    }
    }catch(SQLException e){

    } finally {
                SqlUtils.closeResources(pst, rs);
            }
  • 只有当第一个查询无法执行时才会出现此错误,即使第二个查询正确也意味着执行成功。

  • 我们正在使用public void addItems() { String query = "select * from particularitems where id = ?"; PreparedStatement stmt = null; ResultSet rs = null; Connection conn = null; try { conn = HibernateUtil.currentSession().connection(); stmt = conn.prepareStatement(query); stmt.setInt(1, 34); rs = stmt.executeQuery(); while (rs.next()) { } } catch (Exception se) { throw new Exception(se); } finally { SqlUtils.closeResources(stmt, rs); } }

那么请你告诉我确切的原因以及如何解决它。谢谢你,

1 个答案:

答案 0 :(得分:0)

经过一个多月的谷歌搜索和R&amp; D之后,我终于通过在PPAS9.3 postgresql中将“edb_stmt_level_tx = off”的值设置为“on”来修复上述postgresql 9.3的常见错误。 .config属性文件。     欲了解更多信息,请访问以下链接。

Click here to visit the above desc link