-->
These old forums are deprecated now and set to read-only. We are waiting for you on our new forums!
More modern, Discourse-based and with GitHub/Google/Twitter authentication built-in.

All times are UTC - 5 hours [ DST ]



Forum locked This topic is locked, you cannot edit posts or make further replies.  [ 3 posts ] 
Author Message
 Post subject: TableGenerator: Problem with MS SQL Server using jTDS v1.25
PostPosted: Fri Mar 12, 2010 9:56 am 
Newbie

Joined: Sun Feb 15, 2009 8:24 am
Posts: 9
I am implementing the new TableGenerator on Microsoft SQL Server 2005 with jTDS driver version 1.2.5 latest one. But getting the following error. I need help from hibernate community.

18:50:17,910 ERROR TableGenerator:250 - could not read or init a hi value
java.sql.SQLException: Line 1: FOR UPDATE clause allowed only for DECLARE CURSOR.


Complete Log is below:

18:54:39,383 INFO SchemaExport:196 - schema export complete
18:54:39,398 DEBUG DriverManagerConnectionProvider:129 - returning connection to pool, pool size: 1
18:54:39,398 DEBUG SessionFactoryImpl:392 - Checking 0 named HQL queries
18:54:39,398 DEBUG SessionFactoryImpl:412 - Checking 0 named SQL queries
18:54:39,430 DEBUG SessionImpl:220 - opened session at timestamp: 12684020793
18:54:39,445 DEBUG DefaultSaveOrUpdateEventListener:158 - saving transient instance
18:54:39,445 DEBUG AbstractBatcher:556 - opening JDBC connection
18:54:39,445 DEBUG DriverManagerConnectionProvider:93 - total checked-out connections: 0
18:54:39,445 DEBUG DriverManagerConnectionProvider:99 - using pooled JDBC connection, pool size: 0
18:54:39,445 DEBUG SQL:222 - select next_val from hibernate_sequences tbl where tbl.sequence_name=? for update
18:54:39,461 ERROR TableGenerator:250 - could not read or init a hi value
java.sql.SQLException: Line 1: FOR UPDATE clause allowed only for DECLARE CURSOR.

