Java Reference
In-Depth Information
@Entity
@Table(name="seat_type)
public class SeatType implements Serializable {
private static final long serialVersionUID =
1L;
@Id
@GeneratedValue(strategy=GenerationType.IDENTITY)
private int id;
@NotNull
@Size(min = 1, max = 25, message = "You need
to enter a Seat Description (max 25 char)")
@Pattern(regexp = "[A-Za-z ]*", message =
"Description must contain only letters and
spaces")
private String description;
@NotNull
private int price;
@NotNull
private int quantity;
// Getters/Setters here
}
As you can see, we can also place a description on a constraint, which can be used
to provide a customized error message to the JSF layer should the data fail to pass
the constraint. You can check the Oracle documentation for a full list of constraints
available at http://docs.oracle.com/javaee/6/tutorial/doc/gircz.html .
Search WWH ::




Custom Search