Now that we have prepared the structure for our Java EE application, it’s time to focus on the implementation of the Model layer—in other words, creating the contents for our EJB JAR.
As stated in the introduction of this chapter, we are going to use Enterprise JavaBeans (EJB) 3.0 and Java Persistence API (JPA) 1.0, both of which are part of the Java EE 5 standard. In the JPA, persistent data is represented by special objects called entities. Therefore, to be able to use persistent Employee
data in our application, we need an Employee
entity definition. In JPA, an entity definition is nothing more than a Java class with some extra annotations.
We will base our entity on the table that we created earlier. This means that for every column in the table we need a bean property in our class. Where needed, JPA annotations should be added. This will lead to an entity class that looks like this:
package inc.monsters.mias.data; import java.io.Serializable...