[hibernate-dev] Dialect support for SQL comments.

Daniel Bell daniel.bell at nec.com.au
Sun Jul 6 18:41:21 EDT 2008


Hi,

I have recently tried turning on SQL comments in hibernate 3.2.6.ga.
However, I found that our database (informix 7.31) did not support SQL
where the comment was at the start of the comment. Instead, the comment
needed to be after the SQL. For example:

/* not accepted by informix 7.31*/ select * from systables;

select * from systables /* accepted by informix 7.31*/

Because of this, I have added a method to the Dialect for adding comments:

     /**
      * Add a comment to the SQL string.
      *
      * @param sql          StringBuffer holding the SQL.
      * @param comment      Comment to add to the SQL. May be null.
      */
     public void addCommentToSql(StringBuffer sql, String comment) {
         if (StringHelper.isNotEmpty(comment))
             sql.insert(0, "/* " + comment + " */ ");
     }

Thus, the default implementation provides the same functionality as
before. However, derived Dialects may override this method to add the
comment in a different location.

It is also possible to add additional comments in the derived Dialect.
In our case, we also add the Java thread ID.

I have included a complete patch for this change for hibernate 3.2.6.GA.
Please consider its inclusion in Hibernate.

Thanks,
Daniel.


-------------- next part --------------
A non-text attachment was scrubbed...
Name: hibernate.dialect.patch
Type: text/x-patch
Size: 11553 bytes
Desc: not available
Url : http://lists.jboss.org/pipermail/hibernate-dev/attachments/20080707/6131c470/attachment.bin 


More information about the hibernate-dev mailing list