-->
These old forums are deprecated now and set to read-only. We are waiting for you on our new forums!
More modern, Discourse-based and with GitHub/Google/Twitter authentication built-in.

All times are UTC - 5 hours [ DST ]



Forum locked This topic is locked, you cannot edit posts or make further replies.  [ 5 posts ] 
Author Message
 Post subject: Hibernate using reserved word Group with MySQL dialect
PostPosted: Thu Oct 28, 2004 11:33 am 
Newbie

Joined: Fri Aug 13, 2004 11:41 am
Posts: 9
Hibernate version:

2.1.6

Mapping documents:

<?xml version="1.0"?>
<!DOCTYPE hibernate-mapping PUBLIC "-//Hibernate/Hibernate Mapping DTD//EN" "http://hibernate.sourceforge.net/hibernate-mapping-2.0.dtd">

<hibernate-mapping>
<class name="model.group.Group" table="GROUPING">
<id name="id" column="ID" type="long" unsaved-value="-1">
<generator class="native"/>
</id>
<property name="name" column="NAME" type="string" not-null="true" unique="true"/>
<property name="active" column="ACTIVE" type="boolean" />
<property name="description" column="DESCRIPTION" type="string"/>
<property name="conception" column="CONCEPTION" type="timestamp"/>
<property name="lastModified" column="LASTMODIFIED" type="timestamp"/>

</class>
</hibernate-mapping>

Full stack trace of any exception that occurs:

[Syntax error or access violation, message from server: "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"]
java.sql.SQLException: Syntax error or access violation, message from server: "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"

Name and version of the database you are using:

4.0.18

The generated SQL (show_sql=true):

create table GROUP (ID bigint not null auto_increment, NAME varchar(255) not null unique, ACTIVE bit, DESCRIPTION varchar(255), CONCEPTION datetime, LASTMODIFIED datetime, CREATORID bigint, primary key (ID))

Problem:

The generated SQL for the MySQL database is using a reserved word, 'Group'. Is this valid? Is there a way to work around this? I also have problem with reference objects who maintain a link to this object as a one-to-one relationship with the generated SQL attempting to use the column name 'group'.


Top
 Profile  
 
 Post subject:
PostPosted: Thu Oct 28, 2004 11:34 am 
Hibernate Team
Hibernate Team

Joined: Tue Sep 09, 2003 2:10 pm
Posts: 3246
Location: Passau, Germany
I can hardly belive Hibernate ignores the tablename you specify. Check if you are actually loading the correct mapping files.


Top
 Profile  
 
 Post subject: Validated Information
PostPosted: Thu Oct 28, 2004 12:06 pm 
Newbie

Joined: Fri Aug 13, 2004 11:41 am
Posts: 9
michael wrote:
I can hardly belive Hibernate ignores the tablename you specify. Check if you are actually loading the correct mapping files.


Validated the correct mapping file is being loaded with the table attribute as GROUP.

Also checked out the hibernate.properties file which has the following:

hibernate.dialect=net.sf.hibernate.dialect.MySQLDialect


Top
 Profile  
 
 Post subject:
PostPosted: Thu Oct 28, 2004 12:10 pm 
Newbie

Joined: Fri Aug 13, 2004 11:41 am
Posts: 9
michael wrote:
I can hardly belive Hibernate ignores the tablename you specify. Check if you are actually loading the correct mapping files.


Reading this a second time, I do not want hibernate to ignore the table name... the table name is GROUP which is a reserved word with MySQL.

Shouldn't hibernate attempt to map around this for the dialect?


Top
 Profile  
 
 Post subject:
PostPosted: Thu Oct 28, 2004 12:13 pm 
Hibernate Team
Hibernate Team

Joined: Tue Aug 26, 2003 12:50 pm
Posts: 5130
Location: Melbourne, Australia
No, you should use a quoted identifier.


Top
 Profile  
 
Display posts from previous:  Sort by  
Forum locked This topic is locked, you cannot edit posts or make further replies.  [ 5 posts ] 

All times are UTC - 5 hours [ DST ]


You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum

Search for:
© Copyright 2014, Red Hat Inc. All rights reserved. JBoss and Hibernate are registered trademarks and servicemarks of Red Hat, Inc.