<mapper namespace="com.xxx.mapper.HospitalMapper">
<resultMap type="Hlist" id="ListMap">
<id column="llistId" property="listId"/>
<result column="listName" property="listName"/>
<result column="listPrice" property="listPrice"/>
<result column="listDetails" property="listDetails"/>
resultMap>
<resultMap type="com.xxx.entity.Hospital_list" id="Hospital_listMap">
<id column="id" property="id"/>
<result column="hlhospitalId" property="hospitalId"/>
<result column="hllistId" property="listId"/>
resultMap>
<resultMap type="Hospital" id="HospitalMap">
<id column="hhospitalId" property="hospitalId"/>
<result column="hospitalLevel" property="hospitalLevel"/>
<result column="hospitalName" property="hospitalName"/>
<result column="hospitalAddress" property="hospitalAddress"/>
<result column="hospitalArea" property="hospitalArea"/>
<result column="hospitalTel" property="hospitalTel"/>
<association property="Hlist" javaType="Hlist" resultMap="ListMap">association>
<association property="com.xxx.entity.Hospital_list" javaType="Hospital_list" resultMap="Hospital_listMap">association>
resultMap>
<select id="selectHospitalByListName" parameterType="String" resultMap="HospitalMap">
select h.* , l.listPrice from hospital h,list l,hospital_list hl
where h.hhospitalId = hl.hlhospitalId
and l.llistId = hl.hllistId
and l.listName = #{listName}
select>
mapper>
报错:
SQL: select h.* , l.listPrice from hospital h,list l,hospital_list hl where h.hhospitalId = hl.hlhospitalId and l.llistId = hl.hllistId and l.listName = ?
; bad SQL grammar []; nested exception is java.sql.SQLSyntaxErrorException: Unknown column 'h.hhospitalId' in 'where clause'
列名 没写错嘛 ?hhospitalId 这个字段有没有?
h.hhospitalId = hl.hlhospitalId