81,122
社区成员




@Entity
@NamedQueries({
@NamedQuery(name = Customer.FIND_ALL, query = "SELECT c FROM Customer c ORDER BY c.lastName ASC, c.firstName ASC"),
@NamedQuery(name = Customer.FIND_BY_EMAIL, query = "SELECT c FROM Customer c WHERE c.email = :email")
})
@XmlRootElement
@Table(name = "customer", uniqueConstraints = @UniqueConstraint(columnNames = "email"))
@JsonIdentityInfo(generator = ObjectIdGenerators.PropertyGenerator.class,property = "id")
public class Customer implements Serializable {
private static final long serialVersionUID = 1L;
public static final String FIND_ALL = "Customer.findAll";
public static final String FIND_BY_EMAIL = "Customer.findByEmail";
@Id
@GeneratedValue(strategy = GenerationType.TABLE)
@ApiModelProperty(hidden = true)
private Long id;
@OneToMany(mappedBy = "customer", cascade = CascadeType.ALL, fetch = FetchType.LAZY)
private Set<Booking> booking = new HashSet<Booking>();
set....get...
@Entity
@NamedQuery(name = Booking.FIND_ALL, query = "SELECT c FROM Booking c ORDER BY c.id ASC")
@XmlRootElement
@Table(name = "booking")
public class Booking implements Serializable {
private static final long serialVersionUID = 1L;
public static final String FIND_ALL = "Booking.findAll";
@Id
@GeneratedValue(strategy = GenerationType.TABLE)
private Long id;
@NotNull
@ManyToOne
@JoinColumn(name = "customer_id")
@ApiModelProperty(readOnly = true)
private Customer customer;
set....get....
@SuppressWarnings("unused")
@POST
@ApiOperation(value = "Add a new Booking to the database")
public Response createBooking(
@ApiParam(value = "JSON representation of Booking object to be added to the database", required = true)
Booking booking) {
.....
}