javaspringhibernatehbm2ddl

hibernate.hbm2ddl.auto create-drop with production Database


I am in need to clarify below ,

  1. Is it mandatory to set the hibernate.hbm2ddl.auto property If we are using Hibernate.
  2. hibernate.hbm2ddl.auto create-drop will affect any thing in the production DB

I am using spring localsession factory builder to build hibernate session .The queries all executed fine by using @Transaction but after query execution im getting Invalid data access sql grammer exception.I am assuming Hibernate trying to update something with DB which couldn't.

That's y asking help on hbm2ddl.auto property?


Solution

    1. No. The default is fine: it does nothing with the database
    2. Well, it will drop your database (you'll lose everything) when the session factory is closed, and recreate the schema when it restarts. So you really, really don't want that in production.

    If you want help on your exception, you should show your code, show the stack trace of the exception, and show the relevant information (what the relevant tables look like, for example). I doubt hbm2ddl.auto has anything to do with that exception. Usually, when an exception occurs, it's a problem with your code, not a problem with hibernate. That's true of any framework/library.