why would org.apache.ibatis.logging.jdbc.ResultSetLogger output 3 column names to the console?

classic Classic list List threaded Threaded
2 messages Options
Reply | Threaded
Open this post in threaded view
|

why would org.apache.ibatis.logging.jdbc.ResultSetLogger output 3 column names to the console?

Linus Kamb
I have a strange thing happening:

on every one of a certain class of selects, I get the following output to the console:

org.apache.ibatis.logging.jdbc.ResultSetLogger@3068d1e2 : O_latitude

org.apache.ibatis.logging.jdbc.ResultSetLogger@3068d1e2 : O_longitude

org.apache.ibatis.logging.jdbc.ResultSetLogger@3068d1e2 : O_mag_value


Those are "ohs", not zeros, FWIW.


Even with logging turned completely off, I still get those lines to the console.


They correspond to 3 of the columns / fields of one of my tables / objects, although I don't know where the "O_" comes from.    The select is a join, and I prefix the one table columns with "o_".


The messages are output when a mapper method is invoked.


This is an example of one select:


Preparing: select e.db_id as e_db_id, e.create_time as e_create_time, e.modified_time as e_modified_time , e.active as e_active, e.simulation as e_simulation, e.origin_id as e_origin_id, ( e.network|| '::' ||e.event_name ) as e_event_net_id, ( e.network|| '::' ||e.source ) as e_event_source, e.display_name as e_display_name , o.db_id as o_db_id, o.create_time as o_create_time, o.modified_time as o_modified_time , o.event_id as o_event_id, o.origin_time as o_origin_time, o.latitude as o_latitude, o.longitude as o_longitude, o.depth as o_depth, o.mag_value as o_mag_value, ( o.network|| '::' ||o.source ) as o_origin_source from events e, origins o where e.origin_id = o.db_id and e.event_name = ? 


A little background:  This is basically an earthquake information database.   An earthquake event has multiple solutions, which are estimates of the seismic parameters and location (origin).   An earthquake also has a "preferred" location (origin.)   So both fetching an earthquake event object and a solution object involve the same join to the origins table, referencing sql defined in the origins-mapper.xml.   


Interestingly, only queries for an earthquake event produce the console output.


This is my first myBatis project, so I was experimenting with some of the interesting mapper.xml constructs, so I don't know if I've perhaps done something wrong.


Here are my (edited for brevity) mapper.xml codes:

<mapper namespace='gov.noaa.pmel.tsunami.tws.db.myb.mappers.EventMapper'>


        <sql id="TABLE_NAME">events</sql>


        <resultMap id="TwsEventInfoResult" type="TwsEventInfo"  >

                <id property="_dbId" column="e_db_id" />

                <result property="_createTime" column="e_create_time"/>

                <result property="_modifiedTime" column="e_modified_time"/>

                <result property="_eventId" column="e_event_net_id"

                        javaType="gov.noaa.pmel.tsunami.tcast.types.EventId"

                        typeHandler="gov.noaa.pmel.tsunami.tws.db.myb.handlers.NetInfoTypeHandler"/>

                <result property="_eventSource" column="e_event_source"

                        javaType="gov.noaa.pmel.tsunami.tcast.types.InfoSource"

                        typeHandler="gov.noaa.pmel.tsunami.tws.db.myb.handlers.NetInfoTypeHandler"/>

                <result property="_displayName" column="e_display_name"/>

                <result property="_active" column="e_active"/>

                <result property="_simulation" column="e_simulation"/>


                <association property="_origin" column="origin_id" foreignColumn="db_id" javaType="TwsOrigin"

                                fetchType="eager" columnPrefix="o_"

                                resultMap="gov.noaa.pmel.tsunami.tws.db.myb.mappers.OriginMapper.TwsOriginMap" />

        </resultMap>


        <sql id="select_events_columns_pfx">

                <include refid="gnpt.db.DbMapper.select_db_columns_pfx" /> ,

                ${pfx}.active as ${pfx}_active,

                ${pfx}.simulation as ${pfx}_simulation,

                ${pfx}.origin_id as ${pfx}_origin_id,

                ( ${pfx}.network||<include refid="gnpt.db.Common.NetInfoSeparator"/>||${pfx}.event_name ) as ${pfx}_event_net_id,

                ( ${pfx}.network||<include refid="gnpt.db.Common.NetInfoSeparator"/>||${pfx}.source ) as ${pfx}_event_source,

                ${pfx}.display_name as ${pfx}_display_name

        </sql>


        <sql id="select_all">

                select

                <include refid="select_events_columns_pfx" />,

                <include refid="gov.noaa.pmel.tsunami.tws.db.myb.mappers.OriginMapper.select_origin_columns_pfx">

                        <property name="pfx" value="o"/>

                </include>

                from events e, origins o where e.origin_id = o.db_id

        </sql>


        <select id="retrieveByName" parameterType="String" resultMap="TwsEventInfoResult">

                <include refid="select_all">

                        <property name="pfx" value="e"/>

                </include>

                and e.event_name = #{eventName}

        </select>

