In this post we will create a persistence model for our little employee management application. Based on an earlier post where we created a basic JDeveloper Web application.
Over the project with contextual menu, New > EJB > Entities From Tables. We will use the EJB 3.0 technology, annotating entity beans as JPA 2.0:
Select Departaments and Employees tables.
As seen in an earlier post, we can obtain the ER diagram from a made data base. I created it in the package lebrijo.diagrams:
We can create a New > EJB Diagram, and drag-drop the created entities, we have the whole draw:
I refactored the employees attribute by manager, because it defines the relationship better.
This is refreshed automatically to the EJB diagram (theory, in practice I have to drag the entities again).
As last exercise, we can create the ‘find by name’ query, in the query annotation at Employees entity:
@Entity @NamedQueries({ @NamedQuery(name = "Employees.findAll", query = "select o from Employees o") , @NamedQuery(name = "Employees.findByName", query = "select o from Employees o where o.firstName like :p_name") }) |