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