使用JSF,JPA 2.0,hibernate进行数据库更新所需的帮助

时间:2010-11-30 15:32:16

标签: database hibernate jsf jpa

我正在使用JPA 2.0和hibernate在数据库中保存一些数据并在以后更新它们。数据是通过基于JSF 2.0 web的UI输入的。它给出了以下异常,并且无法弄清楚原因是什么。我是所有这些的新手,所以真的需要一些帮助。

先谢谢,我已经发布了以下代码和例外内容。

int i=em.createQuery("UPDATE UserGroup g SET g.groupName = 'CrazyTest' WHERE g.id="+order.getId()).executeUpdate();
16:19:00.359 (31473614@qtp-21250902-2) WARN  - o.h.util.JDBCExceptionReporter: SQL Error: -3401, SQLState: 22001
16:19:00.359 (31473614@qtp-21250902-2) ERROR - o.h.util.JDBCExceptionReporter: data exception: string data, right truncation
16:19:00.375 (31473614@qtp-21250902-2) ERROR - o.h.e.d.AbstractFlushingEventListener: Could not synchronize database state with session
org.hibernate.exception.DataException: could not update: 
 at org.hibernate.exception.SQLStateConverter.convert(SQLStateConverter.java:102) ~[hibernate-core-3.5.1-Final.jar:3.5.1-Final]

完整堆栈跟踪复制在

