Unfortunately, I can't get mapped-superclass callbacks to work in Toplink Essentials or Hibernate EntityManager.

Funny, considering it must be a fairly common requirement.

Adam Hardy on 06/03/08 18:05, 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.

Reply via email to