Generating dynamic entities from tables

When using EclipseLink JPA, you can create dynamic entities from your database tables. This dynamic persistence provides access to a relational database with all the benefits of JPA without coding or maintaining Java classes.

Dali dynamically creates the classes at runtime, as needed.

To generate dynamic entities:

  1. Right-click the JPA project in the Project Explorer and select JPA Tools > Generate Dynamic Entities from Tables.

    JPA Tools > Generate Dynamic Entities from Tables

    The Select Tables page of the Generate Dynamic Entities from Tables wizard appears.

    Select Tables


  2. On the Select Tables page, select the tables from which to generate the entities and click Next.

    The Table Associations page appears.

    Table Associations


  3. On the Table Associations page, specify which table associations should be generated. Use the Create New Association wizard to create additional relationships.

    Click Next. The Customize Default Entity Generation page appears.

    Customize Defaults


  4. On the Customize Default Entity Generation page, specify the default information to use when generating the entities, and click Next.

    The Customize Individual Entities page appears.

    Customize Individual Entities


  5. Use the Customize Individual Entities page to customize specific generated entities.

  6. Click Finish to complete the wizard and generate the entities.

Dali generates the dynamic entities, using the VIRTUAL access type, as shown in Example: Sample eclipselink-orm.xml File with Dynamic Entities.

Sample eclipselink-orm.xml File with Dynamic Entities

<?xml version="1.0" encoding="UTF-8"?>
<entity-mappings version="2.4" xmlns="http://www.eclipse.org/eclipselink/xsds/persistence/orm" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:schemaLocation="http://www.eclipse.org/eclipselink/xsds/persistence/orm http://www.eclipse.org/eclipselink/xsds/eclipselink_orm_2_4.xsd">
    <entity class="quickstart.demo.model.Inventory" access="VIRTUAL">
        <attributes>
            <id name="itemSku" attribute-type="long">

            </id>
        </attributes>
    </entity>
    <entity ...">
    </entity>
</entity-mappings>