下面
16:19:00.359 (31473614@qtp-21250902-2) WARN  - o.h.util.JDBCExceptionReporter: SQL Error: -3401, SQLState: 22001
16:19:00.359 (31473614@qtp-21250902-2) ERROR - o.h.util.JDBCExceptionReporter: data exception: string data, right truncation
16:19:00.375 (31473614@qtp-21250902-2) ERROR - o.h.e.d.AbstractFlushingEventListener: Could not synchronize database state with session
org.hibernate.exception.DataException: could not update: [Order#3]
 at org.hibernate.exception.SQLStateConverter.convert(SQLStateConverter.java:102) ~[hibernate-core-3.5.1-Final.jar:3.5.1-Final]
 at org.hibernate.exception.JDBCExceptionHelper.convert(JDBCExceptionHelper.java:66) ~[hibernate-core-3.5.1-Final.jar:3.5.1-Final]
 at org.hibernate.persister.entity.AbstractEntityPersister.update(AbstractEntityPersister.java:2596) ~[hibernate-core-3.5.1-Final.jar:3.5.1-Final]
 at org.hibernate.persister.entity.AbstractEntityPersister.updateOrInsert(AbstractEntityPersister.java:2478) ~[hibernate-core-3.5.1-Final.jar:3.5.1-Final]
 at org.hibernate.persister.entity.AbstractEntityPersister.update(AbstractEntityPersister.java:2805) ~[hibernate-core-3.5.1-Final.jar:3.5.1-Final]
 at org.hibernate.action.EntityUpdateAction.execute(EntityUpdateAction.java:114) ~[hibernate-core-3.5.1-Final.jar:3.5.1-Final]
 at org.hibernate.engine.ActionQueue.execute(ActionQueue.java:268) ~[hibernate-core-3.5.1-Final.jar:3.5.1-Final]
 at org.hibernate.engine.ActionQueue.executeActions(ActionQueue.java:260) ~[hibernate-core-3.5.1-Final.jar:3.5.1-Final]
 at org.hibernate.engine.ActionQueue.executeActions(ActionQueue.java:180) ~[hibernate-core-3.5.1-Final.jar:3.5.1-Final]
 at org.hibernate.event.def.AbstractFlushingEventListener.performExecutions(AbstractFlushingEventListener.java:321) ~[hibernate-core-3.5.1-Final.jar:3.5.1-Final]
 at org.hibernate.event.def.DefaultAutoFlushEventListener.onAutoFlush(DefaultAutoFlushEventListener.java:64) [hibernate-core-3.5.1-Final.jar:3.5.1-Final]
 at org.hibernate.impl.SessionImpl.autoFlushIfRequired(SessionImpl.java:1175) [hibernate-core-3.5.1-Final.jar:3.5.1-Final]
 at org.hibernate.impl.SessionImpl.executeUpdate(SessionImpl.java:1273) [hibernate-core-3.5.1-Final.jar:3.5.1-Final]
 at org.hibernate.impl.QueryImpl.executeUpdate(QueryImpl.java:117) [hibernate-core-3.5.1-Final.jar:3.5.1-Final]
 at org.hibernate.ejb.QueryImpl.internalExecuteUpdate(QueryImpl.java:183) [hibernate-entitymanager-3.5.1-Final.jar:3.5.1-Final]
 at org.hibernate.ejb.AbstractQueryImpl.executeUpdate(AbstractQueryImpl.java:99) [hibernate-entitymanager-3.5.1-Final.jar:3.5.1-Final]
 at com.digia.sesath.web.service.ProfileService.findGroup(ProfileService.java:51) [classes/:na]
 at com.digia.sesath.web.service.ProfileService$$FastClassByCGLIB$$492d6578.invoke() [cglib-2.2.jar:na]
 at net.sf.cglib.proxy.MethodProxy.invoke(MethodProxy.java:191) [cglib-2.2.jar:na]
 at org.springframework.aop.framework.Cglib2AopProxy$CglibMethodInvocation.invokeJoinpoint(Cglib2AopProxy.java:692) [spring-aop-3.0.2.RELEASE.jar:3.0.2.RELEASE]
 at org.springframework.aop.framework.ReflectiveMethodInvocation.proceed(ReflectiveMethodInvocation.java:150) [spring-aop-3.0.2.RELEASE.jar:3.0.2.RELEASE]
 at org.springframework.transaction.interceptor.TransactionInterceptor.invoke(TransactionInterceptor.java:110) [spring-tx-3.0.2.RELEASE.jar:3.0.2.RELEASE]
 at org.springframework.aop.framework.ReflectiveMethodInvocation.proceed(ReflectiveMethodInvocation.java:172) [spring-aop-3.0.2.RELEASE.jar:3.0.2.RELEASE]
 at org.springframework.aop.framework.Cglib2AopProxy$DynamicAdvisedInterceptor.intercept(Cglib2AopProxy.java:625) [spring-aop-3.0.2.RELEASE.jar:3.0.2.RELEASE]
 at com.digia.sesath.web.service.ProfileService$$EnhancerByCGLIB$$932e77e4.findGroup() [cglib-2.2.jar:na]
 at com.digia.sesath.web.component.permissionManager.GroupUpdateBean.updateGroupDetails(GroupUpdateBean.java:56) [classes/:na]
 at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method) ~[na:1.6.0_18]
 at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:39) ~[na:1.6.0_18]
 at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:25) ~[na:1.6.0_18]
 at java.lang.reflect.Method.invoke(Method.java:597) ~[na:1.6.0_18]
 at javax.el.BeanELResolver.invokeMethod(BeanELResolver.java:737) [el-api-2.2.jar:na]
 at javax.el.BeanELResolver.invoke(BeanELResolver.java:467) [el-api-2.2.jar:na]
 at javax.el.CompositeELResolver.invoke(CompositeELResolver.java:246) [el-api-2.2.jar:na]
 at com.sun.el.parser.AstValue.invoke(AstValue.java:228) [el-impl-2.2.jar:na]
 at com.sun.el.MethodExpressionImpl.invoke(MethodExpressionImpl.java:297) [el-impl-2.2.jar:na]
 at com.sun.faces.facelets.el.TagMethodExpression.invoke(TagMethodExpression.java:98) [jsf-impl-2.0.2.jar:2.0.2-FCS]
 at javax.faces.component.MethodBindingMethodExpressionAdapter.invoke(MethodBindingMethodExpressionAdapter.java:88) [jsf-api-2.0.jar:2.0.2-SNAPSHOT]
 at com.sun.faces.application.ActionListenerImpl.processAction(ActionListenerImpl.java:102) [jsf-impl-2.0.2.jar:2.0.2-FCS]
 at javax.faces.component.UICommand.broadcast(UICommand.java:315) [jsf-api-2.0.jar:2.0.2-SNAPSHOT]
 at javax.faces.component.UIViewRoot.broadcastEvents(UIViewRoot.java:775) [jsf-api-2.0.jar:2.0.2-SNAPSHOT]
 at javax.faces.component.UIViewRoot.processApplication(UIViewRoot.java:1267) [jsf-api-2.0.jar:2.0.2-SNAPSHOT]
 at com.sun.faces.lifecycle.InvokeApplicationPhase.execute(InvokeApplicationPhase.java:82) [jsf-impl-2.0.2.jar:2.0.2-FCS]
 at com.sun.faces.lifecycle.Phase.doPhase(Phase.java:101) [jsf-impl-2.0.2.jar:2.0.2-FCS]
 at com.sun.faces.lifecycle.LifecycleImpl.execute(LifecycleImpl.java:118) [jsf-impl-2.0.2.jar:2.0.2-FCS]
 at javax.faces.webapp.FacesServlet.service(FacesServlet.java:312) [jsf-api-2.0.jar:2.0.2-SNAPSHOT]
 at org.mortbay.jetty.servlet.ServletHolder.handle(ServletHolder.java:511) [jetty-6.1.24.jar:6.1.24]
 at org.mortbay.jetty.servlet.ServletHandler$CachedChain.doFilter(ServletHandler.java:1166) [jetty-6.1.24.jar:6.1.24]
 at org.springframework.security.web.FilterChainProxy$VirtualFilterChain.doFilter(FilterChainProxy.java:343) [spring-security-web-3.0.2.RELEASE.jar:na]
 at org.springframework.security.web.access.intercept.FilterSecurityInterceptor.invoke(FilterSecurityInterceptor.java:109) [spring-security-web-3.0.2.RELEASE.jar:na]
 at org.springframework.security.web.access.intercept.FilterSecurityInterceptor.doFilter(FilterSecurityInterceptor.java:83) [spring-security-web-3.0.2.RELEASE.jar:na]
 at org.springframework.security.web.FilterChainProxy$VirtualFilterChain.doFilter(FilterChainProxy.java:355) [spring-security-web-3.0.2.RELEASE.jar:na]
 at org.springframework.security.web.access.ExceptionTranslationFilter.doFilter(ExceptionTranslationFilter.java:97) [spring-security-web-3.0.2.RELEASE.jar:na]
 at org.springframework.security.web.FilterChainProxy$VirtualFilterChain.doFilter(FilterChainProxy.java:355) [spring-security-web-3.0.2.RELEASE.jar:na]
 at org.springframework.security.web.session.SessionManagementFilter.doFilter(SessionManagementFilter.java:100) [spring-security-web-3.0.2.RELEASE.jar:na]
 at org.springframework.security.web.FilterChainProxy$VirtualFilterChain.doFilter(FilterChainProxy.java:355) [spring-security-web-3.0.2.RELEASE.jar:na]
 at org.springframework.security.web.authentication.AnonymousAuthenticationFilter.doFilter(AnonymousAuthenticationFilter.java:78) [spring-security-web-3.0.2.RELEASE.jar:na]
 at org.springframework.security.web.FilterChainProxy$VirtualFilterChain.doFilter(FilterChainProxy.java:355) [spring-security-web-3.0.2.RELEASE.jar:na]
 at org.springframework.security.web.servletapi.SecurityContextHolderAwareRequestFilter.doFilter(SecurityContextHolderAwareRequestFilter.java:54) [spring-security-web-3.0.2.RELEASE.jar:na]
 at org.springframework.security.web.FilterChainProxy$VirtualFilterChain.doFilter(FilterChainProxy.java:355) [spring-security-web-3.0.2.RELEASE.jar:na]
 at org.springframework.security.web.savedrequest.RequestCacheAwareFilter.doFilter(RequestCacheAwareFilter.java:35) [spring-security-web-3.0.2.RELEASE.jar:na]
 at org.springframework.security.web.FilterChainProxy$VirtualFilterChain.doFilter(FilterChainProxy.java:355) [spring-security-web-3.0.2.RELEASE.jar:na]
 at org.springframework.security.web.authentication.www.BasicAuthenticationFilter.doFilter(BasicAuthenticationFilter.java:177) [spring-security-web-3.0.2.RELEASE.jar:na]
 at org.springframework.security.web.FilterChainProxy$VirtualFilterChain.doFilter(FilterChainProxy.java:355) [spring-security-web-3.0.2.RELEASE.jar:na]
 at org.springframework.security.web.authentication.AbstractAuthenticationProcessingFilter.doFilter(AbstractAuthenticationProcessingFilter.java:188) [spring-security-web-3.0.2.RELEASE.jar:na]
 at org.springframework.security.web.FilterChainProxy$VirtualFilterChain.doFilter(FilterChainProxy.java:355) [spring-security-web-3.0.2.RELEASE.jar:na]
 at org.springframework.security.web.authentication.logout.LogoutFilter.doFilter(LogoutFilter.java:105) [spring-security-web-3.0.2.RELEASE.jar:na]
 at org.springframework.security.web.FilterChainProxy$VirtualFilterChain.doFilter(FilterChainProxy.java:355) [spring-security-web-3.0.2.RELEASE.jar:na]
 at org.springframework.security.web.context.SecurityContextPersistenceFilter.doFilter(SecurityContextPersistenceFilter.java:79) [spring-security-web-3.0.2.RELEASE.jar:na]
 at org.springframework.security.web.FilterChainProxy$VirtualFilterChain.doFilter(FilterChainProxy.java:355) [spring-security-web-3.0.2.RELEASE.jar:na]
 at org.springframework.security.web.session.ConcurrentSessionFilter.doFilter(ConcurrentSessionFilter.java:109) [spring-security-web-3.0.2.RELEASE.jar:na]
 at org.springframework.security.web.FilterChainProxy$VirtualFilterChain.doFilter(FilterChainProxy.java:355) [spring-security-web-3.0.2.RELEASE.jar:na]
 at org.springframework.security.web.FilterChainProxy.doFilter(FilterChainProxy.java:149) [spring-security-web-3.0.2.RELEASE.jar:na]
 at org.springframework.web.filter.DelegatingFilterProxy.invokeDelegate(DelegatingFilterProxy.java:237) [spring-web-3.0.2.RELEASE.jar:3.0.2.RELEASE]
 at org.springframework.web.filter.DelegatingFilterProxy.doFilter(DelegatingFilterProxy.java:167) [spring-web-3.0.2.RELEASE.jar:3.0.2.RELEASE]
 at org.mortbay.jetty.servlet.ServletHandler$CachedChain.doFilter(ServletHandler.java:1157) [jetty-6.1.24.jar:6.1.24]
 at org.springframework.orm.jpa.support.OpenEntityManagerInViewFilter.doFilterInternal(OpenEntityManagerInViewFilter.java:113) [spring-orm-3.0.2.RELEASE.jar:3.0.2.RELEASE]
 at org.springframework.web.filter.OncePerRequestFilter.doFilter(OncePerRequestFilter.java:76) [spring-web-3.0.2.RELEASE.jar:3.0.2.RELEASE]
 at org.mortbay.jetty.servlet.ServletHandler$CachedChain.doFilter(ServletHandler.java:1157) [jetty-6.1.24.jar:6.1.24]
 at org.mortbay.jetty.servlet.ServletHandler.handle(ServletHandler.java:388) [jetty-6.1.24.jar:6.1.24]
 at org.mortbay.jetty.security.SecurityHandler.handle(SecurityHandler.java:216) [jetty-6.1.24.jar:6.1.24]
 at org.mortbay.jetty.servlet.SessionHandler.handle(SessionHandler.java:182) [jetty-6.1.24.jar:6.1.24]
 at org.mortbay.jetty.handler.ContextHandler.handle(ContextHandler.java:765) [jetty-6.1.24.jar:6.1.24]
 at org.mortbay.jetty.webapp.WebAppContext.handle(WebAppContext.java:418) [jetty-6.1.24.jar:6.1.24]
 at org.mortbay.jetty.handler.ContextHandlerCollection.handle(ContextHandlerCollection.java:230) [jetty-6.1.24.jar:6.1.24]
 at org.mortbay.jetty.handler.HandlerCollection.handle(HandlerCollection.java:114) [jetty-6.1.24.jar:6.1.24]
 at org.mortbay.jetty.handler.HandlerWrapper.handle(HandlerWrapper.java:152) [jetty-6.1.24.jar:6.1.24]
 at org.mortbay.jetty.Server.handle(Server.java:326) [jetty-6.1.24.jar:6.1.24]
 at org.mortbay.jetty.HttpConnection.handleRequest(HttpConnection.java:542) [jetty-6.1.24.jar:6.1.24]
 at org.mortbay.jetty.HttpConnection$RequestHandler.content(HttpConnection.java:943) [jetty-6.1.24.jar:6.1.24]
 at org.mortbay.jetty.HttpParser.parseNext(HttpParser.java:756) [jetty-6.1.24.jar:6.1.24]
 at org.mortbay.jetty.HttpParser.parseAvailable(HttpParser.java:218) [jetty-6.1.24.jar:6.1.24]
 at org.mortbay.jetty.HttpConnection.handle(HttpConnection.java:404) [jetty-6.1.24.jar:6.1.24]
 at org.mortbay.io.nio.SelectChannelEndPoint.run(SelectChannelEndPoint.java:410) [jetty-6.1.24.jar:6.1.24]
 at org.mortbay.thread.QueuedThreadPool$PoolThread.run(QueuedThreadPool.java:582) [jetty-util-6.1.24.jar:6.1.24]
Caused by: java.sql.SQLException: data exception: string data, right truncation
 at org.hsqldb.jdbc.Util.sqlException(Unknown Source) ~[hsqldb-2.0.0.jar:2.0.0]
 at org.hsqldb.jdbc.JDBCPreparedStatement.fetchResult(Unknown Source) ~[hsqldb-2.0.0.jar:2.0.0]
 at org.hsqldb.jdbc.JDBCPreparedStatement.executeUpdate(Unknown Source) ~[hsqldb-2.0.0.jar:2.0.0]
 at org.apache.commons.dbcp.DelegatingPreparedStatement.executeUpdate(DelegatingPreparedStatement.java:105) ~[commons-dbcp-1.4.jar:1.4]
 at org.apache.commons.dbcp.DelegatingPreparedStatement.executeUpdate(DelegatingPreparedStatement.java:105) ~[commons-dbcp-1.4.jar:1.4]
 at org.hibernate.persister.entity.AbstractEntityPersister.update(AbstractEntityPersister.java:2578) ~[hibernate-core-3.5.1-Final.jar:3.5.1-Final]
 ... 91 common frames omitted
Caused by: org.hsqldb.HsqlException: data exception: string data, right truncation
 at org.hsqldb.error.Error.error(Unknown Source) ~[hsqldb-2.0.0.jar:2.0.0]
 at org.hsqldb.error.Error.error(Unknown Source) ~[hsqldb-2.0.0.jar:2.0.0]
 at org.hsqldb.types.BinaryType.castOrConvertToType(Unknown Source) ~[hsqldb-2.0.0.jar:2.0.0]
 at org.hsqldb.types.BinaryType.convertToType(Unknown Source) ~[hsqldb-2.0.0.jar:2.0.0]
 at org.hsqldb.StatementDML.getUpdatedData(Unknown Source) ~[hsqldb-2.0.0.jar:2.0.0]
 at org.hsqldb.StatementDML.executeUpdateStatement(Unknown Source) ~[hsqldb-2.0.0.jar:2.0.0]
 at org.hsqldb.StatementDML.getResult(Unknown Source) ~[hsqldb-2.0.0.jar:2.0.0]
 at org.hsqldb.StatementDMQL.execute(Unknown Source) ~[hsqldb-2.0.0.jar:2.0.0]
 at org.hsqldb.Session.executeCompiledStatement(Unknown Source) ~[hsqldb-2.0.0.jar:2.0.0]
 at org.hsqldb.Session.execute(Unknown Source) ~[hsqldb-2.0.0.jar:2.0.0]
 ... 96 common frames omitted
