/** * Get the comment for the given database object if one exists, or null if * not. * * @param object the database object * @return the comment or null */ public Comment findComment(DbObject object) { if (object.getType() == DbObjectType.COMMENT) { return null; } String key = Comment.getKey(object); return comments.get(key); }
@Override public String getCreateSQL() { StringBuilder buff = new StringBuilder("COMMENT ON "); buff.append(getTypeName(objectType)).append(' ').append(objectName).append(" IS "); if (commentText == null) { buff.append("NULL"); } else { buff.append(StringUtils.quoteStringSQL(commentText)); } return buff.toString(); }
comment = new Comment(db, id, object); comment.setCommentText(text); db.addDatabaseObject(session, comment); db.removeDatabaseObject(session, comment); } else { comment.setCommentText(text); db.updateMeta(session, comment);
add(comment.getCreateSQL(), false);
/** * Get the comment key name for the given database object. This key name is * used internally to associate the comment to the object. * * @param obj the object * @return the key name */ public static String getKey(DbObject obj) { return getTypeName(obj.getType()) + " " + obj.getSQL(); }
public Comment(Database database, int id, DbObject obj) { super(database, id, getKey(obj), Trace.DATABASE); this.objectType = obj.getType(); this.objectName = obj.getSQL(); }