Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- @SpringBootApplication
- public class ReservationServiceApplication {
- @Bean
- CommandLineRunner commandLineRunner(ReservationRepository reservationRepository) {
- return strings -> {
- Stream.of("A","b","C","D", "I")
- .forEach( n -> reservationRepository.save(new Reservation(n)));
- };
- }
- public static void main(String[] args) {
- SpringApplication.run(ReservationServiceApplication.class, args);
- }
- }
- @Entity
- class Reservation {
- @Id
- @GeneratedValue
- private Long id;
- private String reservationName;
- public Reservation(String reservationName) {
- this.reservationName = reservationName;
- }
- public Reservation() {
- }
- public Long getId() {
- return id;
- }
- public void setId(Long id) {
- this.id = id;
- }
- public String getReservationName() {
- return reservationName;
- }
- public void setReservationName(String reservationName) {
- this.reservationName = reservationName;
- }
- @Override
- public String toString() {
- return "Reservation{" +
- "id=" + id +
- ", reservationName='" + reservationName + ''' +
- '}';
- }
- }
- @RepositoryRestResource
- interface ReservationRepository extends JpaRepository<Reservation,Long> {
- @RestResource(path = "by-name")
- Collection<Reservation> findByREservationName(@Param("rn") String rn);
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement