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();