Java Reference
In-Depth Information
private Integer quantity;
private SeatPosition position;
// 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 con-
straint. You can check the Oracle documentation for a full list of constraints available at .
We also have added a seat position information to our seat type. It is a simple enum:
public enum SeatPosition {
ORCHESTRA("Orchestra", "orchestra"), BOX("Box", "box"),
BALCONY("Balcony", "balcony");
private final String label;
private final String dbRepresentation;
private SeatPosition(String label, String
dbRepresentation) {
this.label = label;
this.dbRepresentation = dbRepresentation;
public String getDatabaseRepresentation() {
return dbRepresentation;
public String getLabel() {
return label;
When we save our SeatType entity in the database, we will also store the enum value
with it. Earlier versions of JPA gave us two options to address it automatically (besides
Search WWH ::

Custom Search