sql.append("from bundle2collection ");
sql.append("where bundle_id=? ");
sql.append("and collection_id=? ");
}
QueryParser qp = new QueryParser(sql.toString());
qp.addPreparedStmtElementDefinition(childId);
qp.addPreparedStmtElementDefinition(parentId);
if (connection != null) {
qp.setConnection(connection);
}
int preInsertCheck = -1;
try {
Configuration.getConnectionPool().executeQuery(qp);
preInsertCheck = qp.getResult(Integer.class, "theCount");
} catch (DataTypeMismatchException e) {
Logger.error("Couldn't create an int out of an integer "
+ "db result. Shouldn't happen, but...", e);
}
if (preInsertCheck == 0) {
sql = new StringBuffer();
if (parentType == ContentType.COMMUNITY) {
sql.append("insert into bundle2community ");
sql.append("(bundle_id, community_id) values (?, ?) ");
} else if (parentType == ContentType.COLLECTION) {
sql.append("insert into bundle2collection ");
sql.append("(bundle_id, collection_id) values (?, ?) ");
}
qp.clearForNewSQL();
qp.setSql(sql.toString());
qp.addPreparedStmtElementDefinition(childId);
qp.addPreparedStmtElementDefinition(parentId);
Configuration.getConnectionPool().executeInsertOrUpdate(qp);
}
}