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

QueryRaw with "IN" a "GROUP" is not unique, low rate #1013

Open
TpOut opened this issue Feb 7, 2020 · 0 comments
Open

QueryRaw with "IN" a "GROUP" is not unique, low rate #1013

TpOut opened this issue Feb 7, 2020 · 0 comments

Comments

@TpOut
Copy link

TpOut commented Feb 7, 2020

I have search in issues with keyword "queryRaw", but no similar question is find.
scene
I want to get a RecentContact list from a table of chat record.
The chat bean has fields : sn(as id), targetId, srcId, content, time and ...

for once query, i used raw query:

.getChatBeanDao()
                .queryRaw(" WHERE T.TIME IN" +
                        " (" +
                        " SELECT MAX(TIME)" +
                        " FROM CHAT_BEAN" +
                        " WHERE SRC_ID = " + userId +
                        " GROUP BY TARGET_ID" +
                        " )" +
                        " GROUP BY TIME" //time unit is second, maybe has several in one second
                );

problem
Now i find a result log like this:

17:16:40.303
:ChatBean{sn=1, targetId=213, srcId=321, content='some', time=1580979909}
:ChatBean{sn=2, targetId=213, srcId=321, content='😔', time=1580979934}

It is confused.
When i insert these records in local, and query by the same code, result is unique. Which means i can't reproduce it.
more
nearby the code with problem, another query also is right:

queryBuilder
                .where(
                        ChatBeanDao.Properties.SrcId.eq(myUserId),
                        ChatBeanDao.Properties.TargetId.eq(targetUserId),
                )
                .orderDesc(ChatBeanDao.Properties.Time)
                .limit(1)
                .unique();
// result
17:16:40.455
: last unread is ChatBean{sn=2, targetId=213, srcId=321, content='😔', time=1580979934}

The time only passed 150 milliseconds

Could anyone tell me some ways to solve it ? thank you

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

1 participant