I'm executing a named query using jdbcTemplate.queryForList in the following manner:
List<Conversation> conversations = jdbcTemplate.queryForList(
SELECT_ALL_CONVERSATIONS_SQL_FULL,
new Object[] {userId, dateFrom, dateTo});
The SQL query is:
private final String SELECT_ALL_CONVERSATIONS_SQL_FULL =
"select conversation.conversationID, conversation.room, " +
"conversation.isExternal, conversation.startDate, " +
"conversation.lastActivity, conversation.messageCount " +
"from openfire.ofconversation conversation " +
"WHERE conversation.conversationid IN " +
"(SELECT conversation.conversationID " +
"FROM openfire.ofconversation conversation, " +
"openfire.ofconparticipant participant " +
"WHERE conversation.conversationID = participant.conversationID " +
"AND participant.bareJID LIKE ? " +
"AND conversation.startDate between ? AND ?)";
But when extracting the content of the list in the following manner:
for (Conversation conversation : conversations) {
builder.append(conversation.getId());
builder.append(",");
builder.append(conversation.getRoom());
builder.append(",");
builder.append(conversation.getIsExternal());
builder.append(",");
builder.append(conversation.getStartDate());
builder.append(",");
builder.append(conversation.getEndDate());
builder.append(",");
builder.append(conversation.getMsgCount());
out.write(builder.toString());
}
I get an error:
java.util.LinkedHashMap cannot be cast to net.org.messagehistory.model.Conversation
How do I convert this linkedMap into the desired Object??
Thanks
See Question&Answers more detail:
os 与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…