<?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE mapper PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN"
"http://mybatis.org/dtd/mybatis-3-mapper.dtd">
<mapper namespace="com.lypaydb.mapper.Order_DayMapper">
<resultMap type="com.lypaydb.pojo.Order_Day" id="odMap">
<id property="id" column="id" />
<result property="date" column="date" />
<result property="total" column="total" />
<result property="aisle" column="aisle" />
<result property="operators" column="operators" />
<result property="channelid" column="channelid" />
<result property="appid" column="appid" />
<result property="paycnt" column="paycnt" />
</resultMap>
<!-- /*sql -->
<select id="findod" parameterType="java.util.Map" resultMap="odMap">
select * from order_day where 1 = 1
<if test="${start} != null and ${start != ''}">
and date >= #{start}
</if>
<if test="${end} != null and ${end} != ''">
and #{end} > date
</if>
<if test="appid != null and appid != ''">
and appid=${appid}
</if>
<if test="operators != null and operators != ''">
and operators=${operators}
</if>
limit ${Page.startPos},${Page.pageSize};
</select>
<select id="getAllCount" parameterType="java.util.Map" resultType="java.lang.Integer">
select count(*) from order_day where 1=1
<if test="${start} != null and ${start != ''}">
and date >= #{start}
</if>
<if test="${end} != null and ${end} != ''">
and #{end} > date
</if>
<if test="appid != null and appid != ''">
and appid=${appid}
</if>
<if test="operators != null and operators != ''">
and operators=${operators}
</if>
</select>
<!-- sql*/ -->
</mapper>
mainly to see if the first two methods to determine my findod inside , because I am the only one inside the POJO class date, date type . I want to pass over two points in time for the inquiry , I was put into a map inside , key-value , respectively ("start", time ) and ("end", time ) . Why
reported this wrong
nested exception is org.apache.ibatis.builder.BuilderException: Error evaluating expression '$ {start} = null and $ {start =!! ;''} 'Cause:.! org.apache.ibatis.ognl.ExpressionSyntaxException: Malformed OGNL expression: $ {start} = null and $ {start ! =''} [org.apache.ibatis.ognl.ParseException:. Encountered "$" at line 1, column 1 Was expecting one ; of: ":" ... "not" ... "+" ... "-" ... "~" ... "!" ... "(" ... "true" ... " ; false "..." null "..." # this "..." # root "..." # " ... "[" ... "{" ... "@" ... "new". ........ " \ ' " ... "` " ... " \ " " .. ....... ]
And I start and end of the conditional removed, the two conditions under normal use , how to solve ah ? Is this condition can only be judged if POJO class attribute it? Seeking answers ah , Online
------ Solution ---------------------------------- ----------
map type parameters, use # keyName # to reference , keyName for the key name ? ? ? ?
------ Solution ------------------------------------ --------
MyBatis, database mapping this one .
------ Solution ----------------------- ---------------------
you pass a map key value pairs. . KEY attribute map to see the key-value pairs , map and physical objects are possible. Entities which do not have those attributes , you use map
------ Solution ------------------------------ --------------
but I did not end inside the entity class and the start of this attribute , pass over the entity classes ( full package ) will complain can not find the property right ? The end is just key value map definition. This should be right ? If you operate a data field has a corresponding physical parameters do you use physical objects , if not with a map, MyBatis mappings in this part of the database , all the parameters you pass over urban object properties ( entities --- entity attributes ) (map --- map of KEY)
------ For reference only -------------------------- -------------
own roof ! ! ! ! Find great God
------ For reference only ----------------------------------- ----
nobody comin ......
------ For reference only ---------------------------------------
Well I solved < br> ------ For reference only ---------------------------------------
Finally, what is the problem ?
------ For reference only -------------------------------------- -
map type parameters, use # keyName # to reference , keyName for the key name ? ? ? ?
ah. I said that part of the judgment if the conditions are not the sql . I know sql using # {key} or $ {key} to obtain . I'm talking about
------ For reference only ---- -----------------------------------
this is after revision
<select id="findod" parameterType="map" resultMap="odMap">
select * from order_day where 1 = 1
<if test="start != null and start != ''">
and date >= #{start}
</if>
<if test="end != null and end != ''">
and #{end} > date
</if>
<if test="appid != null and appid != ''">
and appid=${appid}
</if>
<if test="operators != null and operators != ''">
and operators=${operators}
</if>
limit ${Page.startPos},${Page.pageSize};
</select>
put parameterType = "java.lang.Map" change = "map" , but it seems that it does not matter . . . Then determine if the conditions to write directly on the key value map inside , whether it is not a POJO class inside , anyway it wants to write KEY value . I do not know my understanding is wrong, because it is feasible it.
------ For reference only -------------------------------------- -
do not know my understanding is wrong, I hope experienced people to give pointers to the attention of the local
------ For reference only ---------------------------------------
looked a long time did not understand how going on , really Gehangrugeshan ah
------ For reference only ------------------------------ ---------
but I did not end inside the entity class and the start of this property , the entity class pass over ( full package ) will complain it can not find the property ? The end is just key value map definition. This should be right ?
------ For reference only -------------------------------------- -
---- - For reference only ---------------------------------------
but I did not end inside the entity class and the start of this property , the entity class pass over ( full package ) will complain it can not find the property ? The end is just key value map definition. This should be right ? If you operate a data field has a corresponding physical parameters do you use physical objects , if not with a map, MyBatis mappings in this part of the database , all the parameters you pass over urban object properties ( entities --- entity attributes ) (map --- map of KEY)
Oh ~ ~ understand. 3Q
没有评论:
发表评论