Results 1 to 4 of 4
Thread: Insert In SpringMVC
- 05-28-2012, 04:37 PM #1
Member
- Join Date
- May 2012
- Posts
- 12
- Rep Power
- 0
Insert In SpringMVC
Hi I have a Webapp and i want to insert a record in my db
This is my controller
tis is my daoJava Code: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"; } }
Java Code:Code: public interface ReservationDAO { public Reservation saveReservation(int roomId, String firstname, String lastname, String arrival, String departure,String numNights,String numPersons,double price); }
my daoImpl
Code:
When I press on save in my view it doensn't insert a new record in my dbJava Code: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!
- 05-28-2012, 05:20 PM #2
Moderator
- Join Date
- Apr 2009
- Posts
- 10,476
- Rep Power
- 16
Re: Insert In SpringMVC
You'll need to stick some logs in there then and see exactly where in the code it is going wrong.
Please do not ask for code as refusal often offends.
- 05-28-2012, 05:25 PM #3
Member
- Join Date
- May 2012
- Posts
- 12
- Rep Power
- 0
Re: Insert In SpringMVC
What do you mean?
In my logs I have no warnings or errors
He ignores my method
reservationdao.saveReservation(reservation.getRoom Id(),reservation.getFirstname(),
reservation.getLastname(),reservation.getArrival() ,reservation.getDeparture(),reservation.getNumberO fNights(),...
- 05-29-2012, 09:29 AM #4
Moderator
- Join Date
- Apr 2009
- Posts
- 10,476
- Rep Power
- 16
Re: Insert In SpringMVC
I see no debug logging at all in the controller, so how do you know the controller is being called?
I see no debug logging in saveReservation, so how do you know that method isn't being called?
So stick some logging in those methods so you can see what (if anything) is going on in them, otherwise you are simply guessing.
The other option is to debug it and step through.Please do not ask for code as refusal often offends.
Similar Threads
-
insert a row into the DB
By miko5054 in forum JDBCReplies: 13Last Post: 07-11-2010, 02:01 PM -
How to insert '{'
By izrydka in forum New To JavaReplies: 3Last Post: 05-18-2010, 08:38 PM -
How to insert large data into database using one insert query
By sandeepsai39 in forum New To JavaReplies: 3Last Post: 02-28-2009, 09:17 AM -
Help with sql insert
By jmorris in forum New To JavaReplies: 6Last Post: 12-02-2008, 07:05 PM -
SQL Insert Help!!!!
By shaungoater in forum New To JavaReplies: 1Last Post: 06-14-2008, 03:14 AM


LinkBack URL
About LinkBacks
Reply With Quote
Bookmarks