0

I am working on a project with MySQL,Hibernate,Java,GWT

I am making an entity class where i am making each and every field as per the fields in mysql like there is a table UserInfo with fields ,id,name,password,and many other fields in MySQL

now when i am making an entity class in java/hibernate I have to create each field i.e id,name,password and others with my hand

I was just wondering if there's a way with which my entity class automatically detects all fields which are in my Database table and make all the fields in java itself and link them with the database fields.

thanks

2 Answers 2

1

hibernate has a property called "hibernate.hbm2ddl.auto".

hibernate.hbm2ddl.auto

Automatically validates or exports schema DDL to the database when the SessionFactory is created. With create-drop, the database schema will be dropped when the SessionFactory is closed explicitly.

e.g. validate | update | create | create-drop

you can set the proper value when you start creating your sessionfactory. then you will see the tables were created in your datastore, of course, the table creation was based on your entity classes.

if you want to generate java classes (entities) from your database table. you may want to check hibernate reverse engineering out:

http://docs.jboss.org/tools/3.3.0.M5/en/hibernatetools/html/reverseengineering.html

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

Comments

0

Try Hibernate Tools.

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.