This week's book giveaway is in the Java in General forum.
We're giving away four copies of Think Java: How to Think Like a Computer Scientist and have Allen B. Downey & Chris Mayfield on-line!
See this thread for details.
Win a copy of Think Java: How to Think Like a Computer Scientist this week in the Java in General forum!
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic

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

 
Deepaks Deshpande
Ranch Hand
Posts: 114
Eclipse IDE Hibernate 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.
 
Bill Gorder
Bartender
Posts: 1682
7
Android IntelliJ IDE Linux Mac OS X Spring
  • 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
Eclipse IDE Hibernate 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 IntelliJ IDE Linux Mac OS X Spring
  • 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
Eclipse IDE Hibernate 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.
 
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic