]
Diego Pires Plentz updated HHH-2622:
------------------------------------
Summary: Fields quotes must be applied in queries to prevent mix reserved words
with fields names (was: CLONE -Fields quetes must be applied in queries to prevent mix
reserved words with fields names)
Component/s: query-sql
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: Hibernate3
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: