1

Is there a way to automatically create javax.persistence.Entity classes from an existing database (or from the SQL statements that created them)?

I am just reading through the persistence part of The Java EE 5 Tutorial and creating all these annotations by hand seems rather wasteful considering that all (or most) of the necessary knowledge is already encoded in the database or even explicitly given in the form of SQL statements.

1 Answer 1

3

There are several attemps to reverse engineer databases to create entity classes, one of the first google results show this blog, but you can find quite a lot information. Also if you are going to use hibernate, check for ddl2hbm tools, what basically is the very same idea.

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

1 Comment

Excellent, your link has exactly what I was looking for. Creating a "JPA Project" in Eclipse and right-click on it gives you "JPA Tools" which includes "Generates Tables from Entities" and "Generate Entities from Tables". Thank you!

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.