There is no READABLE property named 'day' in class 'java.lang.String';You have an error in your SQL

 <typeAlias alias="roombook" type="roombook.dao.model.RoombookModel" />

 <resultMap class="roombook" id="get-all-roombooks">
  <result property="roombookId" column="rid" />
  <result property="bookUserName" column="cname" />
  <result property="roomId" column="roomid" />
  <result property="roomName" column="roomname" />
  <result property="day" column="day" />
  <result property="bookTimeStart" column="starttime" />
  <result property="bookTimeEnd" column="endtime" />
 </resultMap>

 <select id="getAllReserve" resultMap="get-all-roombooks"
  parameterClass="String">
  SELECT S3.rid,S3.roomid,S1.roomname,S2.detial as starttime,S4.detial
  as endtime,S3.day,S3.cname FROM yy.mroom S1,yy.time S2,yy.reserve
  S3,yy.time S4
  <dynamic prepend="WHERE">
   S1.roomid=S3.roomid and S2.tid=S3.starttimeId and S4.tid=S3.endtimeId
   <isNotEmpty property="day" prepend="AND">
    S3.day=#day#
   </isNotEmpty>
  </dynamic>
 </select>

原来是这个样子的,报错,修改成
<isNotEmpty property="value" prepend="AND">
    S3.day=#value#
   </isNotEmpty>

因为如果是int,String,etc类型的话.参数值应该就value作为参数传递进去。

参考了文章:http://bakcom.iteye.com/blog/226036

顺便提下,我使用的数据库是mysql。修改后,报其他的错误:

You have an error in your SQL syntax; check the manual that corresponds to your MySQL server versio

 

终于找到错误的根本原因了,因为S1.roomid=S3.roomid and S2.tid=S3.starttimeId and S4.tid=S3.endtimeId并不是动态SQL语句,所以不应该包到dynamic里面去,写成下面的就可以了:

<select id="getAllReserve" resultMap="get-all-roombooks" parameterClass="roombook">
  SELECT S3.rid,S3.roomid,S1.roomname,S2.detial as starttime,S4.detial as endtime,S3.bookday,S3.cname FROM yy.mroom S1, yy.time S2, yy.reserve S3, yy.time S4
  where S1.roomid=S3.roomid and S2.tid=S3.starttimeId and S4.tid=S3.endtimeId
   <isNotEmpty property="bookday" prepend="AND">
    S3.bookday=#bookday#
   </isNotEmpty>
 </select>

 

day的名称换成了bookday,因为day这个名字比较敏感,还是换了的好。

你可能感兴趣的:(There is no READABLE property named 'day' in class 'java.lang.String';You have an error in your SQL)