Reputation: 11
Really need your help in drafting a request to ORMlite (Android).
There are sql queries (NamedQuery):
select m.contact.stringId, count(m.contact.stringId) from MessageEntityImpl m where m.status = MessageStatus.NEW group by m.contact.stringId"
SELECT m.chat_id, c.stringid, c.fullname, m.message, Max(posted) as postDate from messageentity m inner join (select chat_id, MAX(posted) max_posted from messageentity group by chat_id) max_posted_date ON m.chat_id = max_posted_date.chat_id and posted = max_posted_date.max_posted inner join contactentity c on c.ID = m.contact_id group by m.chat_id, c.stringid, c.fullname, m.message order by postDate desc
Upvotes: 1
Views: 115
Reputation: 1544
You would be better off issuing a raw query to get the results back (as GenericRawResults<T>
) and then traversing through the container to get the your required results. Here's an example -
String sql = "select m.contact.stringId from MessageEntityImpl m where m.status = MessageStatus.NEW group by m.contact.stringId";
ArrayList<String> id = new ArrayList<>();
try
{
GenericRawResults<String[]> grr = getDao().queryRaw(sql);
List<String[]> results = grr.getResults();
for (String[] outArray : results)
id.add (outArray[0]);
}
catch (SQLException sqle)
{
sqle.printStackTrace();
}
getDao() can be a BaseDaoImpl<T,ID>
.
Upvotes: 1