You are viewing a plain text version of this content. The canonical link for it is here.
Posted to ojb-user@db.apache.org by David Zejda <dv...@atlas.cz> on 2004/07/24 05:54:25 UTC

how to postinitialize objects after being completely materialized

I have a custom row reader able to initialize materialized objects by 
their _postinit() methods. Essentially it works, but there is a problem 
- the _postinit() should be called after the object is materialized 
completely, i.e. with all fields, but also references and collections 
filled. So, I guess I have to override some other method of rowreader or 
  something completely different - please, give a hint.

public class RowReaderPostinitializingImpl extends RowReaderDefaultImpl
{
     public RowReaderPostinitializingImpl(ClassDescriptor c)
     {
         super(c);
     }

     public Object readObjectFrom(Map row)
     {
         Object result = super.readObjectFrom(row);
         if (result instanceof Postinitializable)
         {
             Postinitializable art = (Postinitializable) result;
             art._postinit();
             return art;
         }
         else
         {
             return result;
         }
     }
}

David

---------------------------------------------------------------------
To unsubscribe, e-mail: ojb-user-unsubscribe@db.apache.org
For additional commands, e-mail: ojb-user-help@db.apache.org