Is it possible to force property assignment using private field?

classic Classic list List threaded Threaded
1 message Options
Reply | Threaded
Open this post in threaded view
|

Is it possible to force property assignment using private field?

Casey
I've seen that MyBatis will set the values of private fields just fine
when there is no setter method on an object.  So, for example, the
following works just fine:

        <mapper namespace="...">
                <resultMap type="Foo" id="fooResultMap">
                        <result property="bar" column="BAR" />
                </resultMap>
        </mapper>

where Foo is

        public class Foo {

                private String bar;

                public String getBar() {
                        return bar;
                }
        }

The value of the private field bar is set as expected, However, if I
add a setBar(String value) method to the class Foo, the new setter
method is called to set the property's value.

My question is, can one force MyBatis to set the private field's
value, rather than calling the setter method?

Many thanks in advance,
Casey