Dali Java Persistence Tools User Guide Release 3.2 Release 3.2 |
|
Generating tables from entities |
Modifying persistent project properties |
Home > User Guide > Tasks > Generating dynamic entities...
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:
Right-click the JPA project in the Project Explorer and select JPA Tools > Generate Dynamic Entities from Tables.
The Select Tables page of the Generate Dynamic Entities from Tables wizard appears.
On the Select Tables page, select the tables from which to generate the entities and click Next.
The Table Associations page appears.
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.
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.
Use the Customize Individual Entities page to customize specific generated entities.
Click Finish to complete the wizard and generate the entities.
Dali generates the dynamic entities, using the VIRTUAL
access type, as shown in Example 3-4.
Example 3-4 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>