Skip to main content

Notice: this Wiki will be going read only early in 2024 and edits will no longer be possible. Please see: https://gitlab.eclipse.org/eclipsefdn/helpdesk/-/wikis/Wiki-shutdown-plan for the plan.

Jump to: navigation, search

JPA Diagram Editor Project Tutorial

Overview

This tutorial provides a step by step walk-through of the Java Diagram Editor.

Prerequisites

This tutorial is based on the Eclipse Helios and JPA 1.0 projects.

To install JPA Diagram Editor project follow the steps described in How to Install section of the JPA Diagram Editor wiki main page.

Open JPA Diagram Editor

In the Eclipse IDE create new JPA 1.0 project.

The Open Diagram action is available on two levels:

  • On project level: Select the newly created JPA project and from its context menu select JPA Tools -> Open Diagram

OpenDiagramOnProjectLevel.jpg

  • On JPA node level: Expand the newly created JPA project and from the context menu of its JPA node, select Open Diagram

OpenDiagramOnJPANodeLevel.jpg

Create new Entity

In the Eclipse IDE create new JPA 1.0 project. Download the persistence provider library and add it into the JPA project's classpath.

Open the JPA Diagram Editor. For more information how to do this, follow the steps described in the previous section Open JPA Diagram Editor.

From the right site of the editor, the so called Palette section, select Java Entity and drag&drop it to the diagram. A new entity class org.persistence.Entity1 with default primary key attribute should be created and shown in the diagram:

CreateEntity.jpg

Visualize Existing Entities in JPA Diagram Editor

In the Eclipse IDE create new JPA 1.0 project. Download the persistence provider library and add it into the JPA project's classpath.

Create new entity as you select the created JPA project and from its context menu select New -> Entity.

Open the JPA Diagram Editor. For more information how to do this, follow the steps described in section Open JPA Diagram Editor.

To open existing entity in the JPA Diagram Editor:

  • expand the JPA project to entity resource level in the Project Explorer view, select the created entity and drag&drop it to the diagram.
  • or in the JPA Diagram Editor with right click of the mouse select Show All Entities.

Rename Entity

In the Eclipse IDE create new JPA 1.0 project. Open its diagram editor and create new entity. For more information how to create new entity follow the steps described in the previous section Create new Entity. There are two ways to rename entity:

  • Select entity and click on its header name - this is the so called direct editing

Note: If you double click on the entity, its source code will be opened.

  • Select entity and from its context menu select Refactor Entity Class -> Rename...

Collapse/Expand Entity

In the Eclipse IDE create new JPA 1.0 project. Open its diagram editor and create new entity. For more information how to create new entity follow the steps described in the previous section Create new Entity.

By default the entity is expanded. To collapse entity, select it in the diagram

  • and from its context buttons select Collapse:

CollapseEntity.jpg

  • or from its context menu select Collapse JPA Entity.

Entity is collapsed:

CollapsedEntity.jpg

To expand entity, select it in the JPA Diagram Editor

  • and from its context menu select Expand:

ExpandEntity.jpg

  • or from its context menu select Expand JPA Entity.

Entity is expanded:

ExpandedEntity.jpg

Remove Entity

In the Eclipse IDE create new JPA 1.0 project. Open its diagram editor and create new entity. For more information how to create new entity follow the steps described in the previous section Create new Entity. Entity can me deleted as a resource or removed only from the JPA diagram.

To delete entity select it and

  • from its context buttons choose Delete:

DeleteEntity.jpg

  • from its context menu select Delete

To remove entity from diagram, select it and

  • from its context buttons choose Discard Changes and Remove if you don't want to save the changes that were made if there are any:

DiscardAndRemoveEntity.jpg

  • from its context menu select Remove All Entities From Diagram -> ... and Discard Changes
  • or from its context buttons choose Save and Remove to save all changes that were made:

SaveAndRemoveEntity.jpg

  • from its context menu select Remove All Entities From Diagram -> ... and Save Changes

Add new Attribute

In the Eclipse IDE create new JPA 1.0 project. Open its diagram editor and create new entity. For more information how to create new entity follow the steps described in the previous section Create new Entity. Select the newly created entity or just place the mouse over it and select from its context buttons Create Attribute:

CreateAttribute.jpg

A new attribute named Attribute1 should be added under section Other Attributes:

AddAttribute.jpg

Edit Attribute

In the Eclipse IDE create new JPA 1.0 project. Open its diagram editor and create new entity. Create new attribute. For more information how to create new attribute follow the steps described in the previous section Create new Attribute.

Entity's Attribute can be renamed or its type can be changed.

To rename the attribute, select it and press the mouse one more time, the editing area should be shown.

Note: If you double click on the attribute, the entity's source code will be opened.

To edit the attributes type, select it and from its context menu choose Refactor Attribute Type...

Remove Attribute

In the Eclipse IDE create new JPA 1.0 project. Open its diagram editor and create new entity. Create new attribute. For more information how to create new attribute follow the steps described in the previous section Create new Attribute.

To remove attribute, select it or just place the mouse over it. Select the only one context button Delete Attribute:

DeleteAttribute.jpg

Copyright © Eclipse Foundation, Inc. All Rights Reserved.