I develop company app(JSF maven project) and we use HIbernate. I have no previus experiences with Hibernate. Application is created in that way that there is some auto-build and auto-deploy in time of starting tomcat from eclipse. I need to make first time http login call to application (which always throws exception because there are no data in DB) to hibernate create database schema automaticly on server. And then to manualy insert all data in MS Sql server query. Is it some way (or eclipse plugin) to generate sql create database (all tables) script from entity source codes + persistence.xml or how to do it automate in time of deploying application?
1 Answer
This setting in your hibernate config, creates the schema automatically everytime based on your hibernate entities. Other options are update, create-drop and validate.
<hibernate-configuration>
<session-factory>
<property name="hbm2ddl.auto">create</property>
3 Comments
falconseye
this put to persistence.xml ?
NimChimpsky
@falconseye yes, but using in live environemnt is somewhat frowned upon, by DBA's at least. They think they know best.
falconseye
is it proper tag for persistence.xml? I have found something else <property name="hibernate.hbm2ddl.auto" value="create" /> ...but it does not work :)