日期:2014-05-17  浏览次数:20718 次

在线等,hibernate更新对象的属性时乱码,无法插入mysql,很简单的问题编码问题 我的都设的UTF-8啊怎么办?
错误信息:
Hibernate: select movie0_.id as id0_0_, movie0_.daoyan as daoyan0_0_, movie0_.daymovie as daymovie0_0_, movie0_.describe as describe0_0_, movie0_.diqu as diqu0_0_, movie0_.endTime as endTime0_0_, movie0_.image as image0_0_, movie0_.leixing as leixing0_0_, movie0_.name as name0_0_, movie0_.number as number0_0_, movie0_.price as price0_0_, movie0_.startTime as startTime0_0_, movie0_.zhuyan as zhuyan0_0_ from Movie movie0_ where movie0_.id=?
Hibernate: select movie0_.id as id0_0_, movie0_.daoyan as daoyan0_0_, movie0_.daymovie as daymovie0_0_, movie0_.describe as describe0_0_, movie0_.diqu as diqu0_0_, movie0_.endTime as endTime0_0_, movie0_.image as image0_0_, movie0_.leixing as leixing0_0_, movie0_.name as name0_0_, movie0_.number as number0_0_, movie0_.price as price0_0_, movie0_.startTime as startTime0_0_, movie0_.zhuyan as zhuyan0_0_ from Movie movie0_ where movie0_.id=?
你好
Hibernate: update Movie set daoyan=?, daymovie=?, describe=?, diqu=?, endTime=?, image=?, leixing=?, name=?, number=?, price=?, startTime=?, zhuyan=? where id=?
14:18:18,304  WARN org.hibernate.util.JDBCExceptionReporter:100 - SQL Error: 1064, SQLState: 42000
14:18:18,313 ERROR org.hibernate.util.JDBCExceptionReporter:101 - 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 'describe='浣犲ソ', diqu='鍐呭湴', endTime='2013-03-18 11:22:59.0', image='images' at line 1
14:18:18,320 ERROR org.hibernate.event.def.AbstractFlushingEventListener:324 - Could not synchronize database state with session
org.hibernate.exception.SQLGrammarException: Could not execute JDBC batch update
at org.hibernate.exception.SQLStateConverter.convert(SQLStateConverter.java:90)
at org.hibernate.exception.JDBCExceptionHelper.convert(JDBCExceptionHelper.java:66)
at org.hibernate.jdbc.AbstractBatcher.executeBatch(AbstractBatcher.java:275)
at org.hibernate.engine.ActionQueue.executeActions(ActionQueue.java:266)
at org.hibernate.engine.ActionQueue.executeActions(ActionQueue.java:168)
at org.hibernate.event.def.AbstractFlushingEventListener.performExecutions(AbstractFlushingEventListener.java:321)
at org.hibernate.event.def.DefaultFlushEventListener.onFlush(DefaultFlushEventListener.java:50)
at org.hibernate.impl.SessionImpl.flush(SessionImpl.java:1028)
at org.springframework.orm.hibernate3.HibernateAccessor.flushIfNecessary(HibernateAccessor.java:390)

hibernatetemplate 调用的代码:

// TODO Auto-generated method stub
Movie movie=(Movie)ht.get(Movie.class, id);
int number=movie.getNumber();
number=number-1;
movie.se