日期:2014-05-16  浏览次数:20469 次

iBatis中使用timestamp类型的办法
插入1:

<insert id=”insertUserLocation” parameterClass=”UserLocation”>
INSERT INTO
user_location
(user_id,
location_id,
start_time,
end_time,
islocal)
VALUES
(#userId#,
#locationId#,
#startTime:TimeStamp#,
#endTime:TimeStamp#,
#islocal#
)
</insert>

插入2:
<select id="getHourCpuLongBetween" resultMap="hourCpuLongResult" parameterClass="java.util.Map">
<![CDATA[
        SELECT *
         FROM HOURCPULONG
         WHERE APPID = #appId#
               AND APPVERSION = #appVersion#
               AND STARTTIME>=#startTime:TimeStamp#
               AND ENDTIME<=#endTime:TimeStamp#
   ]]>
</select>

查询:

<select id=”selectByUserLocation” parameterClass=”UserLocation” resultClass=”UserLocation”>
SELECT
user_id as userId,
location_id as locationId,
start_time as startTime,
end_time as endTime,
islocal
FROM user_location
WHERE
user_id = #userId# and
start_time = #startTime:TimeStamp# and
end_time = #endTime:TimeStamp# and
location_id = #locationId#
</select>