[hibernate-issues] [Hibernate-JIRA] Commented: (HHH-3004) The comment syntax /* */ fails on DB2 for z/OS
Steen Klingenberg (JIRA)
noreply at atlassian.com
Mon Dec 10 07:27:56 EST 2007
[ http://opensource.atlassian.com/projects/hibernate/browse/HHH-3004?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel#action_29120 ]
Steen Klingenberg commented on HHH-3004:
----------------------------------------
Suggestion for an externalization of the wrapping of embedded SQL comments....
Example class: Insert.java... (There are a total of 8 classes needing modifications)
public String toStatementString() {
StringBuffer buf = new StringBuffer( columns.size()*15 + tableName.length() + 10 );
if ( comment != null ) {
//Present 'buggy' statement: buf.append( "/* " ).append( comment ).append( " */ " );
dialect.wrapEmbeddedComment(buf, comment);
}
Dialect.java (default)
public StringBuffer wrapEmbeddedComment(StringBuffer buf, String comment) {
buf.append( "/* " ).append( comment ).append( " */ " );
return buf;
}
DB2390Dialect.java
public StringBuffer wrapEmbeddedComment(StringBuffer buf, String comment) {
buf.append("-- ").append(comment);
return buf;
}
> The comment syntax /* */ fails on DB2 for z/OS
> -----------------------------------------------
>
> Key: HHH-3004
> URL: http://opensource.atlassian.com/projects/hibernate/browse/HHH-3004
> Project: Hibernate3
> Issue Type: Bug
> Affects Versions: 3.2.5
> Environment: Hibernate version 3.2.5
> DB2 for z/OS version 8.2
> Reporter: Steen Klingenberg
> Priority: Minor
>
> if the property use_sql_comments is set to true comments with the syntax /* */ issued in Hibernate SQL statements causes DB2 to fail because the syntax is NOT supported when connecting from a Java application...
> From the DB2 manual - source: DB2 SQL Reference v8 zOS
> Comments in SQL statements: SQL statements can include host language comments or SQL comments. Either type of comment can be specified wherever a space is valid, except within a delimiter token or between the keywords EXEC and SQL. The following rules apply to SQL comments:
> - The two hyphens must be on the same line, not separated by a space.
> - Comments cannot be continued on the next line.
> - Within a statement embedded in a COBOL program, the two hyphens must be preceded by a blank unless they begin a line.
> - In Java, SQL comments are not allowed within embedded Java expressions.
> For "host languages", however, comments following the syntax /* */ are allowed! Host languages include COBOL, C, Rexx... but not Java!
> Would it perhaps be possible to externalize the Java statements creating the comment String into the Dialect class hierarchy ?
> e.g. modifying (in InsertSelect):
> buf.append( "/* " ).append( comment ).append( " */ " );
> It requires the comments to be single-lined though - at least for DB2. Otherwise it doesn't follow above rules!
> Having only experience from the combination Hibernate and DB2 for z/OS and no SQL embedded comments I cannot tell the benefit potential.
--
This message is automatically generated by JIRA.
-
If you think it was sent incorrectly contact one of the administrators: http://opensource.atlassian.com/projects/hibernate/secure/Administrators.jspa
-
For more information on JIRA, see: http://www.atlassian.com/software/jira
More information about the hibernate-issues
mailing list