at net.sourceforge.jtds.jdbc.SQLDiagnostic.addDiagnostic(SQLDiagnostic.java:368)
at net.sourceforge.jtds.jdbc.TdsCore.tdsErrorToken(TdsCore.java:2820)
at net.sourceforge.jtds.jdbc.TdsCore.nextToken(TdsCore.java:2258)
at net.sourceforge.jtds.jdbc.TdsCore.getMoreResults(TdsCore.java:632)
at net.sourceforge.jtds.jdbc.JtdsStatement.executeSQLQuery(JtdsStatement.java:477)
at net.sourceforge.jtds.jdbc.JtdsPreparedStatement.executeQuery(JtdsPreparedStatement.java:776)
at org.hibernate.id.enhanced.TableGenerator.doWorkInCurrentTransaction(TableGenerator.java:226)
at org.hibernate.engine.TransactionHelper$1Work.doWork(TransactionHelper.java:38)
at org.hibernate.engine.transaction.Isolater$JdbcDelegate.delegateWork(Isolater.java:187)
at org.hibernate.engine.transaction.Isolater.doIsolatedWork(Isolater.java:43)
at org.hibernate.engine.TransactionHelper.doWorkInNewTransaction(TransactionHelper.java:51)
at org.hibernate.id.enhanced.TableGenerator$1.getNextValue(TableGenerator.java:211)
at org.hibernate.id.enhanced.OptimizerFactory$PooledOptimizer.generate(OptimizerFactory.java:173)
at org.hibernate.id.enhanced.TableGenerator.generate(TableGenerator.java:208)
at org.hibernate.event.def.AbstractSaveEventListener.saveWithGeneratedId(AbstractSaveEventListener.java:99)
at org.hibernate.event.def.DefaultSaveOrUpdateEventListener.saveWithGeneratedOrRequestedId(DefaultSaveOrUpdateEventListener.java:187)
at org.hibernate.event.def.DefaultSaveEventListener.saveWithGeneratedOrRequestedId(DefaultSaveEventListener.java:33)
at org.hibernate.event.def.DefaultSaveOrUpdateEventListener.entityIsTransient(DefaultSaveOrUpdateEventListener.java:172)
at org.hibernate.event.def.DefaultSaveEventListener.performSaveOrUpdate(DefaultSaveEventListener.java:27)
at org.hibernate.event.def.DefaultSaveOrUpdateEventListener.onSaveOrUpdate(DefaultSaveOrUpdateEventListener.java:70)
at org.hibernate.impl.SessionImpl.fireSave(SessionImpl.java:535)
at org.hibernate.impl.SessionImpl.save(SessionImpl.java:523)
at org.hibernate.impl.SessionImpl.save(SessionImpl.java:519)
at com.netsol.domain.AppTest.testSequenceTableWithMySQL(AppTest.java:78)
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 junit.framework.TestCase.runTest(TestCase.java:164)
at junit.framework.TestCase.runBare(TestCase.java:130)
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:120)
at org.eclipse.jdt.internal.junit.runner.junit3.JUnit3TestReference.run(JUnit3TestReference.java:130)
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)
18:54:39,461 DEBUG JDBCExceptionReporter:69 - could not get or update next value [null]
java.sql.SQLException: Line 1: FOR UPDATE clause allowed only for DECLARE CURSOR.
at net.sourceforge.jtds.jdbc.SQLDiagnostic.addDiagnostic(SQLDiagnostic.java:368)
at net.sourceforge.jtds.jdbc.TdsCore.tdsErrorToken(TdsCore.java:2820)
at net.sourceforge.jtds.jdbc.TdsCore.nextToken(TdsCore.java:2258)
at net.sourceforge.jtds.jdbc.TdsCore.getMoreResults(TdsCore.java:632)
at net.sourceforge.jtds.jdbc.JtdsStatement.executeSQLQuery(JtdsStatement.java:477)
at net.sourceforge.jtds.jdbc.JtdsPreparedStatement.executeQuery(JtdsPreparedStatement.java:776)
at org.hibernate.id.enhanced.TableGenerator.doWorkInCurrentTransaction(TableGenerator.java:226)
at org.hibernate.engine.TransactionHelper$1Work.doWork(TransactionHelper.java:38)
at org.hibernate.engine.transaction.Isolater$JdbcDelegate.delegateWork(Isolater.java:187)
at org.hibernate.engine.transaction.Isolater.doIsolatedWork(Isolater.java:43)
at org.hibernate.engine.TransactionHelper.doWorkInNewTransaction(TransactionHelper.java:51)
at org.hibernate.id.enhanced.TableGenerator$1.getNextValue(TableGenerator.java:211)
at org.hibernate.id.enhanced.OptimizerFactory$PooledOptimizer.generate(OptimizerFactory.java:173)
at org.hibernate.id.enhanced.TableGenerator.generate(TableGenerator.java:208)
at org.hibernate.event.def.AbstractSaveEventListener.saveWithGeneratedId(AbstractSaveEventListener.java:99)
at org.hibernate.event.def.DefaultSaveOrUpdateEventListener.saveWithGeneratedOrRequestedId(DefaultSaveOrUpdateEventListener.java:187)
at org.hibernate.event.def.DefaultSaveEventListener.saveWithGeneratedOrRequestedId(DefaultSaveEventListener.java:33)
at org.hibernate.event.def.DefaultSaveOrUpdateEventListener.entityIsTransient(DefaultSaveOrUpdateEventListener.java:172)
at org.hibernate.event.def.DefaultSaveEventListener.performSaveOrUpdate(DefaultSaveEventListener.java:27)
at org.hibernate.event.def.DefaultSaveOrUpdateEventListener.onSaveOrUpdate(DefaultSaveOrUpdateEventListener.java:70)
at org.hibernate.impl.SessionImpl.fireSave(SessionImpl.java:535)
at org.hibernate.impl.SessionImpl.save(SessionImpl.java:523)
at org.hibernate.impl.SessionImpl.save(SessionImpl.java:519)
at com.netsol.domain.AppTest.testSequenceTableWithMySQL(AppTest.java:78)
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 junit.framework.TestCase.runTest(TestCase.java:164)
at junit.framework.TestCase.runBare(TestCase.java:130)
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:120)
at org.eclipse.jdt.internal.junit.runner.junit3.JUnit3TestReference.run(JUnit3TestReference.java:130)
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)
18:54:39,461 WARN JDBCExceptionReporter:77 - SQL Error: 1003, SQLState: S1000
18:54:39,461 ERROR JDBCExceptionReporter:78 - Line 1: FOR UPDATE clause allowed only for DECLARE CURSOR.
18:54:39,461 DEBUG AbstractBatcher:571 - closing JDBC connection (open PreparedStatements: 0, globally: 0) (open ResultSets: 0, globally: 0)
18:54:39,461 DEBUG DriverManagerConnectionProvider:129 - returning connection to pool, pool size: 1

_________________
Faisal Basra


Top
 Profile  
 
 Post subject: Re: TableGenerator: Problem with MS SQL Server using jTDS v1.25
PostPosted: Mon Mar 15, 2010 4:25 am 
Expert
Expert

Joined: Tue Jun 16, 2009 3:36 am
Posts: 990
I'm using TableGenerator too with jTDS driver version 1.2.5 , but I'm using Microsoft SQL Server 2008 and I don't have the problem.
It would be interesting to know if the exception comes from the JDBCdriver or directly from the database.
Did you already try with Microsofts JDBCDriver insted to jTDS?


Top
 Profile  
 
 Post subject: Re: TableGenerator: Problem with MS SQL Server using jTDS v1.25
PostPosted: Mon Mar 15, 2010 7:20 am 
Newbie

Joined: Sun Feb 15, 2009 8:24 am
Posts: 9
Thanks pb00067

The problem was with the Dialect. I just replace the org.hibernate.dialect.JDataStoreDialect with org.hibernate.dialect.SQLServerDialect ,remain same with jTDS driver and my problem gone away.

_________________
Faisal Basra


Top
 Profile  
 
Display posts from previous:  Sort by  
Forum locked This topic is locked, you cannot edit posts or make further replies.  [ 3 posts ] 

All times are UTC - 5 hours [ DST ]


You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum

Search for:
© Copyright 2014, Red Hat Inc. All rights reserved. JBoss and Hibernate are registered trademarks and servicemarks of Red Hat, Inc.