hibernate mysql 报错 简单问题

[code="java"]
Hibernate: update tb_news_radio set state='审核否决', shenhe_name='admin', shenhe_time=now() where id=135
2012-02-05 12:31:08,984 [http-5000-1] ERROR org.hibernate.util.JDBCExceptionReporter - Data truncation: Data truncated for column 'shenhe_time' at row 1
org.hibernate.exception.DataException: could not execute update query
at org.hibernate.exception.SQLStateConverter.convert(SQLStateConverter.java:100)
at org.hibernate.exception.JDBCExceptionHelper.convert(JDBCExceptionHelper.java:66)
at org.hibernate.hql.ast.exec.BasicExecutor.execute(BasicExecutor.java:107)
at org.hibernate.hql.ast.QueryTranslatorImpl.executeUpdate(QueryTranslatorImpl.java:419)
at org.hibernate.engine.query.HQLQueryPlan.performExecuteUpdate(HQLQueryPlan.java:283)
at org.hibernate.impl.SessionImpl.executeUpdate(SessionImpl.java:1168)
at org.hibernate.impl.QueryImpl.executeUpdate(QueryImpl.java:117)
at com.acec.house.service.admin.AdminManager.shipinPass(AdminManager.java:442)
at com.acec.house.service.admin.AdminManager$$FastClassByCGLIB$$c5f9ca65.invoke()
at net.sf.cglib.proxy.MethodProxy.invoke(MethodProxy.java:149)
at org.springframework.aop.framework.Cglib2AopProxy$CglibMethodInvocation.invokeJoinpoint(Cglib2AopProxy.java:700)
at org.springframework.aop.framework.ReflectiveMethodInvocation.proceed(ReflectiveMethodInvocation.java:149)
at org.springframework.transaction.interceptor.TransactionInterceptor.invoke(TransactionInterceptor.java:106)
at org.springframework.aop.framework.ReflectiveMethodInvocation.proceed(ReflectiveMethodInvocation.java:171)
at org.springframework.aop.framework.Cglib2AopProxy$DynamicAdvisedInterceptor.intercept(Cglib2AopProxy.java:635)
at com.acec.house.service.admin.AdminManager$$EnhancerByCGLIB$$2536b346.shipinPass()
at com.acec.house.actions.admin.AdminAction.shipinPass(AdminAction.java:1002)
at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
at sun.reflect.NativeMethodAccessorImpl.invoke(Unknown Source)
at sun.reflect.DelegatingMethodAccessorImpl.invoke(Unknown Source)
at java.lang.reflect.Method.invoke(Unknown Source)
at com.opensymphony.xwork2.DefaultActionInvocation.invokeAction(DefaultActionInvocation.java:440)
at com.opensymphony.xwork2.DefaultActionInvocation.invokeActionOnly(DefaultActionInvocation.java:279)
at com.opensymphony.xwork2.DefaultActionInvocation.invoke(DefaultActionInvocation.java:242)
at com.opensymphony.xwork2.interceptor.DefaultWorkflowInterceptor.doIntercept(DefaultWorkflowInterceptor.java:163)
at com.opensymphony.xwork2.interceptor.MethodFilterInterceptor.intercept(MethodFilterInterceptor.java:87)
at com.opensymphony.xwork2.DefaultActionInvocation.invoke(DefaultActionInvocation.java:236)
at com.opensymphony.xwork2.validator.ValidationInterceptor.doIntercept(ValidationInterceptor.java:249)
at org.apache.struts2.interceptor.validation.AnnotationValidationInterceptor.doIntercept(AnnotationValidationInterceptor.java:68)
at com.opensymphony.xwork2.interceptor.MethodFilterInterceptor.intercept(MethodFilterInterceptor.java:87)
at com.opensymphony.xwork2.DefaultActionInvocation.invoke(DefaultActionInvocation.java:236)
at com.opensymphony.xwork2.interceptor.ConversionErrorInterceptor.intercept(ConversionErrorInterceptor.java:122)
at com.opensymphony.xwork2.DefaultActionInvocation.invoke(DefaultActionInvocation.java:236)
at com.opensymphony.xwork2.interceptor.ParametersInterceptor.doIntercept(ParametersInterceptor.java:195)
at com.opensymphony.xwork2.interceptor.MethodFilterInterceptor.intercept(MethodFilterInterceptor.java:87)
at com.opensymphony.xwork2.DefaultActionInvocation.invoke(DefaultActionInvocation.java:236)
at com.opensymphony.xwork2.interceptor.ParametersInterceptor.doIntercept(ParametersInterceptor.java:195)
at com.opensymphony.xwork2.interceptor.MethodFilterInterceptor.intercept(MethodFilterInterceptor.java:87)
at com.opensymphony.xwork2.DefaultActionInvocation.invoke(DefaultActionInvocation.java:236)
at com.opensymphony.xwork2.interceptor.StaticParametersInterceptor.intercept(StaticParametersInterceptor.java:148)
at com.opensymphony.xwork2.DefaultActionInvocation.invoke(DefaultActionInvocation.java:236)
at org.apache.struts2.interceptor.CheckboxInterceptor.intercept(CheckboxInterceptor.java:93)
at com.opensymphony.xwork2.DefaultActionInvocation.invoke(DefaultActionInvocation.java:236)
at org.apache.struts2.interceptor.FileUploadInterceptor.intercept(FileUploadInterceptor.java:235)
at com.opensymphony.xwork2.DefaultActionInvocation.invoke(DefaultActionInvocation.java:236)
at com.opensymphony.xwork2.interceptor.ModelDrivenInterceptor.intercept(ModelDrivenInterceptor.java:89)
at com.opensymphony.xwork2.DefaultActionInvocation.invoke(DefaultActionInvocation.java:236)
at com.opensymphony.xwork2.interceptor.ScopedModelDrivenInterceptor.intercept(ScopedModelDrivenInterceptor.java:128)
at com.opensymphony.xwork2.DefaultActionInvocation.invoke(DefaultActionInvocation.java:236)
at org.apache.struts2.interceptor.ProfilingActivationInterceptor.intercept(ProfilingActivationInterceptor.java:104)
at com.opensymphony.xwork2.DefaultActionInvocation.invoke(DefaultActionInvocation.java:236)
at org.apache.struts2.interceptor.debugging.DebuggingInterceptor.intercept(DebuggingInterceptor.java:267)
at com.opensymphony.xwork2.DefaultActionInvocation.invoke(DefaultActionInvocation.java:236)
at com.opensymphony.xwork2.interceptor.ChainingInterceptor.intercept(ChainingInterceptor.java:126)
at com.opensymphony.xwork2.DefaultActionInvocation.invoke(DefaultActionInvocation.java:236)
at com.opensymphony.xwork2.interceptor.PrepareInterceptor.doIntercept(PrepareInterceptor.java:138)
at com.opensymphony.xwork2.interceptor.MethodFilterInterceptor.intercept(MethodFilterInterceptor.java:87)
at com.opensymphony.xwork2.DefaultActionInvocation.invoke(DefaultActionInvocation.java:236)
at com.opensymphony.xwork2.interceptor.I18nInterceptor.intercept(I18nInterceptor.java:148)
at com.opensymphony.xwork2.DefaultActionInvocation.invoke(DefaultActionInvocation.java:236)
at org.apache.struts2.interceptor.ServletConfigInterceptor.intercept(ServletConfigInterceptor.java:164)
at com.opensymphony.xwork2.DefaultActionInvocation.invoke(DefaultActionInvocation.java:236)
at com.opensymphony.xwork2.interceptor.AliasInterceptor.intercept(AliasInterceptor.java:128)
at com.opensymphony.xwork2.DefaultActionInvocation.invoke(DefaultActionInvocation.java:236)
at com.opensymphony.xwork2.interceptor.ExceptionMappingInterceptor.intercept(ExceptionMappingInterceptor.java:176)
at com.opensymphony.xwork2.DefaultActionInvocation.invoke(DefaultActionInvocation.java:236)
at org.apache.struts2.impl.StrutsActionProxy.execute(StrutsActionProxy.java:52)
at org.apache.struts2.dispatcher.Dispatcher.serviceAction(Dispatcher.java:468)
at org.apache.struts2.dispatcher.ng.ExecuteOperations.executeAction(ExecuteOperations.java:77)
at org.apache.struts2.dispatcher.ng.filter.StrutsPrepareAndExecuteFilter.doFilter(StrutsPrepareAndExecuteFilter.java:76)
at org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:235)
at org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:206)
at org.springframework.orm.hibernate3.support.OpenSessionInViewFilter.doFilterInternal(OpenSessionInViewFilter.java:198)
at org.springframework.web.filter.OncePerRequestFilter.doFilter(OncePerRequestFilter.java:76)
at org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:235)
at org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:206)
at org.springframework.web.filter.CharacterEncodingFilter.doFilterInternal(CharacterEncodingFilter.java:96)
at org.springframework.web.filter.OncePerRequestFilter.doFilter(OncePerRequestFilter.java:76)
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:233)
at org.apache.catalina.core.StandardContextValve.invoke(StandardContextValve.java:191)
at org.apache.catalina.core.StandardHostValve.invoke(StandardHostValve.java:128)
at org.apache.catalina.valves.ErrorReportValve.invoke(ErrorReportValve.java:102)
at org.apache.catalina.core.StandardEngineValve.invoke(StandardEngineValve.java:109)
at org.apache.catalina.connector.CoyoteAdapter.service(CoyoteAdapter.java:286)
at org.apache.coyote.http11.Http11Processor.process(Http11Processor.java:845)
at org.apache.coyote.http11.Http11Protocol$Http11ConnectionHandler.process(Http11Protocol.java:583)
at org.apache.tomcat.util.net.JIoEndpoint$Worker.run(JIoEndpoint.java:447)
at java.lang.Thread.run(Unknown Source)
Caused by: com.mysql.jdbc.MysqlDataTruncation: Data truncation: Data truncated for column 'shenhe_time' at row 1
at com.mysql.jdbc.SQLError.convertShowWarningsToSQLWarnings(SQLError.java:717)
at com.mysql.jdbc.MysqlIO.scanForAndThrowDataTruncation(MysqlIO.java:3031)
at com.mysql.jdbc.ServerPreparedStatement.serverExecute(ServerPreparedStatement.java:1241)
at com.mysql.jdbc.ServerPreparedStatement.executeInternal(ServerPreparedStatement.java:685)
at com.mysql.jdbc.PreparedStatement.executeUpdate(PreparedStatement.java:1400)
at com.mysql.jdbc.PreparedStatement.executeUpdate(PreparedStatement.java:1314)
at com.mysql.jdbc.PreparedStatement.executeUpdate(PreparedStatement.java:1299)
at org.apache.commons.dbcp.DelegatingPreparedStatement.executeUpdate(DelegatingPreparedStatement.java:102)
at org.apache.commons.dbcp.DelegatingPreparedStatement.executeUpdate(DelegatingPreparedStatement.java:102)
at org.hibernate.hql.ast.exec.BasicExecutor.execute(BasicExecutor.java:98)
... 87 more

