-->
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.  [ 4 posts ] 
Author Message
 Post subject: Column 'ReservedWord' does not belong to table ReservedWords
PostPosted: Thu Jun 18, 2009 6:28 pm 
Newbie

Joined: Thu Jun 18, 2009 6:07 pm
Posts: 1
I am getting a weird error when using NHibernate. And I don't know what is causing this error.
I am new to the whole Visual Studio and NHibernate, but not to Hibernate. I used Hibernate in the past in Java projects.

Any help would be appreciated in pointing me where my error is.

I am using Visual Studio 2008 SP1 with Mysql 5.1.

Below is the code I am using.


Main program:
Code:
Configuration cfg = new Configuration();
cfg.Configure(Assembly.GetExecutingAssembly(), "K.TestCase.Database.hibernate.cfg.xml");

ISessionFactory factory = cfg.BuildSessionFactory(); <== Here the error is thrown
ISession session = factory.OpenSession();
ITransaction transaction = session.BeginTransaction();


hibernate.cfg.xml
Code:
<?xml version="1.0" encoding="utf-8" ?>
<hibernate-configuration xmlns="urn:nhibernate-configuration-2.2">
  <session-factory>
    <property name="connection.provider">
      NHibernate.Connection.DriverConnectionProvider
    </property>
    <property name="connection.driver_class">
      NHibernate.Driver.MySqlDataDriver
    </property>
    <property name="connection.connection_string">
      Server=localhost;Database=K;User ID=K;Password=K;
    </property>
    <property name="dialect">
      NHibernate.Dialect.MySQL5Dialect
    </property>
    <property name="proxyfactory.factory_class">
      NHibernate.ByteCode.Castle.ProxyFactoryFactory, NHibernate.ByteCode.Castle
    </property>
    <!-- mapping files -->
    <mapping resource="K.TestCase.Database.HibernateClass.hbm.xml" assembly="K.TestCase.Database" />
  </session-factory>
</hibernate-configuration>


HibernateClass.cs
Code:
namespace K.TestCase.Database
{
    class HibernateClass
    {
        private int id;
        private string text1;
        private string text2;

        public virtual int Id
        {
            get { return id; }
            set { id = value; }
        }

        public virtual string Text1
        {
            get { return text1; }
            set { text1 = value; }
        }

        public virtual string Text2
        {
            get { return text2; }
            set { text2 = value; }
        }

        public override string ToString()
        {
            return this.id + " " + this.text1 + " " + this.text2;
        }

    }
}


HibernateClass.hbm.xml
Code:
<?xml version="1.0" encoding="utf-8" ?>
<hibernate-mapping xmlns="urn:nhibernate-mapping-2.2">
  <class name="K.TestCase.Database.HibernateClass, K.TestCase.Database" table="hibernate">
    <id name="Id" column="id" type="Int32">
      <generator class="identity" />
    </id>
    <property name="Text1" column="text1" type="String" length="50" />
    <property name="Text2" column="text2" type="String" length="50"/>
  </class>
</hibernate-mapping>


Table:
Code:
DROP TABLE IF EXISTS `k`.`hibernate`;
CREATE TABLE  `k`.`hibernate` (
  `id` int(10) unsigned NOT NULL AUTO_INCREMENT,
  `text1` text NOT NULL,
  `text2` text NOT NULL,
  PRIMARY KEY (`id`)
) ENGINE=InnoDB DEFAULT CHARSET=latin1;


Top
 Profile  
 
 Post subject: Re: Column 'ReservedWord' does not belong to table ReservedWords
PostPosted: Fri Jul 03, 2009 12:12 am 
Newbie

Joined: Fri Jul 03, 2009 12:08 am
Posts: 1
I've had similar problem. I couldn't fix it , so i rolled back to use the previous release of NHibernate
NHibernate-2.0.1.GA at http://sourceforge.net/projects/nhibernate/files/


Top
 Profile  
 
 Post subject: Re: Column 'ReservedWord' does not belong to table ReservedWords
PostPosted: Wed Jul 22, 2009 9:43 am 
Newbie

Joined: Wed Jul 22, 2009 9:24 am
Posts: 1
Greetings.

Just add following line to configuration file to <session-factory> section.

<property name="hbm2ddl.keywords">none</property>

However this fix might cause unexpected problems. :|

Best regards.

_________________
Infinite diversity in infinite combination


Top
 Profile  
 
 Post subject: Re: Column 'ReservedWord' does not belong to table ReservedWords
PostPosted: Fri Oct 02, 2009 3:17 pm 
Newbie

Joined: Fri Oct 02, 2009 2:54 pm
Posts: 3
When using fluent nhibernate use .ExposeConfiguration(c => c.Properties.Add("hbm2ddl.keywords", "none"))
see also http://stackoverflow.com/questions/1061 ... long-to-ta


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