File APIs for Java Developers
Manipulate DOC, XLS, PPT, PDF and many others from your application.
http://aspose.com/file-tools
The moose likes Object Relational Mapping and the fly likes hibernate exception SQLGrammarException  could not fetch initial value for increment Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login
JavaRanch » Java Forums » Databases » Object Relational Mapping
Bookmark "hibernate exception SQLGrammarException  could not fetch initial value for increment" Watch "hibernate exception SQLGrammarException  could not fetch initial value for increment" New topic
Author

hibernate exception SQLGrammarException could not fetch initial value for increment

V Patil
Ranch Hand

Joined: Oct 04, 2008
Posts: 36
org.hibernate.exception.SQLGrammarException: could not fetch initial value for increment generator
this excepetion is shown in console
cannot increment the generator id.
I am getting this error when i am using Hibernate 3.0 and its working fine with Hibernate 2.0.
Please Help.
Talha Kabakus
Greenhorn

Joined: Feb 27, 2010
Posts: 23
same problem occurs to me too.. thanks for topic..
I hope that someone can help us.. I think we should do some changes in hbm.xml file.
Shinelin Samuel
Ranch Hand

Joined: Mar 01, 2010
Posts: 55
It could be a syntax problem with the SQL query which is built during the runtime.
Talha Kabakus
Greenhorn

Joined: Feb 27, 2010
Posts: 23
Shinelin Samuel wrote:It could be a syntax problem with the SQL query which is built during the runtime.

first, thank you for your reply.. do you know how can we correct it? I use HQL's session.save(Object o) method.
Shinelin Samuel
Ranch Hand

Joined: Mar 01, 2010
Posts: 55
Can you please send the full error trace and also the hbm.file
Talha Kabakus
Greenhorn

Joined: Feb 27, 2010
Posts: 23
Shinelin Samuel wrote:Can you please send the full error trace and also the hbm.file

of course, thanks for your interest.

hbm.xml file:

Full Error Trace:
Shinelin Samuel
Ranch Hand

Joined: Mar 01, 2010
Posts: 55
Caused by: java.sql.SQLException: ORA-00933: SQL command not properly ended


Seems like the SQL statement formed using generator increment class, has the issue,.

Have you turned on show-sql parameter in your hibernate config file, In such case I think it will log the SQL statement in your console.

Regards,
Shinelin
Talha Kabakus
Greenhorn

Joined: Feb 27, 2010
Posts: 23
Shinelin Samuel wrote:
Caused by: java.sql.SQLException: ORA-00933: SQL command not properly ended


Seems like the SQL statement formed using generator increment class, has the issue,.

Have you turned on show-sql parameter in your hibernate config file, In such case I think it will log the SQL statement in your console.

Regards,
Shinelin

OK, I added 'show-sql' parameter; but it gives exactly same exception report..
Wolf Lee
Greenhorn

Joined: Mar 09, 2010
Posts: 1
I got the same problem. From google I found this topic, but without solution.
but ,but finally
I solved it by removing the "username" and "password" in the config file of hibernate(hibernate.cfg.xml)
And I changed the generator type from "increment" to "identity".(My id type is "integer", not big-decimal, my db is derby)
this is my case, I think it may be helpful, so....
Not good English, sorry
 
I agree. Here's the link: http://aspose.com/file-tools
 
subject: hibernate exception SQLGrammarException could not fetch initial value for increment
 
Similar Threads
many-to-many Not this saving, please help me
cannot increment the generator id in HIbernate 3.0
Something wrong for hibernate!
Error - cannot increment the generator id
hibernate:problem with schema