public static String unreadIndicator(String userId) { String retVal = ""; try { long lUserId = Long.valueOf(userId); String query = "select count(distinct m) from MessageCenter mc join mc.inbox m where m.messageProperties.isRead = ? and mc.owner.id = ?"; long count = MessageCenter.count(query, false, lUserId); retVal = count != 0 ? "*" : ""; } catch (Exception e) { cLogger.error("The user is incorrect '" + userId + "'"); } return retVal; }
public static MessageCenter findByUserId(Long id) { String query = "select mc from MessageCenter mc where mc.owner.id = ?"; MessageCenter messageCenter = MessageCenter.find(query, id).first(); return messageCenter; }