</mapper>


<mapper namespace='gov.noaa.pmel.tsunami.tws.db.myb.mappers.OriginMapper'>


        <sql id="TABLE_NAME">origins</sql>

        <sql id="originEventIdField">#{_origin._eventId}</sql>


        <resultMap type="TwsOrigin" id="TwsOriginMap" > <!-- extends="gnpt.db.DbMapper.DbItemMap" >  -->

                <!-- super-class fields -->

                <id property="_dbId" column="db_id" />

                <result property="_createTime" column="create_time"/>

                <result property="_modifiedTime" column="modified_time"/>


                <result property="_eventId" column="event_id"/>

                <result property="_time" column="origin_time"/>

                <result property="_latitude" column="latitude"/>

                <result property="_longitude" column="longitude"/>

                <result property="_depth" column="depth"/>

                <result property="_magValue" column="mag_value"/>

                <result property="_originSource" column="origin_source"

                        javaType="gov.noaa.pmel.tsunami.tcast.types.InfoSource"

                        typeHandler="gov.noaa.pmel.tsunami.tws.db.myb.handlers.NetInfoTypeHandler"/>

        </resultMap>


        <sql id="select_origin_columns_pfx">

                <include refid="gnpt.db.DbMapper.select_db_columns_pfx"/>,

                ${pfx}.event_id as ${pfx}_event_id,

                ${pfx}.origin_time as ${pfx}_origin_time,

                ${pfx}.latitude as ${pfx}_latitude,

                ${pfx}.longitude as ${pfx}_longitude,

                ${pfx}.depth as ${pfx}_depth,

                ${pfx}.mag_value as ${pfx}_mag_value,

                ( ${pfx}.network||<include refid="gnpt.db.Common.NetInfoSeparator"/>||${pfx}.source ) as ${pfx}_origin_source

        </sql>


</mapper>


Any ideas on why this would happen?  The 3 lines are output for every event row returned by an events table query.


thanks,

Linus


 

--
You received this message because you are subscribed to the Google Groups "mybatis-user" group.
To unsubscribe from this group and stop receiving emails from it, send an email to [hidden email].
For more options, visit https://groups.google.com/d/optout.
Reply | Threaded
Open this post in threaded view
|

Re: why would org.apache.ibatis.logging.jdbc.ResultSetLogger output 3 column names to the console?

Iwao AVE!
Hi Linus,

Which version of MyBatis are you using?

Regards,
Iwao



2016-09-29 0:43 GMT+09:00 Linus Kamb <[hidden email]>:
I have a strange thing happening:

on every one of a certain class of selects, I get the following output to the console:

org.apache.ibatis.logging.jdbc.ResultSetLogger@3068d1e2 : O_latitude

org.apache.ibatis.logging.jdbc.ResultSetLogger@3068d1e2 : O_longitude

org.apache.ibatis.logging.jdbc.ResultSetLogger@3068d1e2 : O_mag_value


Those are "ohs", not zeros, FWIW.


Even with logging turned completely off, I still get those lines to the console.


They correspond to 3 of the columns / fields of one of my tables / objects, although I don't know where the "O_" comes from.    The select is a join, and I prefix the one table columns with "o_".


The messages are output when a mapper method is invoked.


This is an example of one select:


Preparing: select e.db_id as e_db_id, e.create_time as e_create_time, e.modified_time as e_modified_time , e.active as e_active, e.simulation as e_simulation, e.origin_id as e_origin_id, ( e.network|| '::' ||e.event_name ) as e_event_net_id, ( e.network|| '::' ||e.source ) as e_event_source, e.display_name as e_display_name , o.db_id as o_db_id, o.create_time as o_create_time, o.modified_time as o_modified_time , o.event_id as o_event_id, o.origin_time as o_origin_time, o.latitude as o_latitude, o.longitude as o_longitude, o.depth as o_depth, o.mag_value as o_mag_value, ( o.network|| '::' ||o.source ) as o_origin_source from events e, origins o where e.origin_id = o.db_id and e.event_name = ? 


A little background:  This is basically an earthquake information database.   An earthquake event has multiple solutions, which are estimates of the seismic parameters and location (origin).   An earthquake also has a "preferred" location (origin.)   So both fetching an earthquake event object and a solution object involve the same join to the origins table, referencing sql defined in the origins-mapper.xml.   


Interestingly, only queries for an earthquake event produce the console output.


This is my first myBatis project, so I was experimenting with some of the interesting mapper.xml constructs, so I don't know if I've perhaps done something wrong.


Here are my (edited for brevity) mapper.xml codes:

