-->
These old forums are deprecated now and set to read-only. We are waiting for you on our new forums!
More modern, Discourse-based and with GitHub/Google/Twitter authentication built-in.

All times are UTC - 5 hours [ DST ]



Forum locked This topic is locked, you cannot edit posts or make further replies.  [ 4 posts ] 
Author Message
 Post subject: calling postgresql function ...getting GenericJDBCException
PostPosted: Thu Mar 20, 2008 10:22 am 
Newbie

Joined: Thu Mar 20, 2008 10:11 am
Posts: 3
I m using postgresql db , I m facing with following problem

19:21:59,625 INFO [STDOUT] [2008-03-20 19:21:59,624] org.hibernate.util.JDBCExceptionReporter WARN org.apache.commons.logging.impl.Log4JLogger.warn(Log4JLogger.java:104) - SQL Error: 0, SQLState: null
19:21:59,626 INFO [STDOUT] [2008-03-20 19:21:59,625] org.hibernate.util.JDBCExceptionReporter ERROR org.apache.commons.logging.impl.Log4JLogger.error(Log4JLogger.java:114) - Batch entry 0 select * from createUser ('Testaa',2) as result was aborted. Call getNextException to see the cause.
19:21:59,626 INFO [STDOUT] [2008-03-20 19:21:59,626] org.hibernate.util.JDBCExceptionReporter WARN org.apache.commons.logging.impl.Log4JLogger.warn(Log4JLogger.java:104) - SQL Error: 0, SQLState: 0100E
19:21:59,627 INFO [STDOUT] [2008-03-20 19:21:59,626] org.hibernate.util.JDBCExceptionReporter ERROR org.apache.commons.logging.impl.Log4JLogger.error(Log4JLogger.java:114) - A result was returned when none was expected.
19:21:59,633 INFO [STDOUT] [2008-03-20 19:21:59,628] org.hibernate.event.def.AbstractFlushingEventListener ERROR org.apache.commons.logging.impl.Log4JLogger.error(Log4JLogger.java:119) - Could not synchronize database state with session
org.hibernate.exception.GenericJDBCException: Could not execute JDBC batch update
at org.hibernate.exception.SQLStateConverter.handledNonSpecificException(SQLStateConverter.java:103)
at org.hibernate.exception.SQLStateConverter.convert(SQLStateConverter.java:91)
at org.hibernate.exception.JDBCExceptionHelper.convert(JDBCExceptionHelper.java:43)
at org.hibernate.jdbc.AbstractBatcher.executeBatch(AbstractBatcher.java:253)
at org.hibernate.engine.ActionQueue.executeActions(ActionQueue.java:266)
at org.hibernate.engine.ActionQueue.executeActions(ActionQueue.java:167)
at org.hibernate.event.def.AbstractFlushingEventListener.performExecutions(AbstractFlushingEventListener.java:298)
at org.hibernate.event.def.DefaultFlushEventListener.onFlush(DefaultFlushEventListener.java:27)
at org.hibernate.impl.SessionImpl.flush(SessionImpl.java:1000)
at com.java.hibernate.test.HibernateTestAction.execute(HibernateTestAction.java:69)
at org.apache.struts.chain.commands.servlet.ExecuteAction.execute(ExecuteAction.java:53)
at org.apache.struts.chain.commands.AbstractExecuteAction.execute(AbstractExecuteAction.java:64)
at org.apache.struts.chain.commands.ActionCommandBase.execute(ActionCommandBase.java:48)
at org.apache.commons.chain.impl.ChainBase.execute(ChainBase.java:190)
at org.apache.commons.chain.generic.LookupCommand.execute(LookupCommand.java:304)
at org.apache.commons.chain.impl.ChainBase.execute(ChainBase.java:190)
at org.apache.struts.chain.ComposableRequestProcessor.process(ComposableRequestProcessor.java:280)
at org.apache.struts.action.ActionServlet.process(ActionServlet.java:1858)
at org.apache.struts.action.ActionServlet.doGet(ActionServlet.java:446)
at javax.servlet.http.HttpServlet.service(HttpServlet.java:697)
at javax.servlet.http.HttpServlet.service(HttpServlet.java:810)
at org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:252)
at org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:173)
at com.opensymphony.module.sitemesh.filter.PageFilter.parsePage(PageFilter.java:119)
at com.opensymphony.module.sitemesh.filter.PageFilter.doFilter(PageFilter.java:55)
at org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:202)
at org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:173)
at com.jspbook.GZIPFilter.doFilter(Unknown Source)
at org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:202)
at org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:173)
at org.jboss.web.tomcat.filters.ReplyHeaderFilter.doFilter(ReplyHeaderFilter.java:96)
at org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:202)
at org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:173)
at org.apache.catalina.core.StandardWrapperValve.invoke(StandardWrapperValve.java:213)
at org.apache.catalina.core.StandardContextValve.invoke(StandardContextValve.java:178)
at org.jboss.web.tomcat.security.SecurityAssociationValve.invoke(SecurityAssociationValve.java:175)
at org.jboss.web.tomcat.security.JaccContextValve.invoke(JaccContextValve.java:74)
at org.apache.catalina.core.StandardHostValve.invoke(StandardHostValve.java:126)
at org.apache.catalina.valves.ErrorReportValve.invoke(ErrorReportValve.java:105)
at org.apache.catalina.core.StandardEngineValve.invoke(StandardEngineValve.java:107)
at org.apache.catalina.connector.CoyoteAdapter.service(CoyoteAdapter.java:148)
at org.apache.coyote.http11.Http11Processor.process(Http11Processor.java:869)
at org.apache.coyote.http11.Http11BaseProtocol$Http11ConnectionHandler.processConnection(Http11BaseProtocol.java:664)
at org.apache.tomcat.util.net.PoolTcpEndpoint.processSocket(PoolTcpEndpoint.java:527)
at org.apache.tomcat.util.net.MasterSlaveWorkerThread.run(MasterSlaveWorkerThread.java:112)
at java.lang.Thread.run(Thread.java:595)
Caused by: java.sql.BatchUpdateException: Batch entry 0 select * from createUser ('Testaa',2) as result was aborted. Call getNextException to see the cause.
at org.postgresql.jdbc2.AbstractJdbc2Statement$BatchResultHandler.handleError(AbstractJdbc2Statement.java:2530)
at org.postgresql.jdbc2.AbstractJdbc2Statement$BatchResultHandler.handleResultRows(AbstractJdbc2Statement.java:2494)
at org.postgresql.core.v3.QueryExecutorImpl.processResults(QueryExecutorImpl.java:1258)
at org.postgresql.core.v3.QueryExecutorImpl.execute(QueryExecutorImpl.java:350)
at org.postgresql.jdbc2.AbstractJdbc2Statement.executeBatch(AbstractJdbc2Statement.java:2592)
at org.hibernate.jdbc.BatchingBatcher.doExecuteBatch(BatchingBatcher.java:48)
at org.hibernate.jdbc.AbstractBatcher.executeBatch(AbstractBatcher.java:246)
... 42 more
19:21:59,633 INFO [STDOUT] [2008-03-20 19:21:59,633] HibernateTestAction FATAL com.java.hibernate.test.HibernateTestAction.execute(HibernateTestAction.java:76) - Exception = org.hibernate.exception.GenericJDBCException: Could not execute JDBC batch update
19:21:59,638 INFO [STDOUT] [2008-03-20 19:21:59,637] org.hibernate.impl.SessionFactoryImpl INFO org.apache.commons.logging.impl.Log4JLogger.info(Log4JLogger.java:94) - closing


