Test.
public Collection selectMessagesByChannel(long channelId) {
Collection messages = new ArrayList();
try {
Connection conn = DAOFactory.getConnection();
try {
PreparedStatement query = conn.prepareStatement(
"select ID from jsub_Messages where ChannelID=?");
query.setLong(1, channelId);
ResultSet rs = query.executeQuery();
while(rs.next()) {
Message message = findByPrimaryKey(rs.getLong("ID"));
messages.add(message);
}
rs.close();
query.close();
} finally {
conn.close();
}
} catch(Exception e) {
Log.error("Couldn't select messages by channel \"" + channelId + "\"", e);
}
return messages;
}
Giving up smoking is the easiest thing in the world. I know because I've done it thousands of times. (c) Mark Twain