[hibernate-issues] [Hibernate-JIRA] Commented: (HHH-2622) Fields quotes must be applied in queries to prevent mix reserved words with fields names
Philippe Marchesseault (JIRA)
noreply at atlassian.com
Fri Jan 23 07:27:38 EST 2009
[ http://opensource.atlassian.com/projects/hibernate/browse/HHH-2622?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel&focusedCommentId=32182#action_32182 ]
Philippe Marchesseault commented on HHH-2622:
---------------------------------------------
Hello,
I am just starting out with hibernate but it seems very promising.. I have a table with fields starting with the character '$', wich (in oracle a least) needs to be inside quoted strings.
I did what David suggested, which got me a bit further but ended up with a quote error in the from clause..
I temporarily fixed it by always putting the field names inside double quotes.
Hope this will get fixed in the next release!
Regards,
Philippe
Index: core/src/main/java/org/hibernate/persister/entity/UnionSubclassEntityPersister.java
===================================================================
--- core/src/main/java/org/hibernate/persister/entity/UnionSubclassEntityPersister.java (revision 15808)
+++ core/src/main/java/org/hibernate/persister/entity/UnionSubclassEntityPersister.java (working copy)
@@ -422,8 +422,9 @@
buf.append( dialect.getSelectClauseNullString(sqlType) )
.append(" as ");
}
+ buf.append('"');
buf.append( col.getName() );
- buf.append(", ");
+ buf.append("\", ");
}
buf.append( clazz.getSubclassId() )
.append(" as clazz_");
> Fields quotes must be applied in queries to prevent mix reserved words with fields names
> ----------------------------------------------------------------------------------------
>
> Key: HHH-2622
> URL: http://opensource.atlassian.com/projects/hibernate/browse/HHH-2622
> Project: Hibernate Core
> Issue Type: Bug
> Components: query-sql
> Affects Versions: 3.2.0 cr1
> Environment: MySQL 4.1.16 Hibernate 3.2 cr1 Fedora Core 4
> Reporter: Igor A Tarasov
> Original Estimate: 1 hour
> Remaining Estimate: 1 hour
>
> Quotes must be appied to fields in queries.
> The environment log is:
> org.hibernate.cfg.Environment Hibernate 3.2 cr1
> org.hibernate.cfg.SettingsFactory RDBMS: MySQL, version: 4.1.16
> org.hibernate.cfg.SettingsFactory JDBC driver: MySQL-AB JDBC Driver, version: mysql-connector-java-3.1.12
> org.hibernate.dialect.Dialect Using dialect: org.hibernate.dialect.MySQLDialect
> I have an entity, named Group:
> @Entity
> public class Group {
> ..
> }
> But, 'GROUP' is the reserved word of MySQL query language.
> Log of hibernate show, that queries is without quotes:
> org.hibernate.persister.entity.AbstractEntityPersister Static SQL for entity: org.dicr.isp.entity.Group
> org.hibernate.persister.entity.AbstractEntityPersister Version select: select id from Group where id =?
> org.hibernate.persister.entity.AbstractEntityPersister Snapshot select: select group_.id, group_.name as name0_, group_.comment as comment0_ from Group group_ where group_.id=?
> org.hibernate.persister.entity.AbstractEntityPersister Insert 0: insert into Group (name, comment, id) values (?, ?, ?)
> org.hibernate.persister.entity.AbstractEntityPersister Update 0: update Group set name=?, comment=? where id=?
> org.hibernate.persister.entity.AbstractEntityPersister Delete 0: delete from Group where id=?
> org.hibernate.persister.entity.AbstractEntityPersister Identity insert: insert into Group (name, comment) values (?, ?)
> And this make a critical error in program logic:
> org.hibernate.tool.hbm2ddl.DatabaseMetadata table not found: Group
> ERROR org.hibernate.tool.hbm2ddl.SchemaUpdate Unsuccessful: create table Group (id bigint not null auto_increment, name varchar(255) not null unique, comment varchar(255), primary key (id))
> ERROR org.hibernate.tool.hbm2ddl.SchemaUpdate You have an error in your SQL syntax; check the manual that corresponds to your MySQL server version for the right syntax to use near 'Group (id bigint not null auto_increment, name varchar(255) not null unique, com' at line 1
> [2006-04-27 23:57:23,895] INFO org.hibernate.tool.hbm2ddl.SchemaUpdate schema update complete
> The query: "create table Group (id bigint ..." is not correct.
> Must be: "create table `Group` (`id` bigint ..."
--
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