30.11.2010 16:19:00 com.sun.faces.application.ActionListenerImpl processAction
SEVERE: javax.persistence.PersistenceException: org.hibernate.exception.DataException: could not update: [Order#3]
javax.faces.el.EvaluationException: javax.persistence.PersistenceException: org.hibernate.exception.DataException: could not update: [Order#3]
 at javax.faces.component.MethodBindingMethodExpressionAdapter.invoke(MethodBindingMethodExpressionAdapter.java:102)
 at com.sun.faces.application.ActionListenerImpl.processAction(ActionListenerImpl.java:102)
 at javax.faces.component.UICommand.broadcast(UICommand.java:315)
 at javax.faces.component.UIViewRoot.broadcastEvents(UIViewRoot.java:775)
 at javax.faces.component.UIViewRoot.processApplication(UIViewRoot.java:1267)
 at com.sun.faces.lifecycle.InvokeApplicationPhase.execute(InvokeApplicationPhase.java:82)
 at com.sun.faces.lifecycle.Phase.doPhase(Phase.java:101)
 at com.sun.faces.lifecycle.LifecycleImpl.execute(LifecycleImpl.java:118)
 at javax.faces.webapp.FacesServlet.service(FacesServlet.java:312)
 at org.mortbay.jetty.servlet.ServletHolder.handle(ServletHolder.java:511)
 at org.mortbay.jetty.servlet.ServletHandler$CachedChain.doFilter(ServletHandler.java:1166)
 at org.springframework.security.web.FilterChainProxy$VirtualFilterChain.doFilter(FilterChainProxy.java:343)
 at org.springframework.security.web.access.intercept.FilterSecurityInterceptor.invoke(FilterSecurityInterceptor.java:109)
 at org.springframework.security.web.access.intercept.FilterSecurityInterceptor.doFilter(FilterSecurityInterceptor.java:83)
 at org.springframework.security.web.FilterChainProxy$VirtualFilterChain.doFilter(FilterChainProxy.java:355)
 at org.springframework.security.web.access.ExceptionTranslationFilter.doFilter(ExceptionTranslationFilter.java:97)
 at org.springframework.security.web.FilterChainProxy$VirtualFilterChain.doFilter(FilterChainProxy.java:355)
 at org.springframework.security.web.session.SessionManagementFilter.doFilter(SessionManagementFilter.java:100)
 at org.springframework.security.web.FilterChainProxy$VirtualFilterChain.doFilter(FilterChainProxy.java:355)
 at org.springframework.security.web.authentication.AnonymousAuthenticationFilter.doFilter(AnonymousAuthenticationFilter.java:78)
 at org.springframework.security.web.FilterChainProxy$VirtualFilterChain.doFilter(FilterChainProxy.java:355)
 at org.springframework.security.web.servletapi.SecurityContextHolderAwareRequestFilter.doFilter(SecurityContextHolderAwareRequestFilter.java:54)
 at org.springframework.security.web.FilterChainProxy$VirtualFilterChain.doFilter(FilterChainProxy.java:355)
 at org.springframework.security.web.savedrequest.RequestCacheAwareFilter.doFilter(RequestCacheAwareFilter.java:35)
 at org.springframework.security.web.FilterChainProxy$VirtualFilterChain.doFilter(FilterChainProxy.java:355)
 at org.springframework.security.web.authentication.www.BasicAuthenticationFilter.doFilter(BasicAuthenticationFilter.java:177)
 at org.springframework.security.web.FilterChainProxy$VirtualFilterChain.doFilter(FilterChainProxy.java:355)
 at org.springframework.security.web.authentication.AbstractAuthenticationProcessingFilter.doFilter(AbstractAuthenticationProcessingFilter.java:188)
 at org.springframework.security.web.FilterChainProxy$VirtualFilterChain.doFilter(FilterChainProxy.java:355)
 at org.springframework.security.web.authentication.logout.LogoutFilter.doFilter(LogoutFilter.java:105)
 at org.springframework.security.web.FilterChainProxy$VirtualFilterChain.doFilter(FilterChainProxy.java:355)
 at org.springframework.security.web.context.SecurityContextPersistenceFilter.doFilter(SecurityContextPersistenceFilter.java:79)
 at org.springframework.security.web.FilterChainProxy$VirtualFilterChain.doFilter(FilterChainProxy.java:355)
 at org.springframework.security.web.session.ConcurrentSessionFilter.doFilter(ConcurrentSessionFilter.java:109)
 at org.springframework.security.web.FilterChainProxy$VirtualFilterChain.doFilter(FilterChainProxy.java:355)
 at org.springframework.security.web.FilterChainProxy.doFilter(FilterChainProxy.java:149)
 at org.springframework.web.filter.DelegatingFilterProxy.invokeDelegate(DelegatingFilterProxy.java:237)
 at org.springframework.web.filter.DelegatingFilterProxy.doFilter(DelegatingFilterProxy.java:167)
 at org.mortbay.jetty.servlet.ServletHandler$CachedChain.doFilter(ServletHandler.java:1157)
 at org.springframework.orm.jpa.support.OpenEntityManagerInViewFilter.doFilterInternal(OpenEntityManagerInViewFilter.java:113)
 at org.springframework.web.filter.OncePerRequestFilter.doFilter(OncePerRequestFilter.java:76)
 at org.mortbay.jetty.servlet.ServletHandler$CachedChain.doFilter(ServletHandler.java:1157)
 at org.mortbay.jetty.servlet.ServletHandler.handle(ServletHandler.java:388)
 at org.mortbay.jetty.security.SecurityHandler.handle(SecurityHandler.java:216)
 at org.mortbay.jetty.servlet.SessionHandler.handle(SessionHandler.java:182)
 at org.mortbay.jetty.handler.ContextHandler.handle(ContextHandler.java:765)
 at org.mortbay.jetty.webapp.WebAppContext.handle(WebAppContext.java:418)
 at org.mortbay.jetty.handler.ContextHandlerCollection.handle(ContextHandlerCollection.java:230)
 at org.mortbay.jetty.handler.HandlerCollection.handle(HandlerCollection.java:114)
 at org.mortbay.jetty.handler.HandlerWrapper.handle(HandlerWrapper.java:152)
 at org.mortbay.jetty.Server.handle(Server.java:326)
 at org.mortbay.jetty.HttpConnection.handleRequest(HttpConnection.java:542)
 at org.mortbay.jetty.HttpConnection$RequestHandler.content(HttpConnection.java:943)
 at org.mortbay.jetty.HttpParser.parseNext(HttpParser.java:756)
 at org.mortbay.jetty.HttpParser.parseAvailable(HttpParser.java:218)
 at org.mortbay.jetty.HttpConnection.handle(HttpConnection.java:404)
 at org.mortbay.io.nio.SelectChannelEndPoint.run(SelectChannelEndPoint.java:410)
 at org.mortbay.thread.QueuedThreadPool$PoolThread.run(QueuedThreadPool.java:582)
Caused by: javax.persistence.PersistenceException: org.hibernate.exception.DataException: could not update: [com.digia.sesath.web.domain.Group#3]
 at org.hibernate.ejb.AbstractEntityManagerImpl.convert(AbstractEntityManagerImpl.java:1235)
 at org.hibernate.ejb.AbstractEntityManagerImpl.convert(AbstractEntityManagerImpl.java:1168)
 at org.hibernate.ejb.AbstractEntityManagerImpl.throwPersistenceException(AbstractEntityManagerImpl.java:1245)
 at org.hibernate.ejb.AbstractQueryImpl.executeUpdate(AbstractQueryImpl.java:108)
 at com.digia.sesath.web.service.ProfileService.findGroup(ProfileService.java:51)
 at com.digia.sesath.web.service.ProfileService$$FastClassByCGLIB$$492d6578.invoke()
 at net.sf.cglib.proxy.MethodProxy.invoke(MethodProxy.java:191)
 at org.springframework.aop.framework.Cglib2AopProxy$CglibMethodInvocation.invokeJoinpoint(Cglib2AopProxy.java:692)
 at org.springframework.aop.framework.ReflectiveMethodInvocation.proceed(ReflectiveMethodInvocation.java:150)
 at org.springframework.transaction.interceptor.TransactionInterceptor.invoke(TransactionInterceptor.java:110)
 at org.springframework.aop.framework.ReflectiveMethodInvocation.proceed(ReflectiveMethodInvocation.java:172)
 at org.springframework.aop.framework.Cglib2AopProxy$DynamicAdvisedInterceptor.intercept(Cglib2AopProxy.java:625)
 at com.digia.sesath.web.service.ProfileService$$EnhancerByCGLIB$$932e77e4.findGroup()
 at com.digia.sesath.web.component.permissionManager.GroupUpdateBean.updateGroupDetails(GroupUpdateBean.java:56)
 at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
 at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:39)
 at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:25)
 at java.lang.reflect.Method.invoke(Method.java:597)
 at javax.el.BeanELResolver.invokeMethod(BeanELResolver.java:737)
 at javax.el.BeanELResolver.invoke(BeanELResolver.java:467)
 at javax.el.CompositeELResolver.invoke(CompositeELResolver.java:246)
 at com.sun.el.parser.AstValue.invoke(AstValue.java:228)
 at com.sun.el.MethodExpressionImpl.invoke(MethodExpressionImpl.java:297)
 at com.sun.faces.facelets.el.TagMethodExpression.invoke(TagMethodExpression.java:98)
 at javax.faces.component.MethodBindingMethodExpressionAdapter.invoke(MethodBindingMethodExpressionAdapter.java:88)
 ... 57 more
Caused by: org.hibernate.exception.DataException: could not update: [com.digia.sesath.web.domain.Group#3]
 at org.hibernate.exception.SQLStateConverter.convert(SQLStateConverter.java:102)
 at org.hibernate.exception.JDBCExceptionHelper.convert(JDBCExceptionHelper.java:66)
 at org.hibernate.persister.entity.AbstractEntityPersister.update(AbstractEntityPersister.java:2596)
 at org.hibernate.persister.entity.AbstractEntityPersister.updateOrInsert(AbstractEntityPersister.java:2478)
 at org.hibernate.persister.entity.AbstractEntityPersister.update(AbstractEntityPersister.java:2805)
 at org.hibernate.action.EntityUpdateAction.execute(EntityUpdateAction.java:114)
 at org.hibernate.engine.ActionQueue.execute(ActionQueue.java:268)
 at org.hibernate.engine.ActionQueue.executeActions(ActionQueue.java:260)
 at org.hibernate.engine.ActionQueue.executeActions(ActionQueue.java:180)
 at org.hibernate.event.def.AbstractFlushingEventListener.performExecutions(AbstractFlushingEventListener.java:321)
 at org.hibernate.event.def.DefaultAutoFlushEventListener.onAutoFlush(DefaultAutoFlushEventListener.java:64)
 at org.hibernate.impl.SessionImpl.autoFlushIfRequired(SessionImpl.java:1175)
 at org.hibernate.impl.SessionImpl.executeUpdate(SessionImpl.java:1273)
 at org.hibernate.impl.QueryImpl.executeUpdate(QueryImpl.java:117)
 at org.hibernate.ejb.QueryImpl.internalExecuteUpdate(QueryImpl.java:183)
 at org.hibernate.ejb.AbstractQueryImpl.executeUpdate(AbstractQueryImpl.java:99)
 ... 78 more
Caused by: java.sql.SQLException: data exception: string data, right truncation
 at org.hsqldb.jdbc.Util.sqlException(Unknown Source)
 at org.hsqldb.jdbc.JDBCPreparedStatement.fetchResult(Unknown Source)
 at org.hsqldb.jdbc.JDBCPreparedStatement.executeUpdate(Unknown Source)
 at org.apache.commons.dbcp.DelegatingPreparedStatement.executeUpdate(DelegatingPreparedStatement.java:105)
 at org.apache.commons.dbcp.DelegatingPreparedStatement.executeUpdate(DelegatingPreparedStatement.java:105)
 at org.hibernate.persister.entity.AbstractEntityPersister.update(AbstractEntityPersister.java:2578)
 ... 91 more
Caused by: org.hsqldb.HsqlException: data exception: string data, right truncation
 at org.hsqldb.error.Error.error(Unknown Source)
 at org.hsqldb.error.Error.error(Unknown Source)
 at org.hsqldb.types.BinaryType.castOrConvertToType(Unknown Source)
 at org.hsqldb.types.BinaryType.convertToType(Unknown Source)
 at org.hsqldb.StatementDML.getUpdatedData(Unknown Source)
 at org.hsqldb.StatementDML.executeUpdateStatement(Unknown Source)
 at org.hsqldb.StatementDML.getResult(Unknown Source)
 at org.hsqldb.StatementDMQL.execute(Unknown Source)
 at org.hsqldb.Session.executeCompiledStatement(Unknown Source)
 at org.hsqldb.Session.execute(Unknown Source)
 ... 96 more
30.11.2010 16:19:00 com.sun.faces.lifecycle.InvokeApplicationPhase execute
WARNING: #{groupUpdateBean.updateGroupDetails()}: javax.persistence.PersistenceException: org.hibernate.exception.DataException: could not update: []
javax.faces.FacesException: #{groupUpdateBean.updateGroupDetails()}: javax.persistence.PersistenceException: org.hibernate.exception.DataException: could not update: [Order#3]
 at com.sun.faces.application.ActionListenerImpl.processAction(ActionListenerImpl.java:118)
 at javax.faces.component.UICommand.broadcast(UICommand.java:315)
 at javax.faces.component.UIViewRoot.broadcastEvents(UIViewRoot.java:775)
 at javax.faces.component.UIViewRoot.processApplication(UIViewRoot.java:1267)
 at com.sun.faces.lifecycle.InvokeApplicationPhase.execute(InvokeApplicationPhase.java:82)
 at com.sun.faces.lifecycle.Phase.doPhase(Phase.java:101)
 at com.sun.faces.lifecycle.LifecycleImpl.execute(LifecycleImpl.java:118)
 at javax.faces.webapp.FacesServlet.service(FacesServlet.java:312)
 at org.mortbay.jetty.servlet.ServletHolder.handle(ServletHolder.java:511)
 at org.mortbay.jetty.servlet.ServletHandler$CachedChain.doFilter(ServletHandler.java:1166)
 at org.springframework.security.web.FilterChainProxy$VirtualFilterChain.doFilter(FilterChainProxy.java:343)
 at org.springframework.security.web.access.intercept.FilterSecurityInterceptor.invoke(FilterSecurityInterceptor.java:109)
 at org.springframework.security.web.access.intercept.FilterSecurityInterceptor.doFilter(FilterSecurityInterceptor.java:83)
 at org.springframework.security.web.FilterChainProxy$VirtualFilterChain.doFilter(FilterChainProxy.java:355)
 at org.springframework.security.web.access.ExceptionTranslationFilter.doFilter(ExceptionTranslationFilter.java:97)
 at org.springframework.security.web.FilterChainProxy$VirtualFilterChain.doFilter(FilterChainProxy.java:355)
 at org.springframework.security.web.session.SessionManagementFilter.doFilter(SessionManagementFilter.java:100)
 at org.springframework.security.web.FilterChainProxy$VirtualFilterChain.doFilter(FilterChainProxy.java:355)
 at org.springframework.security.web.authentication.AnonymousAuthenticationFilter.doFilter(AnonymousAuthenticationFilter.java:78)
 at org.springframework.security.web.FilterChainProxy$VirtualFilterChain.doFilter(FilterChainProxy.java:355)
 at org.springframework.security.web.servletapi.SecurityContextHolderAwareRequestFilter.doFilter(SecurityContextHolderAwareRequestFilter.java:54)
 at org.springframework.security.web.FilterChainProxy$VirtualFilterChain.doFilter(FilterChainProxy.java:355)
 at org.springframework.security.web.savedrequest.RequestCacheAwareFilter.doFilter(RequestCacheAwareFilter.java:35)
 at org.springframework.security.web.FilterChainProxy$VirtualFilterChain.doFilter(FilterChainProxy.java:355)
 at 

2 个答案:

答案 0 :(得分:1)

检查order.getId()是否正在返回您认为的内容。听起来返回的值对于列大小来说太大了。

答案 1 :(得分:0)

您的数据库列似乎是“varchar”,或者您的java属性是String。验证两者都是整数。

此外,避免将原始参数值连接到SQL中。它使您容易受到SQL注入[1]的攻击。为此,请使用预准备语句,或者,如果是Hibernate,则可以使用Query对象。像这样:

Query query = em.createQuery("UPDATE UserGroup g SET g.groupName = 'CrazyTest' WHERE g.id= :id"
int i= query.setParameter("id",order.getId()).executeUpdate();

1 - http://www.owasp.org/index.php/SQL_Injection