I used following code

Code:
CREATE TABLE user1
(
  uid numeric NOT NULL,
  uname varchar(30)

)
WITHOUT OIDS;
ALTER TABLE user1 OWNER TO postgres;


CREATE OR REPLACE FUNCTION createUser(UNAME "varchar" , UID int4)
  RETURNS VOID AS
$BODY$

   BEGIN
      RAISE NOTICE 'BEFORE INSERT ';
      INSERT INTO  USER1  VALUES(1,'TEST');
      RAISE NOTICE 'AFTER INSERT ';
      --return 0;
   END;

      
$BODY$
  LANGUAGE 'plpgsql' VOLATILE;
ALTER FUNCTION createUser(UNAME "varchar" , UID int4) OWNER TO postgres;

This is my mapping file

<hibernate-mapping auto-import="true" default-lazy="false">
   
    <class name="com.java.hibernate.test.User"   table="User1">
        <id name="id"  column="UID">
            <generator class="increment"/>
        </id>
        <property name="name" not-null="true" column="UNAME"/>
        <sql-insert  callable="true" check="none" >{call createUser (?,?)}</sql-insert>               
    </class>
   
</hibernate-mapping>

[b]I wrote this code in my Action class[/b]
   hibernateFactory=(SessionFactory) servlet.getServletContext().getAttribute(HibernatePlugIn.SESSION_FACTORY_KEY);
            hibernateSession = hibernateFactory.openSession();
           
            tran = hibernateSession.beginTransaction();

       User user = new User();
            user.setName("'Testaa'");
    tran.commit();


Top
 Profile  
 
 Post subject:
PostPosted: Thu Mar 20, 2008 4:46 pm 
Regular
Regular

Joined: Mon May 08, 2006 6:00 am
Posts: 53
Location: India
check if your stored procedure is returning anything, if yes you should assing it to respective object in your XML mapping.


Top
 Profile  
 
 Post subject:
PostPosted: Fri Mar 21, 2008 1:12 am 
Newbie

Joined: Thu Mar 20, 2008 10:11 am
Posts: 3
sudhir0104 wrote:
check if your stored procedure is returning anything, if yes you should assing it to respective object in your XML mapping.




My function's return type is void..
i have also tried with int return type but it is not working


Top
 Profile  
 
 Post subject:
PostPosted: Mon Mar 24, 2008 4:39 am 
Newbie

Joined: Thu Mar 20, 2008 10:11 am
Posts: 3
I also tried with function returning some int value but stll i m not able to call the function

i m getting following erro

Batch entry 0 select * from createUser ('Testaa',2) as result was aborted. Call getNextException to see the cause.


from this stmt what i understand is that hibernate is calling the function, but there might be some error at db server


Top
 Profile  
 
Display posts from previous:  Sort by  
Forum locked This topic is locked, you cannot edit posts or make further replies.  [ 4 posts ] 

All times are UTC - 5 hours [ DST ]


You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum

Search for:
© Copyright 2014, Red Hat Inc. All rights reserved. JBoss and Hibernate are registered trademarks and servicemarks of Red Hat, Inc.