-->
These old forums are deprecated now and set to read-only. We are waiting for you on our new forums!
More modern, Discourse-based and with GitHub/Google/Twitter authentication built-in.

All times are UTC - 5 hours [ DST ]



Forum locked This topic is locked, you cannot edit posts or make further replies.  [ 2 posts ] 
Author Message
 Post subject: getHibernateTemplate().delete not working
PostPosted: Thu Jul 07, 2011 3:08 am 
Newbie

Joined: Thu Jul 07, 2011 2:38 am
Posts: 3
Hello,
I'm writing a Spring+Hibernate webapp. I'm running a simple unit test for testing DAO operations.

The test looks like so:
Code:
@RunWith(SpringJUnit4ClassRunner.class)
@ContextConfiguration(locations={"file:src/test/resources/testSpringConfig.xml"})
@TransactionConfiguration(transactionManager="txManager")
@Transactional
public class BookingDaoTest {

   @Autowired
   private BookingDao dao;
   private Booking testBooking;

   @Before
   public void beforeTest() {
      testBooking = new Booking();
      testBooking.setSomething("something");
// ...
      
      dao.saveBooking(testBooking);
   }

   @Test
   public void testDeleteBooking() {
      int bookingId = testBooking.getBookingId();
      dao.deleteBooking(testBooking);
      Booking booking = dao.getBookingById(bookingId);
      assertNull(booking);
   }
}


Inside my BookingDaoImpl.deleteBooking method I have a single line:
Code:
getHibernateTemplate().delete(booking);


The test fails at the final assertion. So it appears that for some reason dao.deleteBooking is not working and I have no idea why. I added getHibernateTemplate().flush() invocation but it didn't help.
Also, I don't see the DELETE statement in Hibernate logs (though I see SELECT and INSERT statements).

Does anybody know what might be wrong and why the booking is not getting deleted?
Thanks a lot for any help!

Best regards,
Piotr


Top
 Profile  
 
 Post subject: Re: getHibernateTemplate().delete not working
PostPosted: Fri Jul 08, 2011 4:32 am 
Newbie

Joined: Thu Jul 07, 2011 2:38 am
Posts: 3
How about it guys? Does anyone have a clue? Sorry for double-posting but this is kind of urgent.
Thanks!

Piotr


Top
 Profile  
 
Display posts from previous:  Sort by  
Forum locked This topic is locked, you cannot edit posts or make further replies.  [ 2 posts ] 

All times are UTC - 5 hours [ DST ]


You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum

Search for:
© Copyright 2014, Red Hat Inc. All rights reserved. JBoss and Hibernate are registered trademarks and servicemarks of Red Hat, Inc.