报这个错。我在数据库直接执行sql语句可以执行。
public void shipinPass(Integer id, String pass, String userName) {
if(pass.equals("true"))
manager.createQuery("update NewsRadioEO set state='审核通过',shenheName='"+userName+"',shenheTime=now() where id="+id).executeUpdate();
else
manager.createQuery("update NewsRadioEO set state='审核否决',shenheName='"+userName+"',shenheTime=now() where id="+id).executeUpdate();
}
这样却不行了,我把shenheTime=now() 改成shenheTime='2012-05-05'却可以执行
求指导
[/code]

0

4个回答

建议你做两种尝试:
1.你把now()外面加上单引:
if(pass.equals("true"))

manager.createQuery("update NewsRadioEO set state='审核通过',shenheName='"+userName+"',shenheTime='now()' where id="+id).executeUpdate();
看hibernate是否会把你的now()直接交给数据库处理。
2.你把那个now()用java.util.Date数据类型得到然后赋过去。
if(pass.equals("true"))

manager.createQuery("update NewsRadioEO set state='审核通过',shenheName='"+userName+"',shenheTime='" + new SimpleDateFormat("yyyy-MM-dd").format(new Date()) + "' where id="+id).executeUpdate();

第二种虽然肯定可用,但是多实例化了两个对象,我想你最好先尝试一下第一种方式,不行再采用第二种方式,即用java来获得当前时间。

