Skip to content

希望在多表关联查询中自定义VO能支持单字段和整个VO对象的赋值 #472

@yang2048

Description

@yang2048
@Data
@FieldNameConstants
public class ConversationVO {
    private String id;
    private String name;
    private LocalDateTime createTime;
    ......

    private ChannelEntity channelInfo;
    private SysUserEntity userInfo;
}

easyEntityQuery.queryable(ConversationEntity::class.java)
            .innerJoin(ChannelEntity::class.java) { t, t1 ->
                t.channelId.eq(t1.id)
            }
            .leftJoin(ChannelMemberEntity::class.java) { t, t1, t2 ->
                t.channelId.eq(t2.channelId); t2.userId.ne(query.userId)
            }
            .leftJoin(SysUserEntity::class.java) { t, t1, t2, t3 ->
                t2.userId.eq(t3.id)
            }
            .select { t, t1, t2, t3 -> Select.of( ConversationVO::class.java,
                t.FETCHER.allFields(),
                t1.channelType.`as`(ConversationVO::channelInfo), //查询t1单个字段
                t3.FETCHER.allFields().`as`(ConversationVO::userInfo) //查询t3全部
            ) }
            .toPageResult(basePager)

用结构化如果表关联比较深就会很乱,如果能类似于以上select 中将整个t3表的结果直接赋值于userInfo对象中,这样自定义VO查询会更加灵活,而不用依靠关系型结构化实体

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type
    No fields configured for issues without a type.

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions