Thread: Reg: 25P02, current transaction is aborted, commands ignored until end of transaction block

Dear all,

    I am trying to port my application from Oracle to PostGREs. I have a pr=
oblem while doing so. In my application i need to update record if the dele=
te on the respective record is failed due to Constraint Violation. But SQL =
Error: 0, SQLState: 25P02 ERROR [JDBCExceptionReporter] ERROR: current tran=
saction is aborted, commands ignored until end of transaction block is bein=
g generated while updating the record. But with Oracle i am able to do this.

I have tried with latest Jar [postgresql-8.3-604.jdbc3.jar] too, but proble=
m still exists.

Here is the code that i worked on:

try{
    session =3D sessionManager.getSession();
    transaction =3D session.beginTransaction();
    session.delete(objects[i]);
    session.flush();
}catch(ConstraintViolationException e){
    objects[i].setDeleted(Integer.valueOf(1));
    session.saveOrUpdate(object[i]);
    session.flush();
}
transaction.commit();
sessionManager.closeSession(session);

I am using platform java 1.5, jBoss 4.2.3, Hibernate v3.3, PostGREs v8.3 an=
d OS Windows me.

Thanks in advance,
Bhavani.G=
On Fri, 10 Apr 2009 11:55:03 +0200, Durgabhavani.g <durgabhavani.g@ocimumbio.com> wrote:
>     I am trying to port my application from Oracle to PostGREs. I have a
> problem while doing so. In my application i need to update record if the
> delete on the respective record is failed due to Constraint Violation.
> But SQL Error: 0, SQLState: 25P02 ERROR [JDBCExceptionReporter] ERROR:
> current transaction is aborted, commands ignored until end of
> transaction block is being generated while updating the record. But with
> Oracle i am able to do this.

What you may be looking for is described here:
http://www.postgresql.org/docs/current/interactive/sql-savepoint.html
In short: creating a savepoint, executing a query and - in case the query fails - rolling back to the savepoint created
previouslyrestores the transaction state. In your case, you should create the SAVEPOINT before executing the DELETE
query,and when it fails - ROLLBACK to the savepoint and continue normally. As far as I understand your code/intentions,
thatis. 

--
ru
bhavani gade wrote:
>
> Dear all,
>
>     I am trying to port my application from Oracle to PostGREs. I have a
> problem while doing so. In my application i need to update record if the
> delete on the respective record is failed due to Constraint Violation. But
> SQL Error: 0, SQLState: 25P02 ERROR [JDBCExceptionReporter] ERROR: current
> transaction is aborted, commands ignored until end of transaction block is
> being generated while updating the record. But with Oracle i am able to do
> this.
>
> I have tried with latest Jar [postgresql-8.3-604.jdbc3.jar] too, but
> problem still exists.
>
> Here is the code that i worked on:
>
> try{
>     session = sessionManager.getSession();
>     transaction = session.beginTransaction();
>     session.delete(objects[i]);
>     session.flush();
> }catch(ConstraintViolationException e){
>     objects[i].setDeleted(Integer.valueOf(1));
>     session.saveOrUpdate(object[i]);
>     session.flush();
> }
> transaction.commit();
> sessionManager.closeSession(session);
>
> I am using platform java 1.5, jBoss 4.2.3, Hibernate v3.3, PostGREs v8.3
> and OS Windows me.
>
> Thanks in advance,
> Bhavani.G
>

--
View this message in context:
http://www.nabble.com/Reg%3A-25P02%2C-current-transaction-is-aborted%2C-commands-ignored-until-end-of-transaction-block-tp22986191p25677673.html
Sent from the PostgreSQL - bugs mailing list archive at Nabble.com.
hi i am useing PostgreSQL 8.2 i got this error on console  if any Solution
Please try to contact me or send me any Solution fro that
ajaylabdae@gmail.com

2009-09-30 12:34:56,281
[org.springframework.orm.hibernate3.HibernateTemplate] DEBUG - Not closing
pre-bound Hibernate Session after HibernateTemplate
org.springframework.jdbc.UncategorizedSQLException: Hibernate operation:
could not execute query; uncategorized SQLException for SQL [select
this_.handicap_code as handicap1_161_0_, this_.handicap_desc as
handicap2_161_0_ from est_m_handicap this_ order by this_.handicap_code
asc]; SQL state [25P02]; error code [0]; ERROR: current transaction is
aborted, commands ignored until end of transaction block; nested exception
is org.postgresql.util.PSQLException: ERROR: current transaction is aborted,
commands ignored until end of transaction block
Caused by: org.postgresql.util.PSQLException: ERROR: current transaction is
aborted, commands ignored until end of transaction block
    at
org.postgresql.core.v3.QueryExecutorImpl.receiveErrorResponse(QueryExecutorImpl.java:1548)
    at
org.postgresql.core.v3.QueryExecutorImpl.processResults(QueryExecutorImpl.java:1316)
    at
org.postgresql.core.v3.QueryExecutorImpl.execute(QueryExecutorImpl.java:191)
    at
org.postgresql.jdbc2.AbstractJdbc2Statement.execute(AbstractJdbc2Statement.java:452)
    at
org.postgresql.jdbc2.AbstractJdbc2Statement.executeWithFlags(AbstractJdbc2Statement.java:351)
    at
org.postgresql.jdbc2.AbstractJdbc2Statement.executeQuery(AbstractJdbc2Statement.java:255)
    at
org.apache.commons.dbcp.DelegatingPreparedStatement.executeQuery(DelegatingPreparedStatement.java:92)
    at
org.hibernate.jdbc.AbstractBatcher.getResultSet(AbstractBatcher.java:186)
    at org.hibernate.loader.Loader.getResultSet(Loader.java:1787)
    at org.hibernate.loader.Loader.doQuery(Loader.java:674)
    at
org.hibernate.loader.Loader.doQueryAndInitializeNonLazyCollections(Loader.java:236)
    at org.hibernate.loader.Loader.doList(Loader.java:2220)
    at org.hibernate.loader.Loader.listIgnoreQueryCache(Loader.java:2104)
    at org.hibernate.loader.Loader.list(Loader.java:2099)
    at
org.hibernate.loader.criteria.CriteriaLoader.list(CriteriaLoader.java:94)
    at org.hibernate.impl.SessionImpl.list(SessionImpl.java:1569)
    at org.hibernate.impl.CriteriaImpl.list(CriteriaImpl.java:283)
    at
com.nic.mcc.est.transaction.AbstractSpringDao$3.doInHibernate(AbstractSpringDao.java:181)
    at
org.springframework.orm.hibernate3.HibernateTemplate.execute(HibernateTemplate.java:369)
    at
com.nic.mcc.est.transaction.AbstractSpringDao.getOrderByArrayList(AbstractSpringDao.java:175)
    at com.nic.mcc.est.dao.HandicapDao.getOrderByList(HandicapDao.java:148)
    at
com.nic.mcc.est.controllers.master.employee.CreateController.formBackingObject(CreateController.java:178)
    at
org.springframework.web.servlet.mvc.AbstractFormController.getErrorsForNewForm(AbstractFormController.java:343)
    at
org.springframework.web.servlet.mvc.AbstractFormController.showNewForm(AbstractFormController.java:323)
    at
org.springframework.web.servlet.mvc.AbstractFormController.handleRequestInternal(AbstractFormController.java:263)
    at
org.springframework.web.servlet.mvc.AbstractController.handleRequest(AbstractController.java:153)
    at
org.springframework.web.servlet.mvc.SimpleControllerHandlerAdapter.handle(SimpleControllerHandlerAdapter.java:48)
    at
org.springframework.web.servlet.DispatcherServlet.doDispatch(DispatcherServlet.java:839)
    at
org.springframework.web.servlet.DispatcherServlet.doService(DispatcherServlet.java:774)
    at
org.springframework.web.servlet.FrameworkServlet.processRequest(FrameworkServlet.java:460)
    at
org.springframework.web.servlet.FrameworkServlet.doGet(FrameworkServlet.java:415)
    at javax.servlet.http.HttpServlet.service(HttpServlet.java:690)
    at javax.servlet.http.HttpServlet.service(HttpServlet.java:803)
    at
org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:269)
    at
org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:188)
    at
org.apache.catalina.core.StandardWrapperValve.invoke(StandardWrapperValve.java:210)
    at
org.apache.catalina.core.StandardContextValve.invoke(StandardContextValve.java:174)
    at
org.apache.catalina.core.StandardHostValve.invoke(StandardHostValve.java:127)
    at
