ibatis-user-java mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From Carlos Pita <carlosjosep...@gmail.com>
Subject Property/Field resolution order
Date Mon, 31 Aug 2009 21:17:11 GMT
Hi all,

I'm porting an application persistence layer from hibernate to ibatis.
The hibernate implementation uses field access, and changing to
property access will be asking for trouble at this point of
development. I know ibatis already fallbacks to field access when
there is no property getter/setter, but I yearn for the inverse
resolution order.

As MetaObject accepts an ObjectWrapper as its object parameter...

 if (object instanceof ObjectWrapper) {
      this.objectWrapper = (ObjectWrapper) object;
    } else if (object instanceof Map) {
      this.objectWrapper = new MapWrapper(this, (Map)object);
    } else {
      this.objectWrapper = new BeanWrapper(this, object);
    }

...one solution would be to implement a custom ObjectFactory that
wraps the instances created by DefaultObjectFactory inside an
appropriate custom ObjectWrapper, say FieldObjectWrapper. But as
Reflector assumes the property-then-field precendence,
FieldObjectWrapper would have to be written from scratch, because
MetaObject, MetaClass and Reflector would render useless for my
purposes.

What do you think about adding a global configuration option to set
the field/property resolution order? The change is trivial to
implement (just a few tweaks to Reflector, I think), and will be
backwards compatible if the default order remains property-then-field.

This could be very valuable for developers that prefer to go the other
way around, and at a very low cost for ibatis itself. Also, having
properties as a last resort is handy even if you prefer field access
by default.

Best regards
--
Carlos

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


Mime
View raw message