Book Image

Building a RESTful Web Service with Spring

By : Ludovic Dewailly
Book Image

Building a RESTful Web Service with Spring

By: Ludovic Dewailly

Overview of this book

Table of Contents (17 chapters)
Building a RESTful Web Service with Spring
Credits
About the Author
About the Reviewers
www.PacktPub.com
Preface
Index

The Inventory service


At the heart of our property management service lies rooms that are the representations of physical rooms that guests can reserve. They are organized in categories. A room category is a logical grouping of similar rooms. For example, we could have a Double Rooms category for all rooms with double beds. Rooms exhibit properties as per the code snippet that follows:

@Entity(name = "rooms")
public class Room {

  private long id;
  private RoomCategory roomCategory;
  private String name;
  private String description;

  @Id
  @GeneratedValue
  public long getId() {
    return id;
  }

  @ManyToOne(cascade = {CascadeType.PERSIST, CascadeType.REFRESH}, fetch = FetchType.EAGER)
  public RoomCategory getRoomCategory() {
    return roomCategory;
  }

  @Column(name = "name", unique = true, nullable = false, length = 128)
  public String getName() {
    return name;
  }

  @Column(name = "description")
  public String getDescription() {
    return description;
  }
}

With the...