title: Hibernate and spring mvc Deleting and updating
body: <p>We are developing a spring application with Spring MVC and hibernate. Now we ran into a problem that we can't solve.. The problem arises when we try to delete something.</p>
  
  <p>If we delete the page just loads fine and goes further like everything is succeeded, but the value in the database isn't deleted.</p>
  
  <p>Here is our code:</p>
  
  <p><strong>This is the TestDao</strong></p>
  
  <pre><code>@Repository
  public class TestDaoImpl implements TestDao {
  
      @Autowired
      private SessionFactory sessionFactory;
  
      @Override
      public Test get(int id) {
          return (Test)this.sessionFactory.getCurrentSession().createQuery("FROM Test WHERE id =:ident").setParameter("ident",id).uniqueResult();
      }
  
      @Override
      public void delete(int id) {
  
          this.sessionFactory.getCurrentSession().delete(this.get(id));
  
      }
  }
  </code></pre>
  
  <p><strong>This is our service (business layer)</strong></p>
  
  <pre><code>@Service("testService")
  public class TestServiceImpl implements TestService {
  
      private final TestDao testDao;
  
      @Inject
      public TestServiceImpl(TestDao testDao)
      {
          this.testDao = testDao;
      }
  
      @Override
      @Transactional
      public void delete(int id) {
            testDao.delete(id);
      }
  }
  </code></pre>
  
  <p><strong>And this is the controller:</strong></p>
  
  <pre><code>@Controller
  public class TestingController {
  
      @Qualifier("testService")
      @Autowired
      private TestService testService;
  
      @RequestMapping(value = "/testing")
      public ModelAndView testing()
      {
          testService.delete(1);
          return new ModelAndView("home");
      }
  
  }
  </code></pre>
  
  <p><strong>This is the hibernate configuration:</strong></p>
  
  <pre><code>&lt;!-- Parse database properties --&gt;
      &lt;context:property-placeholder location="classpath:db/db.properties"/&gt;
  
      &lt;bean id="sessionFactory" class="org.springframework.orm.hibernate3.LocalSessionFactoryBean"&gt;
          &lt;property name="mappingResources"&gt;
              &lt;list&gt;
                  &lt;value&gt;db/mappings/User.hbm.xml&lt;/value&gt;
                  &lt;value&gt;db/mappings/Authority.hbm.xml&lt;/value&gt;
                  &lt;value&gt;db/mappings/Car.hbm.xml&lt;/value&gt;
                  &lt;value&gt;db/mappings/Address.hbm.xml&lt;/value&gt;
                  &lt;value&gt;db/mappings/DrivingDay.hbm.xml&lt;/value&gt;
                  &lt;value&gt;db/mappings/Message.hbm.xml&lt;/value&gt;
                  &lt;value&gt;db/mappings/Ride.hbm.xml&lt;/value&gt;
                  &lt;value&gt;db/mappings/RouteAgreement.hbm.xml&lt;/value&gt;
                  &lt;value&gt;db/mappings/Route.hbm.xml&lt;/value&gt;
                  &lt;value&gt;db/mappings/RouteTime.hbm.xml&lt;/value&gt;
                  &lt;value&gt;db/mappings/SocialMediaLogin.hbm.xml&lt;/value&gt;
                  &lt;value&gt;db/mappings/Variables.hbm.xml&lt;/value&gt;
                  &lt;value&gt;db/mappings/Waypoint.hbm.xml&lt;/value&gt;
                  &lt;value&gt;db/mappings/Test.hbm.xml&lt;/value&gt;
              &lt;/list&gt;
          &lt;/property&gt;
          &lt;property name="dataSource"&gt;
              &lt;ref bean="dataSource"/&gt;
          &lt;/property&gt;
          &lt;property name="hibernateProperties"&gt;
              &lt;props&gt;
                  &lt;prop key="hibernate.dialect"&gt;org.hibernate.dialect.MySQL5InnoDBDialect&lt;/prop&gt;
                 &lt;prop key="hibernate.hbm2ddl.auto"&gt;update&lt;/prop&gt;
                  &lt;prop key="hibernate.show_sql"&gt;true&lt;/prop&gt;
              &lt;/props&gt;
          &lt;/property&gt;
      &lt;/bean&gt;
  
      &lt;bean id="dataSource" class="org.springframework.jdbc.datasource.DriverManagerDataSource"&gt;
          &lt;property name="driverClassName" value="${jdbc.driverClassName}"/&gt;
          &lt;property name="url" value="${jdbc.url}"/&gt;
          &lt;property name="username" value="${jdbc.username}"/&gt;
          &lt;property name="password" value="${jdbc.password}"/&gt;
      &lt;/bean&gt;
  
      &lt;bean id="transactionManager"
            class="org.springframework.orm.hibernate3.HibernateTransactionManager"&gt;
          &lt;property name="sessionFactory" ref="sessionFactory"/&gt;
      &lt;/bean&gt;
  </code></pre>
  
  <p>I know it's a wall of code, I'm sorry about that, but I thought I provide as many details as possible.</p>
  
  <p>Thanks in advance</p>
  
  <p><strong>Edit:</strong> There is a value with id 1 in the database.</p>