Java Reference
In-Depth Information
User
1
1
1
0..*
0..*
0..*
Alias
Contact
Folder
1
0..*
Message
1
0..*
Attachment
Figure 12.2: The webmail application model classes
about these model classes. which the JPA calls entities. Add the @Entity
annotation on each model class:
Download email_23/src/stripesbook/model/User.java
@Entity
public class User extends ModelBase {
Entities are managed by JPA and also discovered by Stripersist. We'll
see what Stripersist does for us in the next section. Let's finish anno-
tating the model for JPA.
Each model class has a property that uniquely identifies individual
objects. The @Id annotation must be added to that property for each
entity. Rather than repeat this property in each model class, we can
use an abstract base class:
Download email_23/src/stripesbook/model/ModelBase.java
@MappedSuperclass
public abstract class ModelBase {
@Id
@GeneratedValue
private Integer id;
public Integer getId() { return id; }
public void setId(Integer id) { this .id = id; }
}
 
 
Search WWH ::




Custom Search