1、SQL MAPPER
<resultMap id="AllResultMap" type="Submsg">
<id property="id" column="id" />
<result property="name" column="name" />
<collection property="roles" ofType="Role" >
<id column="role_id" property="id" />
<result column="role_name" property="name"/>
</collection>
</resultMap>
<select id="queryList" parameterType="Submsg" resultMap="AllResultMap">
select t.*,
r.id as role_id,r.name as role_name
from submsg as t
left outer join submsg_sp p on t.id = p.submsg_id
left outer join sys_role r on p.receive_id = r.id and p.receive_type='ROLE'
</select>
2、java对象
@Component
public interface SubmsgDao {
List<Submsg> queryList(@Param("po") Submsg ps);
}
@Data
@Table(name ="submsg")
public class Submsg {
@Id
private String id;
private String name;
@Transient
private List<Role> roles;
}
网友评论