HTML and CSS Reference
In-Depth Information
The methods of
UserManager
EJB are as follows:
getMegaUser
: Retrieves the user information. It throws
UserNotFound
exception if the target
user is not found.
•
registerMegaUser
: Registers the Mega App user in the Mega App database as an application
user (i.e., it makes the user a member in the
"User"
group). It throws
UserAlreadyExists
exception if the user ID already exists in the database.
•
removeMegaUser
: Removes the Mega App user from the database. It throws
UserNotFound
exception if the target user is not found.
•
retrieveMegaUsers
: Retrieves all the users of the Mega App (whether they are normal users or
administrator users).
•
Let's check the details of
MegaUser
JPA entity, which holds the
User
attributes and its associated validation
constraints. Listing 13-9 shows
MegaUser
JPA entity class.
Listing 13-9.
MegaUser JPA Entity Class
package com.jsfprohtml5.megaapp.model;
import java.io.Serializable;
import java.util.List;
import javax.persistence.Basic;
import javax.persistence.CascadeType;
import javax.persistence.Column;
import javax.persistence.Entity;
import javax.persistence.Id;
import javax.persistence.OneToMany;
import javax.persistence.Table;
import javax.persistence.Transient;
import javax.validation.constraints.NotNull;
import javax.validation.constraints.Size;
@Entity
@Table(name = "MEGA_USER")
public class MegaUser implements Serializable {
private static final long serialVersionUID = 109890766546456L;
@Id
@Basic(optional = false)
@Size(min = 3, max = 64, message = "ID must be between 3 and 64 characters")
@Column(name = "ID")
private String id;
@Basic(optional = false)
@NotNull
@Size(min = 3, max = 32, message = "First name must be between 3 and 32 characters")
@Column(name = "FIRST_NAME")
private String firstName;