Hi I have a Webapp and i want to insert a record in my db
This is my controller
tis is my daoCode:public class ReservationController { @Autowired private RoomDAO roomdao; @Autowired private ReservationDAO reservationdao; @RequestMapping(value={"/newReservation"},method=RequestMethod.GET) public String ReservationFormulier(ModelMap model){ Reservation reservation = new Reservation(); model.addAttribute("dereservatie", reservation); return "/newReservation"; } @RequestMapping(value={"/newReservation"},method=RequestMethod.POST) public String ReservationMaken2(@ModelAttribute("dereservatie") @Valid Reservation reservation, BindingResult result, ModelMap model){ reservationdao.saveReservation(reservation.getRoomId(),reservation.getFirstname(), reservation.getLastname(),reservation.getArrival(),reservation.getDeparture(),reservation.getNumberOfNights(),reservation.getNumberOfPersons(),reservation.getPrice()); return "home"; } }
my daoImplCode:public interface ReservationDAO { public Reservation saveReservation(int roomId, String firstname, String lastname, String arrival, String departure,String numNights,String numPersons,double price); }
When I press on save in my view it doensn't insert a new record in my dbCode:public class ReservationDAOcoll implements ReservationDAO{ @PersistenceContext private EntityManager em; @Override public Reservation saveReservation(int roomId, String firstname, String lastname, String arrival, String departure, String numNights, String numPersons, double price) { Reservation reservation = new Reservation(); reservation.setRoomId(roomId); reservation.setFirstname(firstname); reservation.setLastname(lastname); reservation.setArrival(arrival); reservation.setDeparture(departure); reservation.setNumberOfNights(numNights); reservation.setNumberOfPersons(numPersons); reservation.setPrice(price); em.persist(reservation); return null; } }
I have no errors, the webpage goes back to my home.jsp...
Someone who knows what im doing wrong ?
thnx!


Reply With Quote
