Search code examples
springhibernatespring-mvcmany-to-manysqlexception

SQLGrammarException:Table does not exist (ManyTOMany) relationship Spring MVC


I am trying to perform a post user operation using REST services in Spring MVC. I have a many to many relationship between user and phone objects. I have created a User table and Phone table in the database.

Both the user and phone objects are initialized as ArrayList. However, when I run this code(try to create a new user) I get this error: javax.persistence.PersistenceException: org.hibernate.exception.SQLGrammarException: Table 'schemaname.USER_PHONE' doesn't exist

I don't understand why the implementation is excepting the table USER_PHONE to be present on prior basis. Isn't it supposed to create on its own ? Please help me out.Thanks.


Solution

  • Solved the issue by setting "hibernate.hbm2ddl.auto" to "create-drop". Thanks :)