开发者

netbeans + hibernate for java swing application

im developing a java swing app and i would use hibernate for persistance. Im totally new in jpa, hibernate and ORM in general.

Im follow this tutorial, its easy but the problem is the java class that descrive a table in db are made from the table with re开发者_如何学Cverse enginering.

I want do the opposite process: i want make db table from the java class.

The question is, how can i do this with netbeans? There are some tutorial?


Apparently, it is more usual to reverse engineer the database to generate the java class.

If you want to generate the database from the java class, you can generate a DDL for each hibernate object like this :

AnnotationConfiguration config = new AnnotationConfiguration();
config.addAnnotatedClass(User.class);
config.configure();
new SchemaExport(config).create(true, true);

With these parameters for the method create :
create(boolean script, boolean export)
script - print the DDL to the console
export - export the script to the database

0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