1.今天在做hibernate的orm是,数据库主键为identity增长,在hibernate的生成策略也设为identity,然后就报了以下错误System Runtime Error:
Could not execute JDBC batch update; SQL [insert into beforehuaiyun (age, bname, cd, chanci, chanhou_address, echi, eji, end_yj, eqian, fare, fukejc, gangn, gaowei, gb, gxy, hbsag, hiv, jc_date, jgb, jhb, jiancrq, jiaotong, jsb, jutu, jx, kwy, meidu, nanchan, niaodanbai, niaodl, personid, ptaotai, qianm, qita, qitab, qyc, rengong, sb, shengao, sitai, sjixing, taici, tel, tizhong, tlb, whcd, xftz, xuehong, xuetang, xueya, xyb, xzb, ycq, yichuan, yinchan, yindao, yixuejianyi, yqcy, yyrq, yz, zaochan, z_cd, ziran, z_jsb, z_jx, z_qita, zuogu, z_whcd, z_yichuan, bid) values (?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?)]; constraint [null]; nested exception is org.hibernate.exception.ConstraintViolationException: Could not execute JDBC batch update
。。
Caused by: com.microsoft.jdbc.base.BaseBatchUpdateException: [Microsoft][SQLServer 2000 Driver for JDBC][SQLServer]当 IDENTITY_INSERT 设置为 OFF 时,不能为表 'beforehuaiyun' 中的标识列插入显式值。
at com.microsoft.jdbc.base.BasePreparedStatement.executeBatchEmulation(Unknown Source)
at com.microsoft.jdbc.base.BasePreparedStatement.executeBatch(Unknown Source)
at org.apache.commons.dbcp.DelegatingStatement.executeBatch(DelegatingStatement.java:294)
at org.hibernate.jdbc.BatchingBatcher.doExecuteBatch(BatchingBatcher.java:70)
at org.hibernate.jdbc.AbstractBatcher.executeBatch(AbstractBatcher.java:268)
... 90 more2.这个异常困扰了我两天,最后看了一些网上的资料,自己也想了想,最后把hibernate生成策略改为native,OK,完事大吉,高兴!希望我的心得对各位有用!