I am new to nHibernate, so hopefully this is not to much of a newb question. I am trying to get my first C# .Net3.5 nHibernate Oracle 10g application running. To get started I have set it to do something pretty simple, at least I thought.
Here is my hibernate.cfg.xml file: <?xml version="1.0" encoding="utf-8" ?> <hibernate-configuration xmlns="urn:nhibernate-configuration-2.2">
<!-- an ISessionFactory instance --> <session-factory>
<!-- properties --> <property name="connection.provider">NHibernate.Connection.D riverConnectionProvider</property> <property name="connection.driver_class">NHibernate.Driver.O racleDataClientDriver</property> <property name="connection.connection_string">User ID=id;Password=pw;Data Source=requ;Pooling=true;Connection Lifetime=180;Connection Timeout=30;Min Pool Size=2;Max Pool Size=10;Incr Pool Size=2;</property> <property name="dialect">NHibernate.Dialect.Oracle10gDialect </ property> <property name="show_sql">true</property>
<!-- mapping files --> <mapping resource="DataLayer.Mappings.Audit.hbm.xml" assembly="DataLayer" /> </session-factory>
</hibernate-configuration>
Audit.hbm.xml: <?xml version="1.0" encoding="utf-8" ?> <hibernate-mapping xmlns="urn:nhibernate-mapping-2.2" assembly="DataLayer" namespace="DataLayer"> <class name="DataLayer.DAO.Audit, DataLayer" table="ws_audit"> <id name="id" type="int" column="ws_audit_id"> <generator class="native" /> </id> <property name="originalXml" type="string" column="original_xml"/> </class> </hibernate-mapping>
The class is pretty simple: using System; using System.Collections.Generic; using System.Text;
namespace DataLayer.DAO { public class Audit { private int id;
public int Id { get { return id; } set { id = value; } }
private string originalXml;
public string OriginalXml { get { return originalXml; } set { originalXml = value; }
} } }
And I have a simple aspx, here is the code-behind: Audit auditInstance;
protected void Page_Load(object sender, EventArgs e) { if (!Page.IsPostBack) { IList auditList; ISessionFactory factory = new NHibernate.Cfg.Configuration().Configure().BuildSe ssionFactory(); using (ISession session = factory.OpenSession()) { ICriteria ac = session.CreateCriteria(typeof(Audit)); auditList = ac.List(); session.Close(); }
factory.Close(); auditInstance = (Audit)auditList[0]; txtId.Text = auditInstance.Id.ToString(); txtOrigXml.Text = auditInstance.OriginalXml;
} }
When I attempt to run I get: Could not compile the mapping document: DataLayer.Mappings.Audit.hbm.xml
And my error page looks like: Server Error in '/' Application. --------------------------------------------------------------------------------
Could not load type NHibernate.Dialect.Oracle10gDialect. Possible cause: no assembly name specified. Description: An unhandled exception occurred during the execution of the current web request. Please review the stack trace for more information about the error and where it originated in the code.
Exception Details: System.TypeLoadException: Could not load type NHibernate.Dialect.Oracle10gDialect. Possible cause: no assembly name specified.
Source Error:
Line 20: { Line 21: IList auditList; Line 22: ISessionFactory factory = new NHibernate.Cfg.Configuration().Configure().BuildSe ssionFactory(); Line 23: using (ISession session = factory.OpenSession()) Line 24: {
Source File: C:\temp\UsingSpring\UsingSpring\TestAudit.aspx.cs Line: 22
Stack Trace:
[TypeLoadException: Could not load type NHibernate.Dialect.Oracle10gDialect. Possible cause: no assembly name specified.] NHibernate.Util.ReflectHelper.TypeFromAssembly(Ass emblyQualifiedTypeName name, Boolean throwOnError) +653 NHibernate.Util.ReflectHelper.ClassForName(String name) +70 NHibernate.Dialect.Dialect.InstantiateDialect(Stri ng dialectName) +65
[HibernateException: Could not instantiate dialect class NHibernate.Dialect.Oracle10gDialect] NHibernate.Dialect.Dialect.InstantiateDialect(Stri ng dialectName) +199 NHibernate.Dialect.Dialect.GetDialect(IDictionary` 2 props) +233 NHibernate.Cfg.Configuration.AddValidatedDocument( NamedXmlDocument doc) +163
[MappingException: Could not compile the mapping document: DataLayer.Mappings.Audit.hbm.xml] NHibernate.Cfg.Configuration.LogAndThrow(Exception exception) +107 NHibernate.Cfg.Configuration.AddValidatedDocument( NamedXmlDocument doc) +369 NHibernate.Cfg.Configuration.ProcessMappingsQueue( ) +51 NHibernate.Cfg.Configuration.AddDocumentThroughQue ue(NamedXmlDocument document) +53 NHibernate.Cfg.Configuration.AddXmlReader(XmlReade r hbmReader, String name) +72 NHibernate.Cfg.Configuration.AddInputStream(Stream xmlInputStream, String name) +159 NHibernate.Cfg.Configuration.AddResource(String path, Assembly assembly) +268 NHibernate.Cfg.Configuration.DoConfigure(IHibernat eConfiguration hc) +993 NHibernate.Cfg.Configuration.Configure(XmlReader textReader) +315 NHibernate.Cfg.Configuration.Configure(String fileName, Boolean ignoreSessionFactoryConfig) +173 NHibernate.Cfg.Configuration.Configure(String fileName) +45 NHibernate.Cfg.Configuration.Configure() +177 UsingSpring.TestAudit.Page_Load(Object sender, EventArgs e) in C:\temp \UsingSpring\UsingSpring\TestAudit.aspx.cs: 22 System.Web.Util.CalliHelper.EventArgFunctionCaller (IntPtr fp, Object o, Object t, EventArgs e) +14 System.Web.Util.CalliEventHandlerDelegateProxy.Cal lback(Object sender, EventArgs e) +35 System.Web.UI.Control.OnLoad(EventArgs e) +99 System.Web.UI.Control.LoadRecursive() +50 System.Web.UI.Page.ProcessRequestMain(Boolean includeStagesBeforeAsyncPoint, Boolean includeStagesAfterAsyncPoint) +627
-------------------------------------------------------------------------------- Version Information: Microsoft .NET Framework Version:2.0.50727.3603; ASP.NET Version:2.0.50727.3053
Any ideas? Thanks, Sammer
|