-->
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.  [ 6 posts ] 
Author Message
 Post subject: Syntax error while exporting schema
PostPosted: Sat May 06, 2006 10:02 am 
Newbie

Joined: Tue Apr 04, 2006 4:47 am
Posts: 18
Hi,

I was in the process of exporting a schema. However it gave me an error like this during runtime:

"Syntax error near the keyword 'Group'"

Any further details were not provided and I was unable to extract further info from the stackrace. I can't even tell if it refers to a class or a mapping file.

As far as I am able to tell the mapping files look ok.

Group.hbm.xml:
Code:
<hibernate-mapping xmlns="urn:nhibernate-mapping-2.0" assembly="Logic"
  namespace="SymphonyCMS.Logic">
  <class name="Group" table="Group" lazy="true">
    <id name="_id" column="id" access="field" type="Int32">
      <generator class="native" />
    </id>
    <property name="_name" column="name" type="String" access="field"
              not-null="true" unique="true" />
    <set name="_userMembers" table="User_Group"  access="field" lazy="true">
      <key column="group_id" />
      <many-to-many class="User" column="user_id" />
    </set>
    <set name="_permissions" table="Permission" access="field" lazy="true" cascade="all">
      <key column="group_id" />
      <one-to-many class="Permission" />
    </set>
  </class>
</hibernate-mapping>


User.hbm.xml:
Code:
<hibernate-mapping xmlns="urn:nhibernate-mapping-2.0" assembly="Logic"
  namespace="SymphonyCMS.Logic">
  <class name="User" table="User" lazy="true">
    <id name="_id" column="id" type="Int32" access="field">
      <generator class="native" />
    </id>
    <property name="_userName" column="userName" type="String" access="field"
              not-null="true" unique="true" />
    <property name="_password" column="password" type="String" access="field" />
    <property name="_firstName" column="firstName" type="String" access="field" />
    <property name="_lastName" column="lastName" type="String" access="field" />
    <property name="_emailAddress" column="emailAddress" type="String" access="field" />
    <set name="_groups" table="User_Group"  access="field" lazy="true">
      <key column="user_id" />
      <many-to-many class="Group" column="group_id" />
    </set>
  </class>
</hibernate-mapping>


Permission.hbm.xml:
Code:
<hibernate-mapping xmlns="urn:nhibernate-mapping-2.0" assembly="Logic"
  namespace="SymphonyCMS.Logic">
  <class name="Permission" table="Permission" lazy="true">
    <id name="_id" column="id" type="Int32" access="field">
      <generator class="native" />
    </id>
    <many-to-one name="_group" column="group_id" access="field" />
    <many-to-one name="_role" column="role_id" access="field" />
  </class>
</hibernate-mapping>


These are all the mapping files that have something to do with groups. Hope anyone will be able to enlighten me.

Regards,

Dirk Louwers


Top
 Profile  
 
 Post subject:
PostPosted: Sat May 06, 2006 11:02 am 
Regular
Regular

Joined: Mon Mar 20, 2006 10:49 pm
Posts: 59
GROUP is a SQL keyword. The DDL generator will need to escape the table name, e.g. [Group] using SQL Server.

I'm too much of a newbie to know how to do this (or even if its possible).

Mike

_________________
Mike Abraham


Top
 Profile  
 
 Post subject:
PostPosted: Sat May 06, 2006 11:03 am 
Regular
Regular

Joined: Mon Mar 20, 2006 10:49 pm
Posts: 59
GROUP is a SQL keyword. The DDL generator will need to escape the table name, e.g. [Group] using SQL Server.

I'm too much of a newbie to know how to do this (or even if its possible).

Mike

_________________
Mike Abraham


Top
 Profile  
 
 Post subject:
PostPosted: Sat May 06, 2006 10:11 pm 
Newbie

Joined: Tue Apr 04, 2006 4:47 am
Posts: 18
Ok thank you very much. Replacing the Group and User keywords with non keywords helped. Still wondering how to quote names like that so that they will be quoted in the query as well though. Anyone know how?


Top
 Profile  
 
 Post subject:
PostPosted: Sun May 07, 2006 3:48 am 
Expert
Expert

Joined: Tue Aug 23, 2005 5:52 am
Posts: 335
Hi Dirk,

Using back ticks (`) around keywords should solve this problem; they will be replaced at runtime with the appropriate characters in the generated SQL based on your dialect (square brackets ([]) in the SQL 2000 dialect, for example).

Cheers,

Symon.


Top
 Profile  
 
 Post subject:
PostPosted: Sun May 07, 2006 9:45 am 
Newbie

Joined: Tue Apr 04, 2006 4:47 am
Posts: 18
Thank you, that worked like a charm.


Top
 Profile  
 
Display posts from previous:  Sort by  
Forum locked This topic is locked, you cannot edit posts or make further replies.  [ 6 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.