Perhaps it's my test code. The entityManager.flush() is all I need to call, I presume (obviously it kicks off the JDBC SQL which I see logged):

Habitat habitat = habitatDao.findById(DataValues.HABITAT_ID);
habitat.setTitle("modified title " + System.currentTimeMillis());
Date oldModified = habitat.getModified();
habitat = habitatDao.persist(habitat);
em.flush();
logger.info("old date:" + oldModified);
logger.info("new date:" + habitat.getModified());
Assert.assertTrue("old modified date should be before new",
    oldModified.before(habitat.getModified()));


Shibu Gope on 06/03/08 21:41, wrote:
try @PrePersist annotation

On Thu, Mar 6, 2008 at 1:05 PM, Adam Hardy <[EMAIL PROTECTED]> wrote:
I can't get a callback to work on my entity superclass.

 I've mapped it like this:

   <mapped-superclass class="org.permacode.atomic.domain.AtomicEntity"
     access="FIELD">
     <pre-persist method-name="prePersistCallBack" />
     <attributes>
       <basic name="ownerId">
         <column name="OWNER_ID" />
       </basic>
       <basic name="created">
         <column name="CREATED" />
         <temporal>DATE</temporal>
       </basic>
       <basic name="modified">
         <column name="MODIFIED" />
         <temporal>DATE</temporal>
       </basic>
       <version name="version">
         <column name="VERSION" />
       </version>
     </attributes>
   </mapped-superclass>


 The method prePersistCallBack() is on the superclass:

     public void prePersistCallBack()
     {
         this.modified = new Date();
         logger.info("doing prePersistCallBack() - " + this + " - modified="
             + this.modified);
     }

 I see no logging and I see the SQL statement contains the untouched modified 
value.

 Is there anything extra in the mapped subclass entities which is needed for
 callbacks?

Reply via email to