[Helma-user] Adding objects to generic object reference in onPersist()

Anton Pirker helma at gmiatlich.net
Tue Sep 25 06:54:12 CEST 2007


Good Morning!

I got an reply to my question from Kris Leite yesterday via direct mail. 
I just wanted to post it here to have a possible solution for others 
with the same problem.

His patch works great, but i do not know how much impact it has on 
Helmas performance or other stuff i am unaware of. Could some of the 
guys knowing about the internal stuff of Helma have a look on the patch 
and give some comment?

Thanks, Anton

Kris wrote:

 > Hi Anton,
 >
 > > > I think it is because onPersist is called right before the object is
 > > > stored. So when a create a 'Change' object and add it to a
 > > > 'changes'-collection of this in onPersist this does not have an 
finale
 > > > id and so the 'Change'-Object does not know who his parent is.

 > I had the same idea of wanting to add a history of changes to a
 > HopObject. I also have very similar code in the onPersist to implement
 > that idea and got the same results.  This issue is not Helma knowing
 > how to store it, it just ignores any additional HopObject changes
 > during the commit. I added a modification to the commit routine of
 > Transactor.java to pickup any additional HopObject changes during the
 > commit operation.  The code changes are very simple, in
 > Transactor.java at lines: 260, 261 which are:
 >
 >
 >         if (!dirtyNodes.isEmpty()) {
 >             Object[] dirty = dirtyNodes.values().toArray();
 >
 >
 > Replace with:
 >
 >         while (!dirtyNodes.isEmpty()) {
 >             Object[] dirty = dirtyNodes.values().toArray();
 >
 >             // reset dirty node list
 > 	    dirtyNodes = new HashMap();
 >
 >
 > Then your onPersist code will work.
 >
 > Later,
 > Kris



More information about the Helma-user mailing list