`
gary0416
  • 浏览: 330921 次
  • 性别: Icon_minigender_1
  • 来自: 北京
社区版块
存档分类
最新评论

could not execute native bulk manipulation query

阅读更多

报错

 org.hibernate.exception.SQLGrammarException: could not execute native bulk manipulation query
 at org.hibernate.exception.SQLStateConverter.convert(SQLStateConverter.java:92)
 at org.hibernate.exception.JDBCExceptionHelper.convert(JDBCExceptionHelper.java:66)
 at org.hibernate.engine.query.NativeSQLQueryPlan.performExecuteUpdate(NativeSQLQueryPlan.java:219)
 at org.hibernate.impl.SessionImpl.executeNativeUpdate(SessionImpl.java:1310)
 at org.hibernate.impl.SQLQueryImpl.executeUpdate(SQLQueryImpl.java:396)
 at ssh.dao.impl.DiskDAOImpl.updateFileHit(DiskDAOImpl.java:162)
 at ssh.dao.impl.DiskDAOImplTest.testUpdateFileHit(DiskDAOImplTest.java:105)
 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 org.junit.runners.model.FrameworkMethod$1.runReflectiveCall(FrameworkMethod.java:44)
 at org.junit.internal.runners.model.ReflectiveCallable.run(ReflectiveCallable.java:15)
 at org.junit.runners.model.FrameworkMethod.invokeExplosively(FrameworkMethod.java:41)
 at org.junit.internal.runners.statements.InvokeMethod.evaluate(InvokeMethod.java:20)
 at org.junit.runners.BlockJUnit4ClassRunner.runNotIgnored(BlockJUnit4ClassRunner.java:79)
 at org.junit.runners.BlockJUnit4ClassRunner.runChild(BlockJUnit4ClassRunner.java:71)
 at org.junit.runners.BlockJUnit4ClassRunner.runChild(BlockJUnit4ClassRunner.java:49)
 at org.junit.runners.ParentRunner$3.run(ParentRunner.java:193)
 at org.junit.runners.ParentRunner$1.schedule(ParentRunner.java:52)
 at org.junit.runners.ParentRunner.runChildren(ParentRunner.java:191)
 at org.junit.runners.ParentRunner.access$000(ParentRunner.java:42)
 at org.junit.runners.ParentRunner$2.evaluate(ParentRunner.java:184)
 at org.junit.internal.runners.statements.RunBefores.evaluate(RunBefores.java:28)
 at org.junit.internal.runners.statements.RunAfters.evaluate(RunAfters.java:31)
 at org.junit.runners.ParentRunner.run(ParentRunner.java:236)
 at org.eclipse.jdt.internal.junit4.runner.JUnit4TestReference.run(JUnit4TestReference.java:46)
 at org.eclipse.jdt.internal.junit.runner.TestExecution.run(TestExecution.java:38)
 at org.eclipse.jdt.internal.junit.runner.RemoteTestRunner.runTests(RemoteTestRunner.java:467)
 at org.eclipse.jdt.internal.junit.runner.RemoteTestRunner.runTests(RemoteTestRunner.java:683)
 at org.eclipse.jdt.internal.junit.runner.RemoteTestRunner.run(RemoteTestRunner.java:390)
 at org.eclipse.jdt.internal.junit.runner.RemoteTestRunner.main(RemoteTestRunner.java:197)
Caused by: com.mysql.jdbc.exceptions.jdbc4.MySQLSyntaxErrorException: Unknown column 'hit' in 'field list'
 at sun.reflect.NativeConstructorAccessorImpl.newInstance0(Native Method)
 at sun.reflect.NativeConstructorAccessorImpl.newInstance(NativeConstructorAccessorImpl.java:39)
 at sun.reflect.DelegatingConstructorAccessorImpl.newInstance(DelegatingConstructorAccessorImpl.java:27)
 at java.lang.reflect.Constructor.newInstance(Constructor.java:513)
 at com.mysql.jdbc.Util.handleNewInstance(Util.java:409)
 at com.mysql.jdbc.Util.getInstance(Util.java:384)
 at com.mysql.jdbc.SQLError.createSQLException(SQLError.java:1054)
 at com.mysql.jdbc.MysqlIO.checkErrorPacket(MysqlIO.java:3566)
 at com.mysql.jdbc.MysqlIO.checkErrorPacket(MysqlIO.java:3498)
 at com.mysql.jdbc.MysqlIO.sendCommand(MysqlIO.java:1959)
 at com.mysql.jdbc.MysqlIO.sqlQueryDirect(MysqlIO.java:2113)
 at com.mysql.jdbc.ConnectionImpl.execSQL(ConnectionImpl.java:2568)
 at com.mysql.jdbc.PreparedStatement.executeInternal(PreparedStatement.java:2113)
 at com.mysql.jdbc.PreparedStatement.executeUpdate(PreparedStatement.java:2409)
 at com.mysql.jdbc.PreparedStatement.executeUpdate(PreparedStatement.java:2327)
 at com.mysql.jdbc.PreparedStatement.executeUpdate(PreparedStatement.java:2312)
 at com.mchange.v2.c3p0.impl.NewProxyPreparedStatement.executeUpdate(NewProxyPreparedStatement.java:105)
 at org.hibernate.engine.query.NativeSQLQueryPlan.performExecuteUpdate(NativeSQLQueryPlan.java:210)
 ... 29 more

 

 

代码

@Override
	public void updateFileHit(String fileUrl){
		getHibernateSession().createSQLQuery("update test_netdisk set hit=hit+1 where fileURL=?").setParameter(0, fileUrl).executeUpdate();
	}

 

 

原因

 

不能在原生SQL中写HQL,改表名的同时别忘了改列名,而不是用属性名...

 

 

解决

...不说了...掩面泪奔...留个记号 

分享到:
评论
1 楼 chxiaowu 2012-05-29  
只要SQL语句写的不对都会报这错误的。

相关推荐

Global site tag (gtag.js) - Google Analytics