title: Request processing failed; nested exception is org.hibernate.exception.ConstraintViolationException: Could not execute JDBC batch update
body: <p>This is my first post on stackoverflow! But i'm a master student at UIO so I'm not after getting a lot of help(if you even choose to) but perhaps a pointer towards where I could look to understand the problem better! And If you don't like my way of showing the problems then please do comment on that, and it will be better next time!</p>
  
  <pre><code>HTTP Status 500 - Request processing failed; nested exception is org.hibernate.exception.ConstraintViolationException: Could not execute JDBC batch update
  
  type Exception report
  
  message Request processing failed; nested exception is org.hibernate.exception.ConstraintViolationException: Could not execute JDBC batch update
  
  description The server encountered an internal error that prevented it from fulfilling this request.
  
  exception
  
  org.springframework.web.util.NestedServletException: Request processing failed; nested exception is org.hibernate.exception.ConstraintViolationException: Could not execute JDBC batch update
  org.springframework.web.servlet.FrameworkServlet.processRequest(FrameworkServlet.java:948)
  org.springframework.web.servlet.FrameworkServlet.doGet(FrameworkServlet.java:827)
  javax.servlet.http.HttpServlet.service(HttpServlet.java:621)
  org.springframework.web.servlet.FrameworkServlet.service(FrameworkServlet.java:812)
  javax.servlet.http.HttpServlet.service(HttpServlet.java:728)
  org.apache.tomcat.websocket.server.WsFilter.doFilter(WsFilter.java:51)
  org.springframework.orm.hibernate3.support.OpenSessionInViewFilter.doFilterInternal(OpenSessionInViewFilter.java:233)
  org.springframework.web.filter.OncePerRequestFilter.doFilter(OncePerRequestFilter.java:107)
  
  root cause
  
  org.hibernate.exception.ConstraintViolationException: Could not execute JDBC batch update
  org.hibernate.exception.SQLStateConverter.convert(SQLStateConverter.java:96)
  org.hibernate.exception.JDBCExceptionHelper.convert(JDBCExceptionHelper.java:66)
  org.hibernate.jdbc.AbstractBatcher.executeBatch(AbstractBatcher.java:275)
  org.hibernate.engine.ActionQueue.executeActions(ActionQueue.java:263)
  org.hibernate.engine.ActionQueue.executeActions(ActionQueue.java:180)
  org.hibernate.event.def.AbstractFlushingEventListener.performExecutions(AbstractFlushingEventListener.java:321)
  org.hibernate.event.def.DefaultAutoFlushEventListener.onAutoFlush(DefaultAutoFlushEventListener.java:64)
  org.hibernate.impl.SessionImpl.autoFlushIfRequired(SessionImpl.java:1175)
  org.hibernate.impl.SessionImpl.list(SessionImpl.java:1251)
  org.hibernate.impl.QueryImpl.list(QueryImpl.java:102)
  no.uio.inf5750.assignment2.dao.hibernate.HibernateStudentDao.getAllStudents(HibernateStudentDao.java:54)
  sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
  sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:57)
  sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43)
  java.lang.reflect.Method.invoke(Method.java:606)
  org.springframework.aop.support.AopUtils.invokeJoinpointUsingReflection(AopUtils.java:317)
  org.springframework.aop.framework.ReflectiveMethodInvocation.invokeJoinpoint(ReflectiveMethodInvocation.java:183)
  org.springframework.aop.framework.ReflectiveMethodInvocation.proceed(ReflectiveMethodInvocation.java:150)
  org.springframework.transaction.interceptor.TransactionInterceptor$1.proceedWithInvocation(TransactionInterceptor.java:96)
  org.springframework.transaction.interceptor.TransactionAspectSupport.invokeWithinTransaction(TransactionAspectSupport.java:260)
  org.springframework.transaction.interceptor.TransactionInterceptor.invoke(TransactionInterceptor.java:94)
  org.springframework.aop.framework.ReflectiveMethodInvocation.proceed(ReflectiveMethodInvocation.java:172)
  org.springframework.aop.framework.JdkDynamicAopProxy.invoke(JdkDynamicAopProxy.java:204)
  com.sun.proxy.$Proxy13.getAllStudents(Unknown Source)
  no.uio.inf5750.assignment2.service.impl.DefaultStudentSystem.getAllStudents(DefaultStudentSystem.java:168)
  no.uio.inf5750.assignment2.gui.controller.ApiController.jsonAddLocation(ApiController.java:40)
  sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
  sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:57)
  sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43)
  java.lang.reflect.Method.invoke(Method.java:606)
  org.springframework.web.method.support.InvocableHandlerMethod.invoke(InvocableHandlerMethod.java:219)
  org.springframework.web.method.support.InvocableHandlerMethod.invokeForRequest(InvocableHandlerMethod.java:132)
  org.springframework.web.servlet.mvc.method.annotation.ServletInvocableHandlerMethod.invokeAndHandle(ServletInvocableHandlerMethod.java:104)
  org.springframework.web.servlet.mvc.method.annotation.RequestMappingHandlerAdapter.invokeHandleMethod(RequestMappingHandlerAdapter.java:745)
  org.springframework.web.servlet.mvc.method.annotation.RequestMappingHandlerAdapter.handleInternal(RequestMappingHandlerAdapter.java:686)
  org.springframework.web.servlet.mvc.method.AbstractHandlerMethodAdapter.handle(AbstractHandlerMethodAdapter.java:80)
  org.springframework.web.servlet.DispatcherServlet.doDispatch(DispatcherServlet.java:925)
  org.springframework.web.servlet.DispatcherServlet.doService(DispatcherServlet.java:856)
  org.springframework.web.servlet.FrameworkServlet.processRequest(FrameworkServlet.java:936)
  org.springframework.web.servlet.FrameworkServlet.doGet(FrameworkServlet.java:827)
  javax.servlet.http.HttpServlet.service(HttpServlet.java:621)
  org.springframework.web.servlet.FrameworkServlet.service(FrameworkServlet.java:812)
  javax.servlet.http.HttpServlet.service(HttpServlet.java:728)
  org.apache.tomcat.websocket.server.WsFilter.doFilter(WsFilter.java:51)
  org.springframework.orm.hibernate3.support.OpenSessionInViewFilter.doFilterInternal(OpenSessionInViewFilter.java:233)
  org.springframework.web.filter.OncePerRequestFilter.doFilter(OncePerRequestFilter.java:107)
  
  root cause
  
  org.h2.jdbc.JdbcBatchUpdateException: Unique index or primary key violation: "CONSTRAINT_INDEX_BA ON PUBLIC.STUDENT(LATITUDE)"; SQL statement:
  update student set name=?, latitude=?, longitude=? where student_id=? [23001-136]
      org.h2.jdbc.JdbcPreparedStatement.executeBatch(JdbcPreparedStatement.java:1098)
   com.mchange.v2.c3p0.impl.NewProxyPreparedStatement.executeBatch(NewProxyPreparedStatement.java:1723)
  org.hibernate.jdbc.BatchingBatcher.doExecuteBatch(BatchingBatcher.java:70)
  org.hibernate.jdbc.AbstractBatcher.executeBatch(AbstractBatcher.java:268)
  org.hibernate.engine.ActionQueue.executeActions(ActionQueue.java:263)
  org.hibernate.engine.ActionQueue.executeActions(ActionQueue.java:180)
    org.hibernate.event.def.AbstractFlushingEventListener.performExecutions(AbstractFlushingEventListener.java:321)
   org.hibernate.event.def.DefaultAutoFlushEventListener.onAutoFlush(DefaultAutoFlushEventListener.java:64)
  org.hibernate.impl.SessionImpl.autoFlushIfRequired(SessionImpl.java:1175)
  org.hibernate.impl.SessionImpl.list(SessionImpl.java:1251)
  org.hibernate.impl.QueryImpl.list(QueryImpl.java:102)
   no.uio.inf5750.assignment2.dao.hibernate.HibernateStudentDao.getAllStudents(HibernateStudentDao.java:54)
  sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
  sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:57)
  sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43)
  java.lang.reflect.Method.invoke(Method.java:606)
   org.springframework.aop.support.AopUtils.invokeJoinpointUsingReflection(AopUtils.java:317)
   org.springframework.aop.framework.ReflectiveMethodInvocation.invokeJoinpoint(ReflectiveMethodInvocation.java:183)
   org.springframework.aop.framework.ReflectiveMethodInvocation.proceed(ReflectiveMethodInvocation.java:150)
   org.springframework.transaction.interceptor.TransactionInterceptor$1.proceedWithInvocation(TransactionInterceptor.java:96)
   org.springframework.transaction.interceptor.TransactionAspectSupport.invokeWithinTransaction(TransactionAspectSupport.java:260)
  org.springframework.transaction.interceptor.TransactionInterceptor.invoke(TransactionInterceptor.java:94)
  org.springframework.aop.framework.ReflectiveMethodInvocation.proceed(ReflectiveMethodInvocation.java:172)
  org.springframework.aop.framework.JdkDynamicAopProxy.invoke(JdkDynamicAopProxy.java:204)
  com.sun.proxy.$Proxy13.getAllStudents(Unknown Source)
  no.uio.inf5750.assignment2.service.impl.DefaultStudentSystem.getAllStudents(DefaultStudentSystem.java:168)
  no.uio.inf5750.assignment2.gui.controller.ApiController.jsonAddLocation(ApiController.java:40)
  sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
  sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:57)
  sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43)
  java.lang.reflect.Method.invoke(Method.java:606)
  org.springframework.web.method.support.InvocableHandlerMethod.invoke(InvocableHandlerMethod.java:219)
  org.springframework.web.method.support.InvocableHandlerMethod.invokeForRequest(InvocableHandlerMethod.java:132)
  org.springframework.web.servlet.mvc.method.annotation.ServletInvocableHandlerMethod.invokeAndHandle(ServletInvocableHandlerMethod.java:104)
  org.springframework.web.servlet.mvc.method.annotation.RequestMappingHandlerAdapter.invokeHandleMethod(RequestMappingHandlerAdapter.java:745)
  org.springframework.web.servlet.mvc.method.annotation.RequestMappingHandlerAdapter.handleInternal(RequestMappingHandlerAdapter.java:686)
  org.springframework.web.servlet.mvc.method.AbstractHandlerMethodAdapter.handle(AbstractHandlerMethodAdapter.java:80)
  org.springframework.web.servlet.DispatcherServlet.doDispatch(DispatcherServlet.java:925)
  org.springframework.web.servlet.DispatcherServlet.doService(DispatcherServlet.java:856)
  org.springframework.web.servlet.FrameworkServlet.processRequest(FrameworkServlet.java:936)
  org.springframework.web.servlet.FrameworkServlet.doGet(FrameworkServlet.java:827)
  javax.servlet.http.HttpServlet.service(HttpServlet.java:621)
  org.springframework.web.servlet.FrameworkServlet.service(FrameworkServlet.java:812)
  javax.servlet.http.HttpServlet.service(HttpServlet.java:728)
  org.apache.tomcat.websocket.server.WsFilter.doFilter(WsFilter.java:51)
  org.springframework.orm.hibernate3.support.OpenSessionInViewFilter.doFilterInternal(OpenSessionInViewFilter.java:233)
  org.springframework.web.filter.OncePerRequestFilter.doFilter(OncePerRequestFilter.java:107)
  </code></pre>
  
  <p>From the stacktrace : </p>
  
  <blockquote>
    <p>no.uio.inf5750.assignment2.dao.hibernate.HibernateStudentDao.getAllStudents(HibernateStudentDao.java:54)</p>
  </blockquote>
  
  <p>the code:</p>
  
  <pre><code>public Collection&lt;Student&gt; getAllStudents() {    
      Session session = sessionFactory.getCurrentSession();    
      String hql = "from Student";    
      Query query = session.createQuery(hql);    
      return (Collection&lt;Student&gt;)query.list();    &lt;- java:54
  }
  </code></pre>