-->
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.  [ 4 posts ] 
Author Message
 Post subject: The @PreUpdate callback is not called when entity is updated
PostPosted: Tue Jun 28, 2005 4:04 am 
Newbie

Joined: Mon Mar 14, 2005 2:57 pm
Posts: 16
Using the EntityManager beta1 I saw that the @PreUpdate callback is not called when the entity is updated.

To showcase that here is a Test case for the EntityManager TestSuite.

replace the testEntityListener method on CallbacksTest with the following code:
Code:
   public void testEntityListener() throws Exception {
       EntityManager em = factory.createEntityManager();
      Cat c = new Cat();
      c.setName("Kitty");
      c.setDateOfBirth( new Date(90, 11, 15) );
      em.getTransaction().begin();
      em.persist(c);
      em.getTransaction().commit();

      em.getTransaction().begin();
      c = em.find( Cat.class, c.getId() );
      assertNotNull( c.getLastUpdate());
      Date date1=c.getLastUpdate();
      c.setName("new name!");
      em.getTransaction().commit();

      em.getTransaction().begin();
      c = em.find( Cat.class, c.getId() );
      assertNotNull( c.getLastUpdate() );
      Date date2=c.getLastUpdate();
      if( date1.equals(date2) )
         fail("Should not be equal.");
      em.getTransaction().commit();
      em.close();
   }


Top
 Profile  
 
 Post subject:
PostPosted: Tue Jun 28, 2005 11:42 am 
Hibernate Team
Hibernate Team

Joined: Tue Aug 26, 2003 12:50 pm
Posts: 5130
Location: Melbourne, Australia
So, submit to JIRA, with a simple, runnable test case.


Top
 Profile  
 
 Post subject:
PostPosted: Tue Jun 28, 2005 3:26 pm 
Newbie

Joined: Mon Mar 14, 2005 2:57 pm
Posts: 16
I just did here is the reference http://opensource.atlassian.com/project ... wse/EJB-20


Top
 Profile  
 
 Post subject:
PostPosted: Fri Jul 01, 2005 9:22 am 
Hibernate Team
Hibernate Team

Joined: Sun Sep 14, 2003 3:54 am
Posts: 7256
Location: Paris, France
It was called but the entity state changes were not propagated. I fixed that in CVS. Thanks.

_________________
Emmanuel


Top
 Profile  
 
Display posts from previous:  Sort by  
Forum locked This topic is locked, you cannot edit posts or make further replies.  [ 4 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.