4. Managing Persistent Entities with the JPA Persistence Entity Editor
Time to complete this step: 30 minutes
The BEA Workshop ORM Workbench allows you to view, create, and manage JPA
entity relationships. The Entities Editor provides a centralized
view of all entity relationships, allows for modification of entity properties,
and simple navigation between the object model, mapping associations, and database
schema layers.
View entity relationship diagram using the Entities Editor and review features
of editor
As described previously, the Entities Editor displays relationships
diagram for entities defined in the project.
Expand the JPA Persistence Configuration branch in AppXplorer.
Workshop provides a list of entities under the Entities branch
based on the entities defined in the Persistence configurations file.
Double-click on JPA Persistence Configuration>
Entities Editor to access all of the entities and their properties.
The JPA Persistence Entities Editor displays all entity
relationships defined in the web application. Each box displays a specific
entity, its properties, and an icon denoting the nature of the relationship.
The JPA Persistence Entities Editor provides an opportunity
to perform various UI operations like Zoom In, Zoom Out, and Auto Arrangement
of diagram. Right-click on the Entities Editor and select
any action to perform from the pop-up menu.
The JPA Persistence Entities Editor displays property
types for an entity with tool-tip popups.
The JPA Persistence Entities Editor also lets you filter
relationships between entities. This is very helpful feature to understand
/ review the entity relationship diagram when it is complex.
Click the Filter button and select the options Many
to One and One to Many to filter these relations
between entities.
Reset the filters.
You can also review entities using AppXRay. Right-click
the Product entity under the JPA Persistence Configuration
Entities and select Show AppXRay Dependencies.
The AppXaminer View displays the dependency diagram.
Edit the properties of JPA Persistent Entities using the Smart Editor
Using the Smart Editor in Properties view,
Workshop provides easy editing for standard properties of some objects.
Select a Contact entity in JPA Persistence Entities
Editor, the Smart Editor displays the properties
for the Contact entity.
For each selected entity, you can edit the associated Java Bean class,
strategy for persistence, and the database access information. To edit any
information, either enter text in the text box or click on the
icon to get a list of possible options.
In JPA Persistence Entities Editor select the phone
property of Contact entity. The Smart Editor
displays properties of the phone property. Observe the properties.
In Smart Editor you can perform following changes to modify
the Length property of property phone. For
example:
Set Nullable to false
Update the Length value from 20 to 25
Press CTRL+S to save the changes.
Clicking on the Column Name under Database Column
in the Smart Editor for a property will take you to the respective
column in the Database diagram in DbXaminer.
By right-clicking the entity Contact, you can view its
source code or delete the entity. You can open entity or field source code
also by double-clicking the entity or field in the Entities Editor.
Managing JPA Entity mappings
The following briefly describes how the annotations are translated into what
the Smart Editor displays. Note that where the Smart Editor displays an underlined
label, you can click the label to view the corresponding Java source code or
item in the DbXplorer.
Review the many-to-one association between OrderData
and Customer. Click on customer property
in the OrderData entity and view Join Properties
in the Smart Editor .
2. Click on Edit Join Columns to edit the mapping
association.
3. Similarly view the one-to-many association
between OrderData and Lineitem. Click on the
lineitems property in the OrderData entity
and view Target Entity and Mapped By in the
Smart Editor.
4. Clicking on Target Entity will take you to the class of
the related entity type Lineitem.
5. Clicking on Mapped By under the Join Propertieswill
take you to the many-to-one association to OrderData
in Lineitem source code .
6. Also view the source of the one-to-one association
between Customer and CustomerId by
double clicking on the association in the JPA Persistence Entities Editor.
7. View the one-to-one association between Customer and CustomerId
in the Source editor -
Click one of the following arrows to navigate through the tutorial: