1

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 enter image description here

(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?

2 Answers 2

1

There is one property hibernate.hbm2ddl.auto in hibernate which create tables as per your pojo structure.

Refer this doc.

Sign up to request clarification or add additional context in comments.

1 Comment

I found SchemaExport more useful, since hibernate.hbm2ddl.auto in xml configuration configures Hibernate to do it each time the session factory is created
0

Use SchemaExport.export. Run following code in main() method:

 AnnotationConfiguration configuration = new AnnotationConfiguration();
 SchemaExport schemaExport = new SchemaExport(configuration);
 schemaExport.export(true, true, true, false);

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.