0

When I am executing session.save(Object) Hibernate gives a many errors. I have posted this question on as many forums as possible

First error: com.mysql.jdbc.exceptions.jdbc4.MySQLSyntaxErrorException: Table 'entity.listOfcases' doesn't exist

Then I also see one more error:

check the manual that corresponds to your MySQL server version for the right syntax to use near 'type=InnoDB' at line 1

I have used "update" and "create" both in my hibernate mapping file but still the table does not get automatically created in the database.

<property name="hibernate.hbm2ddl.auto">create</property>
<property name="hibernate.hbm2ddl.auto">update</property>

Used both of them above.

Third error: "org.hibernate.exception.SQLGrammarException: could not fetch initial value for increment generator"

I have checked all my getter setters and all the POJO classes. Everything is fine. When I create the tables manually everything works just great, its just that when I delete those tables and try to auto-create them, it doesn't work.

2
  • Have you tried create on its own? If you manually made the schema did you try create-drop then switching to create? Commented Nov 21, 2013 at 1:10
  • But neither got executed. And the one that I created manually was in database named "test" and then I created a new DB named "entity" then made the changes in all the places necessary. Commented Nov 21, 2013 at 1:17

2 Answers 2

1

for me it worked when i updated the value from org.hibernate.dialect.MySQLDialect to org.hibernate.dialect.MySQL57Dialect

Sign up to request clarification or add additional context in comments.

Comments

0

In your Hibernate mapping file i.e. hibernate.cfg.xml make the following change:

<property name="hibernate.dialect">org.hibernate.dialect.MySQL5InnoDBDialect</property>

instead of whatever it says right now. I am assuming:

<property name="hibernate.dialect">org.hibernate.dialect.MySQLInnoDBDialect</property>

This would definitely take care of all the errors if you say that you have checked rest of the code.

3 Comments

I will give this a try as well.
I cannot believe that this small change solved the issue. I have posted this on infinite number of forums but to no use. :-) Appreciate it.
Please post the code as well next time so that the reader can just copy/paste it in his/her IDE rahter than writing the rest of the part themselves.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.