<mapper namespace='gov.noaa.pmel.tsunami.tws.db.myb.mappers.EventMapper'>


        <sql id="TABLE_NAME">events</sql>


        <resultMap id="TwsEventInfoResult" type="TwsEventInfo"  >

                <id property="_dbId" column="e_db_id" />

                <result property="_createTime" column="e_create_time"/>

                <result property="_modifiedTime" column="e_modified_time"/>

                <result property="_eventId" column="e_event_net_id"

                        javaType="gov.noaa.pmel.tsunami.tcast.types.EventId"

                        typeHandler="gov.noaa.pmel.tsunami.tws.db.myb.handlers.NetInfoTypeHandler"/>

                <result property="_eventSource" column="e_event_source"

                        javaType="gov.noaa.pmel.tsunami.tcast.types.InfoSource"

                        typeHandler="gov.noaa.pmel.tsunami.tws.db.myb.handlers.NetInfoTypeHandler"/>

                <result property="_displayName" column="e_display_name"/>

                <result property="_active" column="e_active"/>

                <result property="_simulation" column="e_simulation"/>


                <association property="_origin" column="origin_id" foreignColumn="db_id" javaType="TwsOrigin"

                                fetchType="eager" columnPrefix="o_"

                                resultMap="gov.noaa.pmel.tsunami.tws.db.myb.mappers.OriginMapper.TwsOriginMap" />

        </resultMap>


        <sql id="select_events_columns_pfx">

                <include refid="gnpt.db.DbMapper.select_db_columns_pfx" /> ,

                ${pfx}.active as ${pfx}_active,

                ${pfx}.simulation as ${pfx}_simulation,

                ${pfx}.origin_id as ${pfx}_origin_id,

                ( ${pfx}.network||<include refid="gnpt.db.Common.NetInfoSeparator"/>||${pfx}.event_name ) as ${pfx}_event_net_id,

                ( ${pfx}.network||<include refid="gnpt.db.Common.NetInfoSeparator"/>||${pfx}.source ) as ${pfx}_event_source,

                ${pfx}.display_name as ${pfx}_display_name

        </sql>


        <sql id="select_all">

                select

                <include refid="select_events_columns_pfx" />,

                <include refid="gov.noaa.pmel.tsunami.tws.db.myb.mappers.OriginMapper.select_origin_columns_pfx">

                        <property name="pfx" value="o"/>

                </include>

                from events e, origins o where e.origin_id = o.db_id

        </sql>


        <select id="retrieveByName" parameterType="String" resultMap="TwsEventInfoResult">

                <include refid="select_all">

                        <property name="pfx" value="e"/>

                </include>

                and e.event_name = #{eventName}

        </select>

</mapper>


<mapper namespace='gov.noaa.pmel.tsunami.tws.db.myb.mappers.OriginMapper'>


        <sql id="TABLE_NAME">origins</sql>

        <sql id="originEventIdField">#{_origin._eventId}</sql>


        <resultMap type="TwsOrigin" id="TwsOriginMap" > <!-- extends="gnpt.db.DbMapper.DbItemMap" >  -->

                <!-- super-class fields -->

                <id property="_dbId" column="db_id" />

                <result property="_createTime" column="create_time"/>

                <result property="_modifiedTime" column="modified_time"/>


                <result property="_eventId" column="event_id"/>

                <result property="_time" column="origin_time"/>

                <result property="_latitude" column="latitude"/>

                <result property="_longitude" column="longitude"/>

                <result property="_depth" column="depth"/>

                <result property="_magValue" column="mag_value"/>

                <result property="_originSource" column="origin_source"

                        javaType="gov.noaa.pmel.tsunami.tcast.types.InfoSource"

                        typeHandler="gov.noaa.pmel.tsunami.tws.db.myb.handlers.NetInfoTypeHandler"/>

        </resultMap>


        <sql id="select_origin_columns_pfx">

                <include refid="gnpt.db.DbMapper.select_db_columns_pfx"/>,

                ${pfx}.event_id as ${pfx}_event_id,

                ${pfx}.origin_time as ${pfx}_origin_time,

                ${pfx}.latitude as ${pfx}_latitude,

                ${pfx}.longitude as ${pfx}_longitude,

                ${pfx}.depth as ${pfx}_depth,

                ${pfx}.mag_value as ${pfx}_mag_value,

                ( ${pfx}.network||<include refid="gnpt.db.Common.NetInfoSeparator"/>||${pfx}.source ) as ${pfx}_origin_source

        </sql>


</mapper>


Any ideas on why this would happen?  The 3 lines are output for every event row returned by an events table query.


thanks,

Linus


 

--
You received this message because you are subscribed to the Google Groups "mybatis-user" group.
To unsubscribe from this group and stop receiving emails from it, send an email to [hidden email].
For more options, visit https://groups.google.com/d/optout.

--
You received this message because you are subscribed to the Google Groups "mybatis-user" group.
To unsubscribe from this group and stop receiving emails from it, send an email to [hidden email].
For more options, visit https://groups.google.com/d/optout.