I am getting the following error when I tried to delete all records from a table
int rows = session.createQuery("delete from Region").executeUpdate();
The SQL generated does not work for Sybase 12. I ran the query generated by Hibernate in isql and got the following message.
delete from REGION region0
Msg 102, Level 15, State 1:
Server 'xxx', Line 1:
Incorrect syntax near 'region0'.
SQL generated should be
delete from REGION (without region0)
Hibernate version:
CVS, March 18, 2005
Full stack trace of any exception that occurs:
org.hibernate.exception.SQLGrammarException: could not execute update query
at org.hibernate.exception.SQLStateConverter.convert(SQLStateConverter.java:59)
at org.hibernate.exception.JDBCExceptionHelper.convert(JDBCExceptionHelper.java:43)
at org.hibernate.hql.ast.UpdateStatementExecutor.execute(UpdateStatementExecutor.java:76)
at org.hibernate.hql.ast.QueryTranslatorImpl.executeUpdate(QueryTranslatorImpl.java:294)
at org.hibernate.impl.SessionImpl.executeUpdate(SessionImpl.java:814)
at org.hibernate.impl.QueryImpl.executeUpdate(QueryImpl.java:89)
at mytest.fts.entity.RegionTest.testRegion(RegionTest.java:50)
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:324)
at junit.framework.TestCase.runTest(TestCase.java:154)
at junit.framework.TestCase.runBare(TestCase.java:127)
at junit.framework.TestResult$1.protect(TestResult.java:106)
at junit.framework.TestResult.runProtected(TestResult.java:124)
at junit.framework.TestResult.run(TestResult.java:109)
at junit.framework.TestCase.run(TestCase.java:118)
at junit.framework.TestSuite.runTest(TestSuite.java:208)
at junit.framework.TestSuite.run(TestSuite.java:203)
at org.eclipse.jdt.internal.junit.runner.RemoteTestRunner.runTests(RemoteTestRunner.java:421)
at org.eclipse.jdt.internal.junit.runner.RemoteTestRunner.run(RemoteTestRunner.java:305)
at org.eclipse.jdt.internal.junit.runner.RemoteTestRunner.main(RemoteTestRunner.java:186)
Caused by: com.sybase.jdbc2.jdbc.SybSQLException: Incorrect syntax near 'region0_'.
at com.sybase.jdbc2.tds.Tds.processEed(Tds.java:2636)
at com.sybase.jdbc2.tds.Tds.nextResult(Tds.java:1996)
at com.sybase.jdbc2.jdbc.ResultGetter.nextResult(ResultGetter.java:69)
at com.sybase.jdbc2.jdbc.SybStatement.nextResult(SybStatement.java:204)
at com.sybase.jdbc2.jdbc.SybStatement.nextResult(SybStatement.java:187)
at com.sybase.jdbc2.jdbc.SybStatement.updateLoop(SybStatement.java:1642)
at com.sybase.jdbc2.jdbc.SybStatement.executeUpdate(SybStatement.java:1625)
at com.sybase.jdbc2.jdbc.SybPreparedStatement.executeUpdate(SybPreparedStatement.java:91)
at org.hibernate.hql.ast.UpdateStatementExecutor.execute(UpdateStatementExecutor.java:67)
... 19 more
Name and version of the database you are using:
Sybase version 12.x
The generated SQL (show_sql=true):
delete from REGION region0
Debug level Hibernate log excerpt:
warn
|