Advertisement
Guest User

Untitled

a guest
Jul 19th, 2019
83
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 1.42 KB | None | 0 0
  1. @SpringBootApplication
  2. public class ReservationServiceApplication {
  3.  
  4. @Bean
  5. CommandLineRunner commandLineRunner(ReservationRepository reservationRepository) {
  6. return strings -> {
  7. Stream.of("A","b","C","D", "I")
  8. .forEach( n -> reservationRepository.save(new Reservation(n)));
  9. };
  10. }
  11. public static void main(String[] args) {
  12. SpringApplication.run(ReservationServiceApplication.class, args);
  13. }
  14.  
  15. }
  16.  
  17. @Entity
  18. class Reservation {
  19. @Id
  20. @GeneratedValue
  21. private Long id;
  22. private String reservationName;
  23.  
  24. public Reservation(String reservationName) {
  25. this.reservationName = reservationName;
  26. }
  27.  
  28. public Reservation() {
  29. }
  30.  
  31. public Long getId() {
  32. return id;
  33. }
  34.  
  35. public void setId(Long id) {
  36. this.id = id;
  37. }
  38.  
  39. public String getReservationName() {
  40. return reservationName;
  41. }
  42.  
  43. public void setReservationName(String reservationName) {
  44. this.reservationName = reservationName;
  45. }
  46.  
  47. @Override
  48. public String toString() {
  49. return "Reservation{" +
  50. "id=" + id +
  51. ", reservationName='" + reservationName + ''' +
  52. '}';
  53. }
  54. }
  55.  
  56. @RepositoryRestResource
  57. interface ReservationRepository extends JpaRepository<Reservation,Long> {
  58. @RestResource(path = "by-name")
  59. Collection<Reservation> findByREservationName(@Param("rn") String rn);
  60. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement