Sorry, a typo! It is ssn.Save(s);
And it's now working. On Sep 5, 4:56 am, Fabio Maulo <[email protected]> wrote: > ssn.Save(ssn); > Are you serious or its a joke ? > > 2009/9/4 Joksim <[email protected]> > > > > > > > > > Hi, i'm a newbie and i'm using nhiberante. > > i have a database with 5-6 tables. I map the tables and corrected all > > of the notisable errors. > > > I have this error when I run the application: > > > Unknown entity class: NHibernate.Impl.SessionImpl > > > the code that creates the error: > > > using System; > > using System.Collections; > > using System.Configuration; > > using System.Data; > > using System.Linq; > > using System.Web; > > using System.Web.Security; > > using System.Web.UI; > > using System.Web.UI.HtmlControls; > > using System.Web.UI.WebControls; > > using System.Web.UI.WebControls.WebParts; > > using System.Xml.Linq; > > > using NHibernate; > > using MRI_CBIR_DAL.ClassMappings; > > > namespace MRI_CBIR > > { > > public partial class _Default : System.Web.UI.Page > > { > > protected void Page_Load(object sender, EventArgs e) > > { > > ISession ssn = ProjectConfiguration.GetCurrentSession(); > > > ITransaction tx = ssn.BeginTransaction(); > > > DescriptorType s = new DescriptorType(); > > > s.Type = "random"; > > > ssn.Save(ssn); > > tx.Commit(); > > > ProjectConfiguration.CloseSession(); > > } > > } > > } > > > The error is generated on: ssn.Save(ssn); > > This happens for several tables. > > > The *.cs file looks like this: > > > using System; > > using System.Collections.Generic; > > using System.Text; > > > using NHibernate; > > using System.Collections; > > > namespace MRI_CBIR_DAL.ClassMappings > > { > > /// <summary> > > /// Class representing the Type of Descriptor record > > /// mapped to the table DESCRIPTOR_TYPE > > /// </summary> > > public class DescriptorType > > { > > /// <summary> > > /// The Id of the descriptorType > > /// </summary> > > private long id; > > > /// <summary> > > /// The value of the descriptor Type > > /// </summary> > > private string type; > > > /// <summary> > > /// The Descriptors of of the type > > /// </summary> > > private IDictionary descriptors; > > > /// <summary> > > /// Empty constructor for the NHibernate mapping > > /// </summary> > > public DescriptorType() > > { } > > > /// <summary> > > /// Getter and Setter for the Id > > /// </summary> > > public virtual long Id > > { > > set { id = value; } > > get { return id; } > > } > > > /// <summary> > > /// Getter and Setter for the descriptor Type > > /// </summary> > > public virtual string Type > > { > > set { type = value; } > > get { return type; } > > } > > > /// <summary> > > /// Getter and Setter for the descriptors > > /// </summary> > > public virtual IDictionary Descriptors > > { > > set { descriptors = value; } > > get { return descriptors; } > > } > > } > > } > > > and the hbm.xml is: > > > <?xml version="1.0" encoding="utf-8" ?> > > <hibernate-mapping xmlns="urn:nhibernate-mapping-2.2" > > namespace="MRI_CBIR_DAL.ClassMappings" assembly="MRI_CBIR_DAL"> > > > <class name="DescriptorType" table="DESCRIPTOR_TYPE"> > > > <id name="Id"> > > <column name="ID" not-null="true"/> > > <generator class="native" /> > > </id> > > > <property name="Type"> > > <column name="TYPE" not-null="true"/> > > </property> > > > <set name="Descriptors"> > > <key column="descriptorID" /> > > <one-to-many class="MRI_CBIR_DAL.ClassMappings.Descriptor, > > MRI_CBIR_DAL" /> > > </set> > > > </class> > > > </hibernate-mapping> > > > The table in the database is simpe : two fields Id and Type and looks > > like this: > > > IF NOT EXISTS (SELECT * FROM sys.objects WHERE object_id = OBJECT_ID > > (N'[dbo].[DESCRIPTOR]') AND type in (N'U')) > > BEGIN > > CREATE TABLE [dbo].[DESCRIPTOR]( > > [ID] [int] IDENTITY(1,1) NOT NULL, > > [VALUE] [nvarchar](max) NOT NULL, > > [IMAGE_ID] [int] NOT NULL, > > [DESC_TYPE_ID] [int] NOT NULL, > > CONSTRAINT [PK_DESCRIPTOR] PRIMARY KEY CLUSTERED > > ( > > [ID] ASC > > )WITH (PAD_INDEX = OFF, IGNORE_DUP_KEY = OFF) ON [PRIMARY] > > ) ON [PRIMARY] > > END > > > I have two projects, one for the presentation layer and one is the > > data layer. > > The hibernate.cfg.xml is in the root of the data access layer project > > and looks like this: > > > <?xml version="1.0" encoding="utf-8" ?> > > <configuration> > > > <configSections> > > <section name="hibernate-configuration" > > > type="NHibernate.Cfg.ConfigurationSectionHandler, NHibernate" /> > > <!-- <section name="log4net" > > > type="log4net.Config.Log4NetConfigurationSectionHandler,log4net" / > > > --> > > </configSections> > > > <hibernate-configuration xmlns="urn:nhibernate-configuration-2.2"> > > <session-factory> > > <property name="dialect">NHibernate.Dialect.MsSql2005Dialect</ > > property> > > <property > > name="connection.driver_class">NHibernate.Driver.SqlClientDriver</ > > property> > > <property > > name="connection.provider">NHibernate.Connection.DriverConnectionProvider</ > > property> > > <!--<property name="connection.connection_string">Server= > > (local);database=MRI_DATABASE-ica;Integrated Security=SSPI</property>-- > > > <property name="connection.connection_string">Data Source=DAEMIAN > > \SQLEXPRESS;Initial Catalog=MRI_DATABASE-ica;Integrated Security=True</ > > property> > > <property name="show_sql">true</property> > > <!--<mapping assembly="MRI_CBIR_DAL" /> --> > > > <mapping > > resource="MRI_CBIR_DAL.ClassMappings.Descriptor.hbm.xml" > > assembly="MRI_CBIR_DAL" /> > > <mapping > > resource="MRI_CBIR_DAL.ClassMappings.DescriptorType.hbm.xml" > > assembly="MRI_CBIR_DAL" /> > > <mapping resource="MRI_CBIR_DAL.ClassMappings.MRIClass.hbm.xml" > > assembly="MRI_CBIR_DAL" /> > > <mapping > > resource="MRI_CBIR_DAL.ClassMappings.MRImageBase.hbm.xml" > > assembly="MRI_CBIR_DAL" /> > > <mapping resource="MRI_CBIR_DAL.ClassMappings.MRISet.hbm.xml" > > assembly="MRI_CBIR_DAL" /> > > <mapping > > resource="MRI_CBIR_DAL.ClassMappings.SimilarityMeasure.hbm.xml" > > assembly="MRI_CBIR_DAL" /> > > <mapping > > resource="MRI_CBIR_DAL.ClassMappings.SimilarityMeasureType.hbm.xml" > > assembly="MRI_CBIR_DAL" /> > > > </session-factory> > > </hibernate-configuration> > > > <log4net> > > <appender name="ConsoleAppender" > > type="log4net.Appender.ConsoleAppender, log4net"> > > <layout type="log4net.Layout.PatternLayout, log4net"> > > <param name="ConversionPattern" value="%m" /> > > </layout> > > </appender> > > <root> > > <priority value="WARN" /> > > <appender-ref ref="ConsoleAppender" /> > > </root> > > </log4net> > > > </configuration> > > > I have embedded all the hbm.xml files. > > > can you tell me what is the problem?!?!? > > > Thanks in advance, > > > Joksim > > -- > Fabio Maulo --~--~---------~--~----~------------~-------~--~----~ You received this message because you are subscribed to the Google Groups "nhusers" group. To post to this group, send email to [email protected] To unsubscribe from this group, send email to [email protected] For more options, visit this group at http://groups.google.com/group/nhusers?hl=en -~----------~----~----~----~------~----~------~--~---
