could not execute native bulk manipulation query

报错

 org.hibernate.exception.SQLGrammarException: could not execute native bulk manipulation query

atorg.hibernate.exception.SQLStateConverter.convert(SQLStateConverter.java:92)

atorg.hibernate.exception.JDBCExceptionHelper.convert(JDBCExceptionHelper.java:66)

atorg.hibernate.engine.query.NativeSQLQueryPlan.performExecuteUpdate(NativeSQLQueryPlan.java:219)

atorg.hibernate.impl.SessionImpl.executeNativeUpdate(SessionImpl.java:1310)

atorg.hibernate.impl.SQLQueryImpl.executeUpdate(SQLQueryImpl.java:396)

atssh.dao.impl.DiskDAOImpl.updateFileHit(DiskDAOImpl.java:162)

atssh.dao.impl.DiskDAOImplTest.testUpdateFileHit(DiskDAOImplTest.java:105)

atsun.reflect.NativeMethodAccessorImpl.invoke0(NativeMethod)

atsun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:39)

atsun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:25)

atjava.lang.reflect.Method.invoke(Method.java:597)

atorg.junit.runners.model.FrameworkMethod$1.runReflectiveCall(FrameworkMethod.java:44)

atorg.junit.internal.runners.model.ReflectiveCallable.run(ReflectiveCallable.java:15)

atorg.junit.runners.model.FrameworkMethod.invokeExplosively(FrameworkMethod.java:41)

atorg.junit.internal.runners.statements.InvokeMethod.evaluate(InvokeMethod.java:20)

atorg.junit.runners.BlockJUnit4ClassRunner.runNotIgnored(BlockJUnit4ClassRunner.java:79)

atorg.junit.runners.BlockJUnit4ClassRunner.runChild(BlockJUnit4ClassRunner.java:71)

atorg.junit.runners.BlockJUnit4ClassRunner.runChild(BlockJUnit4ClassRunner.java:49)

atorg.junit.runners.ParentRunner$3.run(ParentRunner.java:193)

atorg.junit.runners.ParentRunner$1.schedule(ParentRunner.java:52)

atorg.junit.runners.ParentRunner.runChildren(ParentRunner.java:191)

atorg.junit.runners.ParentRunner.access$000(ParentRunner.java:42)

atorg.junit.runners.ParentRunner$2.evaluate(ParentRunner.java:184)

atorg.junit.internal.runners.statements.RunBefores.evaluate(RunBefores.java:28)

atorg.junit.internal.runners.statements.RunAfters.evaluate(RunAfters.java:31)

atorg.junit.runners.ParentRunner.run(ParentRunner.java:236)

atorg.eclipse.jdt.internal.junit4.runner.JUnit4TestReference.run(JUnit4TestReference.java:46)

atorg.eclipse.jdt.internal.junit.runner.TestExecution.run(TestExecution.java:38)

atorg.eclipse.jdt.internal.junit.runner.RemoteTestRunner.runTests(RemoteTestRunner.java:467)

atorg.eclipse.jdt.internal.junit.runner.RemoteTestRunner.runTests(RemoteTestRunner.java:683)

atorg.eclipse.jdt.internal.junit.runner.RemoteTestRunner.run(RemoteTestRunner.java:390)

atorg.eclipse.jdt.internal.junit.runner.RemoteTestRunner.main(RemoteTestRunner.java:197)

Causedby:com.mysql.jdbc.exceptions.jdbc4.MySQLSyntaxErrorException:Unknowncolumn'hit'in'fieldlist'

atsun.reflect.NativeConstructorAccessorImpl.newInstance0(NativeMethod)

atsun.reflect.NativeConstructorAccessorImpl.newInstance(NativeConstructorAccessorImpl.java:39)

atsun.reflect.DelegatingConstructorAccessorImpl.newInstance(DelegatingConstructorAccessorImpl.java:27)

atjava.lang.reflect.Constructor.newInstance(Constructor.java:513)

atcom.mysql.jdbc.Util.handleNewInstance(Util.java:409)

atcom.mysql.jdbc.Util.getInstance(Util.java:384)

atcom.mysql.jdbc.SQLError.createSQLException(SQLError.java:1054)

atcom.mysql.jdbc.MysqlIO.checkErrorPacket(MysqlIO.java:3566)

atcom.mysql.jdbc.MysqlIO.checkErrorPacket(MysqlIO.java:3498)

atcom.mysql.jdbc.MysqlIO.sendCommand(MysqlIO.java:1959)

atcom.mysql.jdbc.MysqlIO.sqlQueryDirect(MysqlIO.java:2113)

atcom.mysql.jdbc.ConnectionImpl.execSQL(ConnectionImpl.java:2568)

atcom.mysql.jdbc.PreparedStatement.executeInternal(PreparedStatement.java:2113)

atcom.mysql.jdbc.PreparedStatement.executeUpdate(PreparedStatement.java:2409)

atcom.mysql.jdbc.PreparedStatement.executeUpdate(PreparedStatement.java:2327)

atcom.mysql.jdbc.PreparedStatement.executeUpdate(PreparedStatement.java:2312)

atcom.mchange.v2.c3p0.impl.NewProxyPreparedStatement.executeUpdate(NewProxyPreparedStatement.java:105)

atorg.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,改表名的同时别忘了改列名,而不是用属性名...

解决

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

相关推荐