
2. Create a JPA Class
from the Editor Toolbar
Click on the JPA icon in
the Class Diagram Editor.
Select JPA Entity for example.

Select the Entity type
from the list.
Select Table > Name for example.

Enter the Stereotype
Value.
Enter table in the Value Field for example.

Enter the name of the
JPA Id.
Enter Id in the Name field for example.

Your JPA Class has
immediately been created in your Class Diagram and in your Java code.

3. Create a JPA Class
from the Class Diagram contextual menu.
Click on the Class
Diagram background > New.
Select New > JPA > Entity
> Name for example.

Enter the Stereotype
Value.
Enter table in the Value Field for example.

Enter the name of the
JPA Id.
Enter Id in the Name field for example.

Your JPA Class has immediately been created in your Class Diagram and in your Java code.

4. Extend existing
Class by adding JPA properties using:
1. Adding EclipseUML stereotype into
the UML model and getting live code synchronization to add JPA
annotation in your code.
You can extend JPA
properties to existing classes.
For example, click on class2 and add persistence property to this class.
Click on Class2 > Properties

Add a new stereotype to
your class.
For example add persistence properties to your class by selecting New Stereotype.

Select
Persistence::Entity to map a Class and add persistence properties.
It means that this class will be
saved as a table in your database.

1. Using Dali plugin, or writing code to add
annotation in your java code and getting immediate live from
code to model synchronization.
The Dali annotation will immediately be saved inside the UML 2.1
metamodel if you just add a JPA annotation in your code using the live
code and model synchronization.
Create a class using the
UML Editor or the Package Explorer menu. Note that the JPA details
synchronization is using the Java Code Editor, therefore you need to
select the Class either in the code, or double click in the class
diagram on the Element.

The Class2 has been
updated.

An error is in the code
because the mapped class is not contained in any persistence unit.
We are going to fix this error by selecting persistence.xml file in the
Package Explorer > JPA Tools >
Synchronize

There is still an error
saying that the Entity " Class2" has no Id or EmbeddedId.
We are going to fix this error.

We need to create a
new attribute Id.
Click on the Class2 > New >
Attribute

The attribute has been
created. Click on the attribute and select the attribute code (the JPA Details is synchronize with the
java code and the diagram is also synchronize with the java code. Don't
close the java code, because there is no direct synchronization between
the UML
editor and the JPA details, except using the code editor..)
Add a map property to the Attribute.

The code is now clean
with no error.

We are now going to use
the Add JPA annotation menu.
Please note that the JPA Annotation
sub menus will only be activated if the Class is already an
Entity.

The JPA table annotation
has been added in your UML Editor diagram, in your Java Code and in
your UML Model.

5. Why my new JPA Class
is in error ?
The JPA Class could be
in error for one of the following reasons:
- Did you add the needed external jar. See more information
- Did you synchronize your data. See more information
- Did you add an Id to your Class. See more information