Skip to main content


Eclipse Community Forums
Forum Search:

Search      Help    Register    Login    Home
Home » Language IDEs » Java Development Tools (JDT) » Insert In SpringMVC
Insert In SpringMVC [message #878096] Mon, 28 May 2012 14:32
arian zand is currently offline arian zandFriend
Messages: 1
Registered: May 2012
Junior Member
Hi I have a Webapp and i want to insert a record in my db
This is my controller

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";
    }
}


this is my dao

public interface ReservationDAO 
{
	public Reservation saveReservation(int roomId, String firstname, String lastname, String arrival, String departure,String numNights,String numPersons,double price);

}


my daoImpl
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;
	}
	
	
}


When I press on save in my view it doensn't insert a new record in my db

I have no errors, the webpage goes back to my home.jsp...

Someone who knows what im doing wrong ?

thnx!
Previous Topic:How to create a stateless session bean programatically..
Next Topic:Failing to create JVM, but I have more than enough RAM
Goto Forum:
  


Current Time: Thu Mar 28 11:49:41 GMT 2024

Powered by FUDForum. Page generated in 0.02625 seconds
.:: Contact :: Home ::.

Powered by: FUDforum 3.0.2.
Copyright ©2001-2010 FUDforum Bulletin Board Software

Back to the top