Java Mailing List Archive

http://www.gg3721.com/

Home » Hibernate Dev List »

[hibernate-dev] Dialect support for SQL comments.

Daniel Bell

2008-07-06

Replies: Find Java Web Hosting

Author LoginPost Reply
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.



Attachment: hibernate.dialect.patch (zipped)
_______________________________________________
hibernate-dev mailing list
hibernate-dev@(protected)
https://lists.jboss.org/mailman/listinfo/hibernate-dev
©2008 gg3721.com - Jax Systems, LLC, U.S.A.