EclipseUML User Guide > Persistence  Development

Reverse an existing Database into the Class Diagram



To reverse an existing Database into the Class diagram you need to use both Dali and EclipseUML plugins.
It is not possible to reverse an existing database if you don't use the EclipseUML JEE build including Eclipse 3.3 Europa.
This section is composed by an Oracle Database example:
  1. Connect your database
  2. Create a JPA Project
  3. Generate Java code from Database
  4. Reverse Oracle Database into a class Diagram

1. How to connect to my Database.

You need to switch to JPA Perspective.
Go to the Database Source Explorer > Database > Oracle




Click on Oracle in the Database Explorer > Open the contextual menu > Connect




The JBDC connection will be created




2. Create a JPA Project

Click in the Package Explorer > New > Other > JPA > JPA Development > Next




Select your Connection (e.g. Oracle) and your implementation library (e.g.Toplink)



3. Generate Java Code from your database

Click on  your JPA project in your Package Explorer > JPA tools > Generate Entities



Select the source folder and the table you want to transform into Java Classes (e.g. Article, Categorize etc...)
Create a package in which your code will be generated (e.g. entities)
Click on the finish button.



Your previously selected tables have been created as Entity Classes in your Package Explorer in the package entities.




4. Reverse Oracle Database into a class Diagram

Click on your JPA project in your Package Explorer > UML > Create/Update UML Model.
This will create a new UML 2.1 Metamodel from your Java Code Entities.



Select your project and the package you want to upgrade to UML > Next > Next > Annotations (EJB3) > Click on the Finish button.




Your project has been updated to UML 2.1 metamodel.
Click on your project and select src > entities > Open Reverse UML > Class Diagram > select association and click on the OK button.
Here is the class diagram which will be displayed inside Eclipse 3.3 in the JPA Perspective.