• Post Reply Bookmark Topic Watch Topic
  • New Topic
programming forums Java Mobile Certification Databases Caching Books Engineering Micro Controllers OS Languages Paradigms IDEs Build Tools Frameworks Application Servers Open Source This Site Careers Other all forums
this forum made possible by our volunteer staff, including ...
Marshals:
  • Campbell Ritchie
  • Liutauras Vilda
  • Tim Cooke
  • Jeanne Boyarsky
  • Bear Bibeault
Sheriffs:
  • Knute Snortum
  • paul wheaton
  • Devaka Cooray
Saloon Keepers:
  • Tim Moores
  • Stephan van Hulst
  • Ron McLeod
  • Piet Souris
  • Ganesh Patekar
Bartenders:
  • Tim Holloway
  • Carey Brown
  • salvin francis

Request processing failed; nested exception is org.hibernate.exception.SQLGrammarException

 
Ranch Hand
Posts: 114
Hibernate Eclipse IDE Spring
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Hello,
I am using Spring, Hibernate and MySQL for my project. I have configured hibernate in spring using the AnnotationSessionFactoryBean as shown below


My hibernate.cfg.xml file is as follows



My Model calss is as follows:

My DAO and DAO impl class is as follows

The DAO Impl class is:

I am getting the following error and i am not able to make out what the problem is.


Please help.
Thank you.
 
Bartender
Posts: 1682
7
Android Mac OS X IntelliJ IDE Spring Linux
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Well it says your table does not exist. Do you see the log statements printing out that your table is being created?

If your schema is already existing and I am imagining it is you can try using:



Its possible create cannot add the table to an existing schema but I can't remember.

The other thing you could try is defining your schema explicitly on your table:



If you do that btw you don't need to specify the schema in your connection details (although I don't think it hurts if you do)

Good luck,
 
Deepaks Deshpande
Ranch Hand
Posts: 114
Hibernate Eclipse IDE Spring
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Dear Bill,
The problem was resolved. It was a silly and a stupid mistake. The Id field in my Entity class was of type String and it also has the @GeneratedValue annotation. So it is quite obvious that we can't auto increment a field with String datatype. It can only be done on the int field.
Thank you
 
Bill Gorder
Bartender
Posts: 1682
7
Android Mac OS X IntelliJ IDE Spring Linux
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Glad you got it figured out! I did not even look that close at your mappings since the error complained of a table not existing.. I am sure the cause of that was further up your stack trace in the table generation output
 
Deepaks Deshpande
Ranch Hand
Posts: 114
Hibernate Eclipse IDE Spring
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Yes Bill, it was further up the stack where no one will normally look at with such an error message. Thanks though for youy help.
Cheers
Deepak.
 
What are your superhero powers? Go ahead and try them on this tiny ad:
Java file APIs (DOC, XLS, PDF, and many more)
https://products.aspose.com/total/java
  • Post Reply Bookmark Topic Watch Topic
  • New Topic
Boost this thread!