日期:2014-05-20  浏览次数:20796 次

在Hibernate中不能添加一条中文,却能添加一条英文的诡异问题!
Hibernate: 
  /* insert cn.jbit.bid.entity.Bidding
  */ insert 
  into
  BIDS.BIDDING
  (ITEMNAME, CONTENT, UPTOTIMES, STATE, BNUMBER) 
  values
  (?, ?, ?, ?, ?)
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 org.hibernate.exception.JDBCExceptionHelper.convert(JDBCExceptionHelper.java:43)
at org.hibernate.jdbc.AbstractBatcher.executeBatch(AbstractBatcher.java:254)
at org.hibernate.engine.ActionQueue.executeActions(ActionQueue.java:266)
at org.hibernate.engine.ActionQueue.executeActions(ActionQueue.java:167)
at org.hibernate.event.def.AbstractFlushingEventListener.performExecutions(AbstractFlushingEventListener.java:298)
at org.hibernate.event.def.DefaultFlushEventListener.onFlush(DefaultFlushEventListener.java:27)
at org.hibernate.impl.SessionImpl.flush(SessionImpl.java:1001)
at org.hibernate.impl.SessionImpl.managedFlush(SessionImpl.java:339)
at org.hibernate.transaction.JDBCTransaction.commit(JDBCTransaction.java:106)
at cn.jbit.bid.test.BiddingTest.main(BiddingTest.java:40)
Caused by: java.sql.BatchUpdateException: ORA-01461: can bind a LONG value only for insert into a LONG column

at oracle.jdbc.driver.DatabaseError.throwBatchUpdateException(DatabaseError.java:367)
at oracle.jdbc.driver.OraclePreparedStatement.executeBatch(OraclePreparedStatement.java:8739)
at org.hibernate.jdbc.BatchingBatcher.doExecuteBatch(BatchingBatcher.java:48)
at org.hibernate.jdbc.AbstractBatcher.executeBatch(AbstractBatcher.java:247)
... 8 more
给为前辈们好,我是刚学习Hibernate的,我在向数据库插入一条数据的时候他就给我报这个错。我的主键是通过通过生成策略的assigned的属性。经过我的一番调试我发现在实体类中为String的属性为name的列不能添加中文 ,添加英文就可以成功的添加一条数据。所以想不出来是什么原因,希望前辈们指点!谢谢!

------解决方案--------------------
编码问题吧
------解决方案--------------------
Caused by: java.sql.BatchUpdateException: ORA-01461: can bind a LONG value only for insert into a LONG column

那个字段是Long,当然不能插字符串噜。。
------解决方案--------------------
探讨
Caused by: java.sql.BatchUpdateException: ORA-01461: can bind a LONG value only for insert into a LONG column

我的实体类中没有Long类型的字段,这个异常是由:org.hibernate.exception.GenericJDBCException: Could not execut……