Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 7510873
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 29, 20262026-05-29T23:21:31+00:00 2026-05-29T23:21:31+00:00

We are developing a spring application with Spring MVC and hibernate. Now we ran

  • 0

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.

If we delete the page just loads fine and goes further like everything is succeeded, but the value in the database isn’t deleted.

Here is our code:

This is the TestDao

@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));

    }
}

This is our service (business layer)

@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);
    }
}

And this is the controller:

@Controller
public class TestingController {

    @Qualifier("testService")
    @Autowired
    private TestService testService;

    @RequestMapping(value = "/testing")
    public ModelAndView testing()
    {
        testService.delete(1);
        return new ModelAndView("home");
    }

}

This is the hibernate configuration:

<!-- Parse database properties -->
    <context:property-placeholder location="classpath:db/db.properties"/>

    <bean id="sessionFactory" class="org.springframework.orm.hibernate3.LocalSessionFactoryBean">
        <property name="mappingResources">
            <list>
                <value>db/mappings/User.hbm.xml</value>
                <value>db/mappings/Authority.hbm.xml</value>
                <value>db/mappings/Car.hbm.xml</value>
                <value>db/mappings/Address.hbm.xml</value>
                <value>db/mappings/DrivingDay.hbm.xml</value>
                <value>db/mappings/Message.hbm.xml</value>
                <value>db/mappings/Ride.hbm.xml</value>
                <value>db/mappings/RouteAgreement.hbm.xml</value>
                <value>db/mappings/Route.hbm.xml</value>
                <value>db/mappings/RouteTime.hbm.xml</value>
                <value>db/mappings/SocialMediaLogin.hbm.xml</value>
                <value>db/mappings/Variables.hbm.xml</value>
                <value>db/mappings/Waypoint.hbm.xml</value>
                <value>db/mappings/Test.hbm.xml</value>
            </list>
        </property>
        <property name="dataSource">
            <ref bean="dataSource"/>
        </property>
        <property name="hibernateProperties">
            <props>
                <prop key="hibernate.dialect">org.hibernate.dialect.MySQL5InnoDBDialect</prop>
               <prop key="hibernate.hbm2ddl.auto">update</prop>
                <prop key="hibernate.show_sql">true</prop>
            </props>
        </property>
    </bean>

    <bean id="dataSource" class="org.springframework.jdbc.datasource.DriverManagerDataSource">
        <property name="driverClassName" value="${jdbc.driverClassName}"/>
        <property name="url" value="${jdbc.url}"/>
        <property name="username" value="${jdbc.username}"/>
        <property name="password" value="${jdbc.password}"/>
    </bean>

    <bean id="transactionManager"
          class="org.springframework.orm.hibernate3.HibernateTransactionManager">
        <property name="sessionFactory" ref="sessionFactory"/>
    </bean>

I know it’s a wall of code, I’m sorry about that, but I thought I provide as many details as possible.

Thanks in advance

Edit: There is a value with id 1 in the database.

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-05-29T23:21:33+00:00Added an answer on May 29, 2026 at 11:21 pm

    You may be missing tx:annotation-driven in your xml – this is the one which triggers creation of proxies for @Transaction annotated beans – if the request is not within a transaction the delete will not work.

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I am using Spring Web MVC and Hibernate for developing my application. My login.jsp
I'm developing a simple, training application with Spring MVC and Hibernate. I'm using Maven
I am developing my application using spring-web-mvc... Now at my Controller it returns like
I'm developing a Java/Spring web application. The problem I'm currently facing is that I'd
Background I am developing an application (with Spring MVC ) with its base path
I'm developing a spring application that uses large MySQL tables. When loading large tables,
Hey I am developing an desktop application using Spring and Hibernate, and I have
We are developing a web application using Spring framework and Hibernate ORM. As far
I am developing project using Spring , Struts2 & Hibernate . Now I want
I'm developing a spring application, now I've added a dropdownlist to one of my

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.