Hello guys, I am using Hibernate + Spring with netbeans to make a web application. I have it working correctly and displaying data from the DB. My problem is I only know how to do one hibernate query which is shown below.

How can I do insert/delete queries. For instance in my JSP page I have a button, how can I make it so when a user clicks on a button it deletes a specific record from the database. In essence how can I pass parameters to my controller. and can someone explain when/how I need to use DAO objects.


 * To change this template, choose Tools | Templates
 * and open the template in the editor.

package controller;

import java.util.List;
import javax.servlet.ServletException;
import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;
import model.HibernateUtil;
import org.hibernate.Session;
import org.springframework.web.servlet.ModelAndView;
import org.springframework.web.servlet.mvc.Controller;

 * @author Zombies
public class TestimonialsController implements Controller {

    public ModelAndView handleRequest(HttpServletRequest hsr, HttpServletResponse hsr1)
        throws Exception

        ModelAndView bc = new ModelAndView("testimonials");
        String out = new String ("testimonial list");

        try {
            Session session = HibernateUtil.getSessionFactory().getCurrentSession();
            List result= session.createQuery("from Testimonial").list();
            bc.addObject("testimonials", result);
        } catch (Exception e) {

        bc.addObject("message", out);
        return bc;

6 Years
Discussion Span
Last Post by peter_budo
This topic has been dead for over six months. Start a new discussion instead.
Have something to contribute to this discussion? Please be thoughtful, detailed and courteous, and be sure to adhere to our posting rules.