4

I have some java classes like,

Class User {
    String email;
    String name;
    String password;
}

Class Point {
    int pointForA;
    int pointForB;
}

Is there any way to get database table structure(or SQL queries) from these java classes directly? I just want to avoid manual tables' creation in database. Thanks in advance.

4
  • Is the question not clear? Not showing any research? or does not seem useful? Commented Apr 1, 2012 at 14:01
  • I didn't downvote, but maybe you should add more information about what is your expected output. Commented Apr 1, 2012 at 14:02
  • I think you are not showing any research, all modern JPA-based ORMs can do what you want. Commented Apr 1, 2012 at 14:03
  • :( Once I found this JPA based ORM. But I was not so sure that it would be a easy way around for my problem. Commented Apr 1, 2012 at 14:09

1 Answer 1

2

you can use jpa(Java persistence API). JPA can help you in directly creating tables from java classes. for DDL statements(i.e. creating tables) you need to have this line in your persistence.xml file.

property name="eclipselink.ddl-generation" value="create-tables" (for eclipselink jpa provider )

this line will ensure that if your tables are not present in database then it will be created by java program

if you don't know about jpa then you need to read java ee tutorial like this

http://docs.oracle.com/javaee/6/tutorial/doc/bnbqa.html

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

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.