0

I am reading https://www.mkyong.com/hibernate/how-to-generate-code-with-hibernate-tools/. It explains how to first create a database, and then to automatically create a Hibernate mapping and Java classes that match the tables in the database by using JBoss plugin in Eclipse.

I was wondering how to do the reverse automatically. Specifically, if I have created java classes, then how shall I create the database automatically? Do I need to manually create the database first, if it doesn't exist already? Do I need to manually create the tables in the database first, if they don't exist already? Thanks.

Note that If I am correct, this is how to do that manually instead. First add annotation or a hbm.xml file for the mapping, and then create the database and then create the tables in the database corresponding to the Java classses.

Tim
  • 1
  • 141
  • 372
  • 590
  • Most of the Hibernate tutorials actually show it the way you're looking for, sometimes called "entities first" or "objects first" or similar names. See https://stackoverflow.com/questions/438146/hibernate-hbm2ddl-auto-possible-values-and-what-they-do and http://hibernate.org/orm/documentation/getting-started/ – E-Riz Jan 05 '18 at 22:38
  • @E-Riz Thanks. If I am correct, the first link you gave is for automating the creation of database from existing java classes? – Tim Jan 05 '18 at 22:49
  • That's correct. – E-Riz Jan 05 '18 at 23:07

0 Answers0