Haskell Fun Haskell Fun - 1 year ago 89
Java Question

How does it work ? Dot notation on null - mybatis

When I do:

insert into .... values (...,#{object.intField, javaType=Integer},...)#
then it is working - in database this column contains
- as expected. How does it work under hood ? I mean, that
is null, altohugh it works. Where is the magic ?

Answer Source

Parameters values are resolved from the method org.apache.ibatis.scripting.defaults.DefaultParameterHandler.setParameters(PreparedStatement)

Then the magic you are looking for is here: method org.apache.ibatis.reflection.MetaObject.getValue(String) tokenizes parameter name string, splitting on dots, and is recursively called until the end of the chain is reached or until the current element is null.

After that we are back to the general case: object properties values are retrieved by reflection: down to java.lang.reflect.Field.

Recommended from our users: Dynamic Network Monitoring from WhatsUp Gold from IPSwitch. Free Download