-->
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.  [ 1 post ] 
Author Message
 Post subject: criteria.uniqueResult() throwing exception
PostPosted: Mon Dec 24, 2007 2:05 am 
Newbie

Joined: Mon Dec 24, 2007 1:18 am
Posts: 1
Using Hibernate DTD 3.0:

I have a code to count of the number of objects that match the given criteria.. Here is the code snip..

public int getObjectCount(QueryCriteria criteria)
throws InternalException {
UserTransaction txn = null;
try {
txn = PersistenceService.getInstance().beginTemporaryTransaction();
QueryCriteria countQuery = new QueryCriteria(criteria);
countQuery.setFirstResult(QueryCriteria.NO_INDEX);
countQuery.setMaxResults(QueryCriteria.NO_INDEX);
countQuery.setResultType(Results.rowCount());
countQuery.removeOrder();
return txn.countObjectsByQuery(countQuery);
}
catch (Exception e) {
AesLogImpl.getInstance().error3(AesLog.LOG_CONFIG, CONFIGURATION_SERVICE,
"getObjectCount", e);
throw new InternalException(INTERNAL_ERROR, e);
}
finally {
try {
if (txn != null) {
txn.commit();
}
}
catch (Exception e) {
AesLogImpl.getInstance().throwing(AesLog.LOG_CONFIG, CONFIGURATION_SERVICE,
"getObjectCount", e);
}
}
}

--------------

public int countObjectsByQuery(QueryCriteria query)
throws TransactionException {
checkOpen();
try {
Criteria criteria = new CriteriaBuilder(
query).buildHibernateCriteria(_session);
Integer result = (Integer) criteria.uniqueResult();
return (result != null) ? result.intValue() : 0;
}
catch (HibernateException ex) {
throw new TransactionException(ex);
}
}
------------------------
the line in bold is giving this exception:
What might be causing this exception? How do i overcome this exception.

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 com.cisco.server.persistence.hibernate.dialect.SolidDialect$2.convert(SolidDialect.java:149)
at org.hibernate.exception.JDBCExceptionHelper.convert(JDBCExceptionHelper.java:43)
at org.hibernate.jdbc.AbstractBatcher.executeBatch(AbstractBatcher.java:249)
at org.hibernate.engine.ActionQueue.executeActions(ActionQueue.java:235)
at org.hibernate.engine.ActionQueue.executeActions(ActionQueue.java:144)
at org.hibernate.event.def.AbstractFlushingEventListener.performExecutions(AbstractFlushingEventListener.java:298)
at org.hibernate.event.def.DefaultAutoFlushEventListener.onAutoFlush(DefaultAutoFlushEventListener.java:41)
at org.hibernate.impl.SessionImpl.autoFlushIfRequired(SessionImpl.java:969)

at org.hibernate.impl.SessionImpl.list(SessionImpl.java:1562)
at org.hibernate.impl.CriteriaImpl.list(CriteriaImpl.java:283)
at org.hibernate.impl.CriteriaImpl.uniqueResult(CriteriaImpl.java:305)
at com.cisco.server.persistence.transaction.TransactionImpl.countObjectsByQuery(TransactionImpl.java:375)
at com.cisco.server.services.ConfigurationService.getObjectCount(ConfigurationService.java:1864)
at com.cisco.server.managedobjects.bridge.Switch.postDelete(Switch.java:359)
at com.cisco.server.managedobjects.common.ObjectManager.deleteObject(ObjectManager.java:376)
at com.cisco.server.services.ConfigurationService.deleteControllerById(ConfigurationService.java:2182)
at com.cisco.webui.action.configure.bridge.SwitchListCommandAction.executeAction(SwitchListCommandAction.java:104)
at com.cisco.webui.action.common.UiAction.execute(UiAction.java:121)
at org.apache.struts.action.RequestProcessor.processActionPerform(RequestProcessor.java:465)
at org.apache.struts.action.RequestProcessor.process(RequestProcessor.java:274)
at org.apache.struts.action.ActionServlet.process(ActionServlet.java:1422)
at org.apache.struts.action.ActionServlet.doPost(ActionServlet.java:523)
at javax.servlet.http.HttpServlet.service(HttpServlet.java:710)
at javax.servlet.http.HttpServlet.service(HttpServlet.java:803)
at org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:290)
at org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:206)
at org.displaytag.filter.ResponseOverrideFilter.doFilter(ResponseOverrideFilter.java:125)
at org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:235)
at org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:206)
at com.cisco.webui.common.AuthenticationFilter.doFilter(AuthenticationFilter.java:196)
at org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:235)
at org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:206)
at org.apache.catalina.core.StandardWrapperValve.invoke(StandardWrapperValve.java:230)
at org.apache.catalina.core.StandardContextValve.invoke(StandardContextValve.java:175)
at org.apache.catalina.core.StandardHostValve.invoke(StandardHostValve.java:128)
at org.apache.catalina.valves.ErrorReportValve.invoke(ErrorReportValve.java:104)
at org.apache.catalina.valves.AccessLogValve.invoke(AccessLogValve.java:563)
at org.apache.catalina.core.StandardEngineValve.invoke(StandardEngineValve.java:109)
at org.apache.catalina.connector.CoyoteAdapter.service(CoyoteAdapter.java:261)
at org.apache.jk.server.JkCoyoteHandler.invoke(JkCoyoteHandler.java:190)
at org.apache.jk.common.HandlerRequest.invoke(HandlerRequest.java:283)
at org.apache.jk.common.ChannelSocket.invoke(ChannelSocket.java:767)
at org.apache.jk.common.ChannelSocket.processConnection(ChannelSocket.java:697)
at org.apache.jk.common.ChannelSocket$SocketConnection.runIt(ChannelSocket.java:889)
at org.apache.tomcat.util.threads.ThreadPool$ControlRunnable.run(ThreadPool.java:686)
at java.lang.Thread.run(Thread.java:595)


Caused by: java.sql.BatchUpdateException: SOLID Database Error 10028: Foreign key constraint (FK882DED964AF58438) violation, foreign key values exist.
at ssa.s_Stmt.Execute_batch(Unknown Source)
at solid.jdbc.SolidPreparedStatement.executeBatch_newRPC(Unknown Source)
at solid.jdbc.SolidPreparedStatement.executeBatch(Unknown Source)
at com.mchange.v2.c3p0.impl.NewProxyPreparedStatement.executeBatch(NewProxyPreparedStatement.java:1723)
at org.hibernate.jdbc.BatchingBatcher.doExecuteBatch(BatchingBatcher.java:48)
at org.hibernate.jdbc.AbstractBatcher.executeBatch(AbstractBatcher.java:242)
... 43 more


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

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.