The g9 Database Import Eclipse plugin supports converting database schemas to an Ecore or Xcore model, or Java source code.
The domain model based on the imported schema will contain classes, groups and associations. Database tables results in domain model classes, and the columns of a table will become attributes in the class. Foreign keys in the database schema are treated as associations. Groups or value objects are created from indexes, primary keys and foreign keys in the database schema containing more than one column.
A database schema will be imported to an existing project in an Eclipse workspace. Start by creating a project of the right type into which your database schema will be imported:
The imported database schema can also be used as a domain model in a g9 modeling project. The latter requires a full g9 installation. See g9 products.
Open the Import wizard by selecting the target project and the Import… context menu of the existing project. Expand the g9 category, select Import Database Model and click the [Next] button.
On the wizard page Database Model Import - Connection, choose one of the built-in JDBC drivers (MySQL, MS SQL Server, Sybase ASE or Derby) for your database, or register a JDBC driver suitable for your database type by pressing the [Maintain JDBC Drivers] button. Fill in the connection properties to access the database to be imported:
Attributes with the name of the ancestor and locking columns will be excluded by matching the names used in the database before fetching the schema. Click the [Fetch] button to import the schema from the database.
After a successful fetch of the database schema, page Database Model Import - Create Model shows the tables referenced in the schema. Every time the database schema has changed, click the Fetch button to update the database model in the wizard.
In the section Import to a Java Model or Import to an Xcore Model, parameters can be set in order to customize the imported model. Common parameters for all model types are:
For Java projects, the following parameters are available in addition to the common parameters:
The tables found in the database schema are shown in a list. To exclude a table from being imported to the domain model, uncheck the Include check box for that table. By selecting multiple lines in the list of tables, the inclusion and sub package of all selected tables can be edited.
To edit the package and name of a class, select a line in the list of tables and click the [Edit…] button. This opens the Table Configuration page:
In the Table Configuration page, a sub package can be added to the common root package for all classes. The suggested class name can be changed. To exclude a column from being imported to the domain model, uncheck the Include check box for that column. By selecting multiple lines in the list of columns, the checked/unchecked columns will be included/excluded from being imported to the domain model.
In the Table Configuration page, select a line in the list of columns and click the [Edit…] button. This opens the Column Configuration page where the suggested attribute name can be edited.
The last step is the mapping of JDBC types to Domain Model types. The g9 Database Import has a default mapping of all JDBC types. To change the mapping of a type, select the JDBC type in the list and click the [Edit…] button. This will open the JDBC Type Mapping Configuration page:
Click the [Finish] button to start the database model import. For each included table, a Java class will be generated to the target project:
If the Cancel button of the wizard is clicked, and any of the values in the dialog is changed, you can choose to save the values. The values are saved for the current import project, and will be restored the next time the Import Database Model wizard is started for the project.
g9 2.6.0 - april 2017
g9 2.5.0 - september 2016
g9 2.4.0 - juni 2016
g9 2.3.0 - april 2016
g9 2.2.0 - februar 2016
g9 2.1.0 - oktober 2015
g9 2.0.0 - august 2015
Ta kontakt med oss dersom du ønsker eldre versjoner.