Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

请问关联查询如何设置固定只取部分字段 #106

Closed
forgottor opened this issue Feb 20, 2021 · 4 comments
Closed

请问关联查询如何设置固定只取部分字段 #106

forgottor opened this issue Feb 20, 2021 · 4 comments

Comments

@forgottor
Copy link

forgottor commented Feb 20, 2021

 SELECT * FROM `sys_user` WHERE user_id in (148,149,150)    

目前只想取 select user_name, 用@transient无效

 meeMeeting = MeeMeeting.queryFirst("mee_id = ?",
                     new Relationship[]{ MeeMeeting.HAS_MANY_MEE_CHATS,
                             MeeMeeting.HAS_MANY_SYS_FILE_INFOS,
                             MeeMeeting.HAS_MANY_MEE_JOINS,
                             MeeMeeting.HAS_MANY_MEE_VOTE_LIST,
                             **MeeMeeting.HAS_ONE_MAIN_USERS**
                     },
                     meeId);

    @Transient
    private String userName;
@catchex
Copy link
Member

catchex commented Feb 20, 2021

你好,这样的Case 应该属于自定义查询,基于Model 的查询,无法匹配不同的场景,进行不同的Projection, 你可以通过Select 类,自己构造Projection.

@forgottor
Copy link
Author

请问rawAttributes 这个数据怎么隐藏,返回数据的时候全部取出来了

@catchex
Copy link
Member

catchex commented Feb 22, 2021

因为SQL 在Projection 时出现的字段,在Model 不一定都定义,例如:

select count(*) as user_count from users

user_count 字段在User 中未定义,它就会出现在rawAttributes 中,

@forgottor
Copy link
Author

明白了谢谢

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants