我有一个如下所示的resultSet:
library(dplyr)
pulse %>%
mutate(first = if_else(is.na(Rt1), Rt2, Rt1))
pulse <- mutate(pulse, cd1 = Rt2 - if_else(is.na(Rt1), Rt2, Rt1))
映射到此resultSet的select查询是:
<resultMap type="User" id="userMap">
<id column="id" property="id" />
<result property="userName" column="user_name" />
<result property="enabled" column="enabled" />
<result property="firstName" column="first_name" />
<result property="lastName" column="last_name" />
<result property="email" column="email" />
<result property="password" column="user_password" />
<result property="passwordSalt" column="user_password_salt" />
<result property="lastLogin" column="last_login_time" />
<result property="creationTime" column="creation_time" />
<result property="lastEdit" column="last_edit_time" />
<result property="validTill" column="valid_till" />
<collection property="roles" javaType="ArrayList" ofType="Role" column="id">
<id property="id" column="role_id" />
<result property="name" column="role_name" />
<result property="description" column="role_description" />
</collection>
</resultMap>
视图查询是这样的:
<select id="getWithRole" resultMap="userMap" parameterType="User">
SELECT * FROM view_boss_user_role
<trim prefix="WHERE" prefixOverrides="AND | OR ">
<if test="id != null">id = #{id}</if>
<if test="userName != null">AND user_name = #{userName}</if>
<if test="firstName != null">AND first_name = #{firstName}</if>
<if test="lastName != null">AND last_name = #{lastName}</if>
<if test="email != null">AND email = #{email}</if>
</trim>
</select>
产生的结果类似于:
CREATE OR REPLACE VIEW public.view_boss_user_role(
id,
user_name,
enabled,
first_name,
last_name,
email,
user_password,
user_password_salt,
last_login_time,
creation_time,
last_edit_time,
valid_till,
role_id,
role_name,
role_description)
AS
SELECT bu.id,
bu.user_name,
bu.enabled,
bu.first_name,
bu.last_name,
bu.email,
bu.user_password,
bu.user_password_salt,
bu.last_login_time,
bu.creation_time,
bu.last_edit_time,
bu.valid_till,
br.id AS role_id,
br.name AS role_name,
br.description AS role_description
FROM boss_user bu
LEFT JOIN boss_role_user_map ru ON ru.user_id = bu.id
LEFT JOIN boss_role br ON ru.role_id = br.id;
但是,当我尝试从此结果图中获取角色列表时,它会将其显示为空白。我不知道自己做错了什么。文档要么不容易区分这个收集标记的情况,要么我没有把它弄好。
由于某些原因,我无法对resultMap定义进行单一更改,但可以更改查询。并且保证resultMap定义是正确的。
需要专家指导