Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- <form action="/hms/accommodations?searchBY" method="GET">
- <input type="text" name="searchKeyword"/>
- <input type="submit" value="Submit"/>
- </form>
- @RequestMapping(value = "/{searchKeyword}", method = RequestMethod.GET)
- public List<Accommodation> listofAccomo(@PathVariable("searchKeyword") String searchKeyword){
- List<Accommodation> searchResult = accommodationService.findAllAccommodationBySearchBox(searchKeyword);
- return searchResult;
- }
- public abstract List<Accommodation> findAllAccommodationBySearchBox(String searchKeyword);
- public List<Accommodation> findAllAccommodationBySearchBox(String searchKeyword){
- TypedQuery<Accommodation> searchResult = em.createNamedQuery("findAllAccommodationBySearch", Accommodation.class);
- searchResult.setParameter("searchKeyword",'%'+searchKeyword+'%');
- List<Accommodation> result=searchResult.getResultList();
- return result;
- }
- @NamedQueries(
- {
- @NamedQuery(
- name = "findAllAccommodationBySearch",
- query = "SELECT a FROM Accommodation a WHERE a.person.firstName LIKE :searchKeyword OR a.person.middleName LIKE :searchKeyword OR a.person.lastName LIKE :searchKeyword OR a.room.roomNumber LIKE :searchKeyword OR a.person.pvId LIKE :searchKeyword OR a.startDate LIKE :searchKeyword OR a.endDate LIKE :searchKeyword"
- )
- })
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement