+"case when ofConParticipant.bareJID=ofMessageArchive.fromJID then ofMessageArchive.fromJID else ofMessageArchive.toJID end as fromJID, "
+"case when ofConParticipant.bareJID=ofMessageArchive.toJID then ofMessageArchive.fromJID else ofMessageArchive.toJID end as toJID "
+"ofConParticipant.bareJID as fromJID, "
+"ofMessageArchive.toJID "
+"FROM ofConversation "
+"INNER JOIN ofConParticipant ON ofConversation.conversationID = ofConParticipant.conversationID "
+"INNER JOIN ofMessageArchive ON ofConParticipant.conversationID = ofMessageArchive.conversationID";
+"INNER JOIN (SELECT conversationID, toJID FROM ofMessageArchive "
+"union all "
+"SELECT conversationID, fromJID as toJID FROM ofMessageArchive) ofMessageArchive ON ofConParticipant.conversationID = ofMessageArchive.conversationID";
// public static final String SELECT_CONVERSATIONS =
@@ -63,7 +65,9 @@ public class JdbcPersistenceManager implements PersistenceManager {
publicstaticfinalStringCOUNT_CONVERSATIONS="SELECT COUNT(DISTINCT ofConversation.conversationID) FROM ofConversation "
+"INNER JOIN ofConParticipant ON ofConversation.conversationID = ofConParticipant.conversationID "
+"INNER JOIN ofMessageArchive ON ofConParticipant.conversationID = ofMessageArchive.conversationID";
+"INNER JOIN (SELECT conversationID, toJID FROM ofMessageArchive "
+"union all "
+"SELECT conversationID, fromJID as toJID FROM ofMessageArchive) ofMessageArchive ON ofConParticipant.conversationID = ofMessageArchive.conversationID";
// public static final String COUNT_CONVERSATIONS =
// "SELECT count(*) FROM archiveConversations AS c";
...
...
@@ -80,7 +84,7 @@ public class JdbcPersistenceManager implements PersistenceManager {