Reputation: 166
I have wrote some POJOs in NetBeans, and want to map these entities automatically to an empty database, to be tables.
I have read the netbeans official tutorial https://netbeans.org/kb/docs/java/hibernate-java-se.html#06a
But using Hibernate Mapping File
as the document says can not choose the Database Table
value, compare to the pic
(https://netbeans.org/images_www/articles/70/java/hibernate-j2se/mapping-wizard.png,
The actor
value will not show since my database is empty.
So what should I do if I followed the tutorial, or is there any other method to automatically create tables by POJO in NetBeans?
Upvotes: 1
Views: 8899
Reputation: 21961
Use SchemaExport.export
. Run following code in main()
method:
AnnotationConfiguration configuration = new AnnotationConfiguration();
SchemaExport schemaExport = new SchemaExport(configuration);
schemaExport.export(true, true, true, false);
Upvotes: 0
Reputation: 10497
There is one property hibernate.hbm2ddl.auto
in hibernate which create tables as per your pojo structure.
Refer this doc.
Upvotes: 1