Hello Henk,

The way I have implemented a postCommit a couple of times is by overriding
the commit method. 

   public boolean commit(MMObjectNode objectNode) {
      // Pre-commit code

      // Save node to database
      boolean retval = super.commit(objectNode);
      if (retval) {
         //Post-commit code
      }
      return retval;
   }
 
Personally, I don't like the preCommit method. It is called from the storage
layer to the core. For the same reason, I don't like It that the bridge is
called from the core (builder). It goes against the layers of the mmbase
architecture. Bridge->core->storage. And I hope you are aware of this
http://www.mail-archive.com/[email protected]/msg04658.html
I already have seen some interesting issues with MMBase when the builder
indirectly tried to modify the node it was inserting or commiting.
With a new node the insert() is called and with a existing node the
commit(). This is the only way I know that you can make a difference between
a new node and an exisiting one. When you override these methods then you
have to CALL the super methods otherwise you lose functionality (eg.
database inserts and commits :) ).

Nico

> -----Oorspronkelijk bericht-----
> Van: [EMAIL PROTECTED] 
> [mailto:[EMAIL PROTECTED] Namens Henk Hangyi
> Verzonden: vrijdag 12 november 2004 17:35
> Aan: [EMAIL PROTECTED]
> Onderwerp: MMObjectBuilder.postCommit ?
> 
> 
> Hi,
> 
> I want to carry out an action on a node in the process of 
> commiting it.
> 
> So the preCommit(node) looks like:
> 
> super.preCommit(node);
> Cloud cloud = CloudFactory.getCloud();
> NodeIterator iNodes= cloud.getList(node.getStringValue("number")
>    , "evenement,posrel1,deelnemers_categorie,posrel2,evenement_type"
>    , "posrel1.number,posrel1.pos,posrel2.pos", null, null, 
> null, null, false).nodeIterator();
> if(iNodes.hasNext()) {
>  ....
> }
> 
> This works perfect for already existing nodes.
> 
> However, for nodes that are new, this results in an error of type:
> nodetype of node ... could not be found. Which is not so surprising.
> 
> Questions: 
> 1. Is there an equivalent to preCommit which is carried out 
> after commiting the node (something like postCommit ?) 2. Is 
> there a way by which in the preCommit can be detected whether 
> the node already exists?
> 
> Thanks in advance,
> 
> Bye, Henk.
> 
> 


Reply via email to