org.apache.catalina.valves.ErrorReportValve.invoke(ErrorReportValve.java:117)
    at
org.apache.catalina.core.StandardEngineValve.invoke(StandardEngineValve.java:108)
    at
org.apache.catalina.connector.CoyoteAdapter.service(CoyoteAdapter.java:151)
    at
org.apache.coyote.http11.Http11Processor.process(Http11Processor.java:870)
    at
org.apache.coyote.http11.Http11BaseProtocol$Http11ConnectionHandler.processConnection(Http11BaseProtocol.java:665)
    at
org.apache.tomcat.util.net.PoolTcpEndpoint.processSocket(PoolTcpEndpoint.java:528)
    at
org.apache.tomcat.util.net.LeaderFollowerWorkerThread.runIt(LeaderFollowerWorkerThread.java:81)
    at
org.apache.tomcat.util.threads.ThreadPool$ControlRunnable.run(ThreadPool.java:685)
    at java.lang.Thread.run(Thread.java:595)


ajay labade wrote:
>
>
>
> bhavani gade wrote:
>>
>> Dear all,
>>
>>     I am trying to port my application from Oracle to PostGREs. I have a
>> problem while doing so. In my application i need to update record if the
>> delete on the respective record is failed due to Constraint Violation.
>> But SQL Error: 0, SQLState: 25P02 ERROR [JDBCExceptionReporter] ERROR:
>> current transaction is aborted, commands ignored until end of transaction
>> block is being generated while updating the record. But with Oracle i am
>> able to do this.
>>
>> I have tried with latest Jar [postgresql-8.3-604.jdbc3.jar] too, but
>> problem still exists.
>>
>> Here is the code that i worked on:
>>
>> try{
>>     session = sessionManager.getSession();
>>     transaction = session.beginTransaction();
>>     session.delete(objects[i]);
>>     session.flush();
>> }catch(ConstraintViolationException e){
>>     objects[i].setDeleted(Integer.valueOf(1));
>>     session.saveOrUpdate(object[i]);
>>     session.flush();
>> }
>> transaction.commit();
>> sessionManager.closeSession(session);
>>
>> I am using platform java 1.5, jBoss 4.2.3, Hibernate v3.3, PostGREs v8.3
>> and OS Windows me.
>>
>> Thanks in advance,
>> Bhavani.G
>>
>
>

--
View this message in context:
http://www.nabble.com/Reg%3A-25P02%2C-current-transaction-is-aborted%2C-commands-ignored-until-end-of-transaction-block-tp22986191p25677724.html
Sent from the PostgreSQL - bugs mailing list archive at Nabble.com.
On Wed, Sep 30, 2009 at 5:23 AM, ajay labade <ajaylabade@gmail.com> wrote:
>> =A0 =A0 I am trying to port my application from Oracle to PostGREs. I ha=
ve a
>> problem while doing so. In my application i need to update record if the
>> delete on the respective record is failed due to Constraint Violation. B=
ut
>> SQL Error: 0, SQLState: 25P02 ERROR [JDBCExceptionReporter] ERROR: curre=
nt
>> transaction is aborted, commands ignored until end of transaction block =
is
>> being generated while updating the record. But with Oracle i am able to =
do
>> this.
>>
>> I have tried with latest Jar [postgresql-8.3-604.jdbc3.jar] too, but
>> problem still exists.
>>
>> Here is the code that i worked on:
>>
>> try{
>> =A0 =A0 session =3D sessionManager.getSession();
>> =A0 =A0 transaction =3D session.beginTransaction();
>> =A0 =A0 session.delete(objects[i]);
>> =A0 =A0 session.flush();
>> }catch(ConstraintViolationException e){
>> =A0 =A0 objects[i].setDeleted(Integer.valueOf(1));
>> =A0 =A0 session.saveOrUpdate(object[i]);
>> =A0 =A0 session.flush();
>> }
>> transaction.commit();
>> sessionManager.closeSession(session);

This is not a bug.

When an exception occurs in PostgreSQL, any further commands are
ignored until the transaction is rolled back.  In this case, you seem
to be catching a ConstraintViolationException and then attempting to
performing further database actions, which is bound to fail.

You may want to ROLLBACK within your exception handler and then BEGIN again.

...Robert