0

hql有问题

0

shenhe_time是什么类型的?date ? 如果是date类型的在hql可以使用string但格式要正确。希望能帮上忙

0

你需要把now格式化一下吧。

0
Csdn user default icon
上传中...
上传图片
插入图片
抄袭、复制答案,以达到刷声望分或其他目的的行为,在CSDN问答是严格禁止的,一经发现立刻封号。是时候展现真正的技术了!
其他相关推荐
Hibernate连接MySql5.7的部分问题
先把解决问题的代码丢出来一下 src\test\resources\hibernate.cfg.xml <?xml version='1.0' encoding='utf-8'?> <!DOCTYPE hibernate-configuration PUBLIC "-//Hibernate/Hibernate Configuration DTD 3.0//EN...
使用hibernate造成的MySql 8小时问题解决方案
真正解决连接池问题!!
maven+Hibernate mysql驱动无法加载错误
运行之前用maven构建的hibernate项目,突然提示我mysql驱动无法加载 错误信息如下: Exception in thread “main” org.hibernate.boot.registry.classloading.spi.ClassLoadingException: Unable to load class [com.mysql.jdbc.Driver] at o
Hibernate HQL根据中文字段排序(order by)错乱的问题(MySQL数据库)
问题:HQL查询数据库根据中文字段排序时,发生错乱。 原因:网上查了一下原因,说是因为数据库的字符集是utf-8,UTF8 默认校对集是 utf8_general_ci , 它不是按照中文来的。你需要强制让MySQL按中文来排序。MySQL中使用 CONVERT(chineseColumnName USING gbk) 来解决 现在是HQL,不支持convert()怎么办??? 解决办法:给...
MySql数据库Hibernate不能使用别名问题解决
oracle数据库换成了mysql数据库, 结果字段名称使用别名的话提示找不到原字段名, 整理之后解决方案如下: 1, 在连接的url里加上参数, 修改如下:jdbc.url=jdbc:mysql://localhost:3306/jwerp?characterEncoding=utf-8&[color=red]useOldAliasMetadataBehavior=true[/color] ...
使用Hibernate原生SQL映射MYSQL的CHAR(n)类型到String时出错
数据库中有一个currencies表,表中有一个字段code,类型为CHAR(3),用于存放“CNY”,“USD”之类的字符串 与之对应的Java对象中的字段是String类型   如果通过Entity映射,没有问题,可以; 但是通过原生SQL和ResultTransformer映射时,却总是出错 String sql = "select currencies.code, attr1, ...
hibernate占位符的问题导致无法执行带变量的mysql sql语句
今天为研发改写了一个巨复杂的sql,因为保密原因就不贴出来了,自觉得意之时开发哥哥抱怨说只能在命令行执行,一旦放程序里就报错(hibernate包装过) 这里给一个简单的sql来做例子: select a.id ,a.d ,if(@od=a.d,@rank:=@rank+1,@rank:=1) num ,@od:=a.d from (select id ,d from number c ord
关于Hibernate配置及数据库访问过程中报错及解决办法
使用Hibernate对MySQL数据库中的表数据进行增删改查操作过程中出现的问题及解决办法:1. 缺少日志文件配置。解决办法:首先确认是否添加了log4j-**.jar和self4j-log4j****.jar包,然后在src下添加log4j.properties文件,其内容log4j.rootLogger = debug,stdout,D,E log4j.appender.stdout = o...
解决hibernate向mysql数据库传值中文乱码问题
解决hibernate向mysql数据库传值中文乱码问题最近在完成老师的大作业,是写一个考试系统,需要往数据库存值。 在最开始的时候遇到了一些小问题,想记录一下,并分享一下自己的解决方案。一、最开始是将数据库中的中文读取到jsp页面中,乱码!在查询了很多大家分享的方法后,做了修改 这样解决了从数据库到jsp页面的乱码问题。二、然后本以为事情完美解决了,又出现新的问题,从jsp页面取到的数据,在
用IDEA第一次配置Hibernate出现的com.mysql.jdbc.Driver红字问题及无法利用映射自动生成表的问题
一、关键在hibernate.cfg.xml的配置中出现如下问题解决方法:将驱动JAR包手动添加到module的dependences依赖中或者添加到Libraries中File—>project structure—>ModulesFile—>project structure—>Libraries二、当在hibernate.cfg.xml的配置中设置<!-- 生成...
hibernate mysql 报错 简单问题
[code="java"]rnHibernate: update tb_news_radio set state='审核否决', shenhe_name='admin', shenhe_time=now() where id=135rn2012-02-05 12:31:08,984 [http-5000-1] ERROR org.hibernate.util.JDBCExceptionReporter - Data truncation: Data truncated for column 'shenhe_time' at row 1rnorg.hibernate.exception.DataException: could not execute update queryrn at org.hibernate.exception.SQLStateConverter.convert(SQLStateConverter.java:100)rn at org.hibernate.exception.JDBCExceptionHelper.convert(JDBCExceptionHelper.java:66)rn at org.hibernate.hql.ast.exec.BasicExecutor.execute(BasicExecutor.java:107)rn at org.hibernate.hql.ast.QueryTranslatorImpl.executeUpdate(QueryTranslatorImpl.java:419)rn at org.hibernate.engine.query.HQLQueryPlan.performExecuteUpdate(HQLQueryPlan.java:283)rn at org.hibernate.impl.SessionImpl.executeUpdate(SessionImpl.java:1168)rn at org.hibernate.impl.QueryImpl.executeUpdate(QueryImpl.java:117)rn at com.acec.house.service.admin.AdminManager.shipinPass(AdminManager.java:442)rn at com.acec.house.service.admin.AdminManager$$FastClassByCGLIB$$c5f9ca65.invoke()rn at net.sf.cglib.proxy.MethodProxy.invoke(MethodProxy.java:149)rn at org.springframework.aop.framework.Cglib2AopProxy$CglibMethodInvocation.invokeJoinpoint(Cglib2AopProxy.java:700)rn at org.springframework.aop.framework.ReflectiveMethodInvocation.proceed(ReflectiveMethodInvocation.java:149)rn at org.springframework.transaction.interceptor.TransactionInterceptor.invoke(TransactionInterceptor.java:106)rn at org.springframework.aop.framework.ReflectiveMethodInvocation.proceed(ReflectiveMethodInvocation.java:171)rn at org.springframework.aop.framework.Cglib2AopProxy$DynamicAdvisedInterceptor.intercept(Cglib2AopProxy.java:635)rn at com.acec.house.service.admin.AdminManager$$EnhancerByCGLIB$$2536b346.shipinPass()rn at com.acec.house.actions.admin.AdminAction.shipinPass(AdminAction.java:1002)rn at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)rn at sun.reflect.NativeMethodAccessorImpl.invoke(Unknown Source)rn at sun.reflect.DelegatingMethodAccessorImpl.invoke(Unknown Source)rn at java.lang.reflect.Method.invoke(Unknown Source)rn at com.opensymphony.xwork2.DefaultActionInvocation.invokeAction(DefaultActionInvocation.java:440)rn at com.opensymphony.xwork2.DefaultActionInvocation.invokeActionOnly(DefaultActionInvocation.java:279)rn at com.opensymphony.xwork2.DefaultActionInvocation.invoke(DefaultActionInvocation.java:242)rn at com.opensymphony.xwork2.interceptor.DefaultWorkflowInterceptor.doIntercept(DefaultWorkflowInterceptor.java:163)rn at com.opensymphony.xwork2.interceptor.MethodFilterInterceptor.intercept(MethodFilterInterceptor.java:87)rn at com.opensymphony.xwork2.DefaultActionInvocation.invoke(DefaultActionInvocation.java:236)rn at com.opensymphony.xwork2.validator.ValidationInterceptor.doIntercept(ValidationInterceptor.java:249)rn at org.apache.struts2.interceptor.validation.AnnotationValidationInterceptor.doIntercept(AnnotationValidationInterceptor.java:68)rn at com.opensymphony.xwork2.interceptor.MethodFilterInterceptor.intercept(MethodFilterInterceptor.java:87)rn at com.opensymphony.xwork2.DefaultActionInvocation.invoke(DefaultActionInvocation.java:236)rn at com.opensymphony.xwork2.interceptor.ConversionErrorInterceptor.intercept(ConversionErrorInterceptor.java:122)rn at com.opensymphony.xwork2.DefaultActionInvocation.invoke(DefaultActionInvocation.java:236)rn at com.opensymphony.xwork2.interceptor.ParametersInterceptor.doIntercept(ParametersInterceptor.java:195)rn at com.opensymphony.xwork2.interceptor.MethodFilterInterceptor.intercept(MethodFilterInterceptor.java:87)rn at com.opensymphony.xwork2.DefaultActionInvocation.invoke(DefaultActionInvocation.java:236)rn at com.opensymphony.xwork2.interceptor.ParametersInterceptor.doIntercept(ParametersInterceptor.java:195)rn at com.opensymphony.xwork2.interceptor.MethodFilterInterceptor.intercept(MethodFilterInterceptor.java:87)rn at com.opensymphony.xwork2.DefaultActionInvocation.invoke(DefaultActionInvocation.java:236)rn at com.opensymphony.xwork2.interceptor.StaticParametersInterceptor.intercept(StaticParametersInterceptor.java:148)rn at com.opensymphony.xwork2.DefaultActionInvocation.invoke(DefaultActionInvocation.java:236)rn at org.apache.struts2.interceptor.CheckboxInterceptor.intercept(CheckboxInterceptor.java:93)rn at com.opensymphony.xwork2.DefaultActionInvocation.invoke(DefaultActionInvocation.java:236)rn at org.apache.struts2.interceptor.FileUploadInterceptor.intercept(FileUploadInterceptor.java:235)rn at com.opensymphony.xwork2.DefaultActionInvocation.invoke(DefaultActionInvocation.java:236)rn at com.opensymphony.xwork2.interceptor.ModelDrivenInterceptor.intercept(ModelDrivenInterceptor.java:89)rn at com.opensymphony.xwork2.DefaultActionInvocation.invoke(DefaultActionInvocation.java:236)rn at com.opensymphony.xwork2.interceptor.ScopedModelDrivenInterceptor.intercept(ScopedModelDrivenInterceptor.java:128)rn at com.opensymphony.xwork2.DefaultActionInvocation.invoke(DefaultActionInvocation.java:236)rn at org.apache.struts2.interceptor.ProfilingActivationInterceptor.intercept(ProfilingActivationInterceptor.java:104)rn at com.opensymphony.xwork2.DefaultActionInvocation.invoke(DefaultActionInvocation.java:236)rn at org.apache.struts2.interceptor.debugging.DebuggingInterceptor.intercept(DebuggingInterceptor.java:267)rn at com.opensymphony.xwork2.DefaultActionInvocation.invoke(DefaultActionInvocation.java:236)rn at com.opensymphony.xwork2.interceptor.ChainingInterceptor.intercept(ChainingInterceptor.java:126)rn at com.opensymphony.xwork2.DefaultActionInvocation.invoke(DefaultActionInvocation.java:236)rn at com.opensymphony.xwork2.interceptor.PrepareInterceptor.doIntercept(PrepareInterceptor.java:138)rn at com.opensymphony.xwork2.interceptor.MethodFilterInterceptor.intercept(MethodFilterInterceptor.java:87)rn at com.opensymphony.xwork2.DefaultActionInvocation.invoke(DefaultActionInvocation.java:236)rn at com.opensymphony.xwork2.interceptor.I18nInterceptor.intercept(I18nInterceptor.java:148)rn at com.opensymphony.xwork2.DefaultActionInvocation.invoke(DefaultActionInvocation.java:236)rn at org.apache.struts2.interceptor.ServletConfigInterceptor.intercept(ServletConfigInterceptor.java:164)rn at com.opensymphony.xwork2.DefaultActionInvocation.invoke(DefaultActionInvocation.java:236)rn at com.opensymphony.xwork2.interceptor.AliasInterceptor.intercept(AliasInterceptor.java:128)rn at com.opensymphony.xwork2.DefaultActionInvocation.invoke(DefaultActionInvocation.java:236)rn at com.opensymphony.xwork2.interceptor.ExceptionMappingInterceptor.intercept(ExceptionMappingInterceptor.java:176)rn at com.opensymphony.xwork2.DefaultActionInvocation.invoke(DefaultActionInvocation.java:236)rn at org.apache.struts2.impl.StrutsActionProxy.execute(StrutsActionProxy.java:52)rn at org.apache.struts2.dispatcher.Dispatcher.serviceAction(Dispatcher.java:468)rn at org.apache.struts2.dispatcher.ng.ExecuteOperations.executeAction(ExecuteOperations.java:77)rn at org.apache.struts2.dispatcher.ng.filter.StrutsPrepareAndExecuteFilter.doFilter(StrutsPrepareAndExecuteFilter.java:76)rn at org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:235)rn at org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:206)rn at org.springframework.orm.hibernate3.support.OpenSessionInViewFilter.doFilterInternal(OpenSessionInViewFilter.java:198)rn at org.springframework.web.filter.OncePerRequestFilter.doFilter(OncePerRequestFilter.java:76)rn at org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:235)rn at org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:206)rn at org.springframework.web.filter.CharacterEncodingFilter.doFilterInternal(CharacterEncodingFilter.java:96)rn at org.springframework.web.filter.OncePerRequestFilter.doFilter(OncePerRequestFilter.java:76)rn at org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:235)rn at org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:206)rn at org.apache.catalina.core.StandardWrapperValve.invoke(StandardWrapperValve.java:233)rn at org.apache.catalina.core.StandardContextValve.invoke(StandardContextValve.java:191)rn at org.apache.catalina.core.StandardHostValve.invoke(StandardHostValve.java:128)rn at org.apache.catalina.valves.ErrorReportValve.invoke(ErrorReportValve.java:102)rn at org.apache.catalina.core.StandardEngineValve.invoke(StandardEngineValve.java:109)rn at org.apache.catalina.connector.CoyoteAdapter.service(CoyoteAdapter.java:286)rn at org.apache.coyote.http11.Http11Processor.process(Http11Processor.java:845)rn at org.apache.coyote.http11.Http11Protocol$Http11ConnectionHandler.process(Http11Protocol.java:583)rn at org.apache.tomcat.util.net.JIoEndpoint$Worker.run(JIoEndpoint.java:447)rn at java.lang.Thread.run(Unknown Source)rnCaused by: com.mysql.jdbc.MysqlDataTruncation: Data truncation: Data truncated for column 'shenhe_time' at row 1rn at com.mysql.jdbc.SQLError.convertShowWarningsToSQLWarnings(SQLError.java:717)rn at com.mysql.jdbc.MysqlIO.scanForAndThrowDataTruncation(MysqlIO.java:3031)rn at com.mysql.jdbc.ServerPreparedStatement.serverExecute(ServerPreparedStatement.java:1241)rn at com.mysql.jdbc.ServerPreparedStatement.executeInternal(ServerPreparedStatement.java:685)rn at com.mysql.jdbc.PreparedStatement.executeUpdate(PreparedStatement.java:1400)rn at com.mysql.jdbc.PreparedStatement.executeUpdate(PreparedStatement.java:1314)rn at com.mysql.jdbc.PreparedStatement.executeUpdate(PreparedStatement.java:1299)rn at org.apache.commons.dbcp.DelegatingPreparedStatement.executeUpdate(DelegatingPreparedStatement.java:102)rn at org.apache.commons.dbcp.DelegatingPreparedStatement.executeUpdate(DelegatingPreparedStatement.java:102)rn at org.hibernate.hql.ast.exec.BasicExecutor.execute(BasicExecutor.java:98)rn ... 87 morernrn报这个错。我在数据库直接执行sql语句可以执行。rn public void shipinPass(Integer id, String pass, String userName) rn if(pass.equals("true"))rn manager.createQuery("update NewsRadioEO set state='审核通过',shenheName='"+userName+"',shenheTime=now() where id="+id).executeUpdate();rn elsern manager.createQuery("update NewsRadioEO set state='审核否决',shenheName='"+userName+"',shenheTime=now() where id="+id).executeUpdate();rn rn这样却不行了,我把shenheTime=now() 改成shenheTime='2012-05-05'却可以执行rn求指导rn[/code]
mysql字段有默认值,Hibernate插入为空时报错的解决方法
当数据库字段有默认值,比如create_time,默认值为当前时间,在对象的属性列表应该改为: @Column(name = "create_time",insertable = false, updatable = false) private Timestamp createTime; 否则会报错 : DataIntegrityViolationException ...
关于hibernate在处理oracle序列的时候遇到的一些问题分析
现象与该文类似:http://www.cnblogs.com/fangwenyu/archive/2011/08/01/2123929.html   上文的解释没有问题 DBSequence*allocationSize<= IDs < (DBSequence+1)*allocationSize 只有当id到达下个序列值*allocationSize时,序列值才会自增1。 ...
Hibernate开发环境的简单搭建及常见错误(一)
“两个蝴蝶飞”特别喜欢"java1234知识分享网"小峰的实用主义,所以本文及其系列文章均是采用实用主义,从项目和代码的角度去分析。由于本人经验有限,嘴皮子不溜,所以学术性,概念性,底层性的知识点暂时不做介绍。文章中有错误之处,欢迎拍砖和指点。特别感谢"java1234知识分享网"和"黑马程序员官网",所有的资料大部分是两者提供,为了方便书写,故不一一指名出处,请谅解,非常抱歉。 上一章简...
Hibernate和Mysql5.7生成表时报错
Hibernate第一次运行时报错:You have an error in your SQL syntax; check the manual that corresponds to your MySQL server version for the right syntax to use near 'type=MyISAM' at line 1。 根据异常可以知道应该是MySQL的版
hibernate主键冲突问题
“increment” 主键按数值顺序递增。此方式的实现机制为在当前应用实例中维持一个变量,以保存着当前的最大值,之后每次需要生成主键的时候将此值加1作为主键。这种方式可能产生的问题是:不能在集群下使用。
hibernate连接数据库错误总结
1.could not parse configuration:hibernate.cfg.xml <!--高版本hibernate的hibernate.cfg.xml文件 --> <!DOCTYPE hibernate-configuration PUBLIC "-//Hibernate/Hibernate Configuration DTD 3.0//...
hibernate 中第一次IDEA配置时出现com.mysql.Driver无法识别
一、将数据库驱动包,就是...bin.jar包添加到modules和librares中二、将hibernate得配置文件hibernate.cfg.xml中的dialect选择为<property name="hibernate.dialect">org.hibernate.dialect.MySQL5Dialect</property>...
Hibernate | Spring JPA | MySQL 使用过程遇到的一些问题
1. 使用过程 2. 背景 3. 遇到问题 3.1 不指定Hibernate数据库方言,默认SQL生成方式 3.2 抛出异常Hibernate加入了@Transactional事务不会回滚 3.3 Hibernate使用Spring Test测试加入了@Transactional事务无论如何数据库插入不成功 3.4 Hibernate在使用MyISAM引擎也可以回滚? 3.5 Hibernat...
Hibernate中text字段诡异出错
Hibernate中text字段诡异出错 描述:最初的sql语句如下: [code="sql"] select a.game_id,ifnull(cid,0) as cid,ifnull(fullname,'') as title,format_name,file_size*1024 as size, ifnull(c.name,'') as mobileBrand,ifnull(d.s...
Hibernate&MySQL——Group是关键字,在使用Hibernate时不能将其作为表名
在写程序时,由于需要用到“分组”类,故随手写了Group作为类名(坑!)。在之后使用Hibernate自动建表时,报错:Caused by: org.hibernate.tool.schema.spi.SchemaManagementException: Unable to execute schema management to JDBC target [create table Group (i
关于MySQL版本与HIbernate版本不匹配的问题,注意事项!!
关于MySQL版本问题注意事项MySQL5InnoDBDialect   报错信息error:You have an error in your SQL syntax; check the manual that corresponds to your MySQL server version for the right syntax to use near 'type=InnoDB' at
使用hibernate过程中,遇到的一些sql报错
          现在进入了一家新公司,已经快2个月了。公司是做电子政务的,产品已经很成熟了。现在每天的工作就是针对各个项目的产品,完成JIRA上分配来的各种任务,有开发任务、bug修复、需求改进等。现在已经很熟悉项目的业务和架构了,但还是遇到各种各样的问题,现在尽量把遇到的问题及解决方式记录下,在点滴积累中成长。       1、could not extract ResultSet,这个错误...
HIBERNATE 的乐观锁@VERSION和 MYSQL 的两个小问题
MySQL的设计者一直没有支持精度到毫秒或者纳秒的Timestamp类型,过去一直只能支持到秒。这虽然不太方便但是也凑合着能用,比如我通过程序代码插入long int也可以。但是Hibernate的实体如果用了@Version在MySQL一个时间字段上做乐观锁,就有问题了。Hibernate比较实体对象是否改变过,是根据@version字段的值,由于MySQL的DATETIME类型不能包含毫秒,纳
如何解决由hibernate和mysql的连接问题:
环境:tomcat5.0.28,JDK1.4.2,spring1.1.4,hibernate2.1.7,webwork2.1.7,linux操作系统 先将编译好的文件打包成war文件,然后上传到远程linux服务器.放到tomcat/webapps/目录下.关闭tomcat服务器. [root@localhost bin]# ./catalina.sh stop Using CATALINA...
Hibernate 原生sql 报错 因为text类型报 错误
======================== public class MySQL5DialectExtends extends MySQLDialect { public MySQL5DialectExtends() { super(); registerColumnType(Types.LONGVARCHAR, 65535, "text"); } } ======
Hibernate4和MySQL5.5自动创建表失败问题解决方法
今天初学Hibernate4,了解了使用Hibernate的过程。大体分为4个步骤: ①创建hibernate.cfg.xml文件 ②创建持久化对象 ③创建*.hbm.xml映射文件 ④编写hibernate相应代码 在第四步中,进行了单元测试,测试预期结果是hibernate自动帮助在数据库中创建数据表,结果JUnit单元测试没有问题,在控制台打印了创建数据表的SQL语句,但在数据库中...
hibernate不支持注解mysql的text类型
1.写一个类import java.sql.Types; import org.hibernate.Hibernate; import org.hibernate.dialect.MySQL5InnoDBDialect; //此处继承的是Hibernate MySql方言类,视不同开发情况而定 public class MySQLDialect extends MySQL5InnoDBDialec...
MySQL5.6.16数据库中type=MyISAM错误的解决办法
对于数据库,我完全是一个新手。因为平时工作基本不与数据库打交道,所以对于数据库的认识也就基本停留在了念书那时候很浅的概念了。        最近在看《细说PHP》这本书,在学习php的过程中也会遇到mysql的一些问题。今天照着书本创建表的时候,除了一些问题,总是提示出现一些问题。在解决了基本的拼写错误后,在“type=MyISAM DEFAULT CHARACTER SET utf8 COLL
Hibernate数据库方言选择问题
今天准备使用Hibernate配置Oracle数据库进行分页查询,在配置数据库方言的过程中遇到了问题,我本机安装的Oracle数据库版本是11.2.0.1.0,也就是11g版本,但是选择对应的版本数据库方言时,很郁闷,竟然没有对应的方言,如下所示: 可以清楚的看到Hibernate提供的Oracle数据库方言,就是没有对应的11g版本,想了想配置MySQL数据库的时候配置的是MySQLD
Hibernate的分页(基于数据库中分页)MySQL
Hibernate的分页,基于数据库的分页 下面是获取总共页面的totalCount,用到了HQL的拼接,用到了removeSelect()获得从From开始语句,并对Order by 语句进行了拼接成sql语句select count(*) from  user   Integer i = (Integer) this.getHibernateTemplate().find("select
关于hibernate做添加主键自增长数据保存失败的问题
本人做User表的增删改查 在添加方法的时候,由于User表的UserId是以自增长的方式进行添加的,所以在用hibernate写方法的时候,它会自动增加UserId的值,且给它赋值为0,然后报错 ERROR: 当 IDENTITY_INSERT 设置为 OFF 时,不能为表 ‘User’ 中的标识列插入显式值。 写的service方法什么的并没有添加UserId的步骤 //添加user @...
MySQL之—— 使用Hibernate连接MySQL数据库,MySQL连接超时断开的问题
最近让人头疼的一个问题,就是服务器在不确定的时间点会出现关于数据库连接的Exception,大致的Exception如下: org.hibernate.util.JDBCExceptionReporter - SQL Error:0, SQLState: 08S01 org.hibernate.util.JDBCExceptionReporter - The last packet succes
Hibernate MySQL方言配置遇到的坑
环境 hibernate5.2.17、MySQL5.5,采用JPA注解配置 1. The First 配置文件:peresistence.xml //...其它略... <property name="hibernate.dialect" value="org.hibernate.dialect.MySQLDialect"/> <property name="hiber...
mysql8.0配置serverTimezone,否则时区报错
jdbc:mysql://localhost:3306/ssm?serverTimezone=GMT%2B8&useSSL=false 在xml和class中“&是读不出的,正确写法将“&”转义“&” 但是如果使用properties文件来配置就不能使用转义,否则解析错误 jdbc:mysql://localhost:3306/ssm?serverTime...
解决hibernate表字段名与数据库关键字冲突
由于backup在sqlserver2000中是关键字。而我的表中却有一字段用的就是‘backup’,为了尽量不改动表,只好在hibernate里面想办法。在hibernate对应的映射配置文件中,找到该表字段的映射,在对应的字段名变成:[字段名]即可。如: Xml代码 <property name="backup" type="java.lang.String"&...
MySql使用Hibernate的异常的总结
1.把mysql的关键字interval ,time当做了字段描述而引起的。 2.和数据库连接经常断开,Hibernate: Communication link failure: java.io.IOException I recently launched a new site based on Struts, Hibernate and MySQL and immediately
解决hibernate报错:no-session的问题
问题1:因为没有将web.xml中的openSessionInViewFilter这样配置导致的问题,可以这样去配置,即可解决问题。问题2:在我一次项目当中,我已经这样配置了,但是仍然出现no-session的情况,这种情况下的解决方案是,我们要懒加载的bean是不是在加载这个view之前就已经装载到了http session当中的问题,我的解决方案是在取这样一个bean之前重新从数据库读取一次即...
hibernate学习笔记5---实体类或属性名与数据库关键字冲突、hql命名参数、hql实现通用分页
一、实体类或属性名与数据库关键字冲突问题 1、实体类名与数据库中的关键字冲突 比如:实体表User与oracle中的系统表冲突 解决方式1:在xml中添加table属性,指定表名,使其不与name默认相等 <!DOCTYPE hibernate-mapping PUBLIC "-//Hibernate/Hibernate Mapping DTD 3.0//EN"
hibernate查询结果转为实体类 数组越界报错
hibernate查询结果转为实体类 数组越界报错 String index out of range: 0
文章热词 机器学习教程 Objective-C培训 交互设计视频教程 颜色模型 设计制作学习
相关热词 mysql关联查询两次本表 native底部 react extjs glyph 图标 简单网页制作视频 简单网页制作视频教程