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.  [ 15 posts ] 
Author Message
 Post subject: CreateCriteria(typeof(...)).List() doesn't work
PostPosted: Fri Mar 28, 2008 6:55 pm 
Newbie

Joined: Fri Mar 28, 2008 6:40 pm
Posts: 1
I'm trying to get a very simple sample to work - with NHibernate on Oracle 10gR2.

By using "session.BeginTransaction()" I 've verified at the database side that a database session has been created. Nevertheless a subsequent:

x = session.CreateCriteria(typeof(TheData.MessageProvider)).List();

leaves "x" empty and does not raise an exception either ...

So I've no clue what 's going on/wrong here.
Any help is really highly appreciated.


Top
 Profile  
 
 Post subject:
PostPosted: Sat Mar 29, 2008 9:04 am 
Expert
Expert

Joined: Thu Dec 14, 2006 5:57 am
Posts: 1185
Location: Zurich, Switzerland
Hard to say without more information. Set logging to DEBUG and post the log. Also mappings and classes.

What do you mean with x is empty ? Empty list or null ? If you get an empty list, that would mean there is no data available matching your criteria.

_________________
--Wolfgang


Top
 Profile  
 
 Post subject:
PostPosted: Wed Apr 02, 2008 10:25 am 
Regular
Regular

Joined: Tue Oct 16, 2007 9:45 am
Posts: 93
Yes, I am trying to figure out where is the logging set. As soon as I figure that out, I'll post more info. Data is there, I can see in the table. There is nothing in the criteria, I want them first, without constraints, just to see if it works.


Top
 Profile  
 
 Post subject:
PostPosted: Wed Apr 02, 2008 10:27 am 
Regular
Regular

Joined: Tue Oct 16, 2007 9:45 am
Posts: 93
Yes, I am trying to figure out where is the logging set. As soon as I figure that out, I'll post more info. Data is there, I can see in the table. There is nothing in the criteria, I want them first, without constraints, just to see if it works.


Top
 Profile  
 
 Post subject:
PostPosted: Wed Apr 02, 2008 1:04 pm 
Regular
Regular

Joined: Mon Mar 20, 2006 10:49 pm
Posts: 59
This will happen if the type being queried is not mapped. How are you adding the mappings to your configuration? If you are using AddAssembly, ensure that the .hbm.xml files are Embedded Resources.

_________________
Mike Abraham


Top
 Profile  
 
 Post subject:
PostPosted: Wed Apr 02, 2008 1:22 pm 
Regular
Regular

Joined: Tue Oct 16, 2007 9:45 am
Posts: 93
Yes, mapping file is embeded resource.
Here is the mapping:

<?xml version="1.0" encoding="utf-8"?>
<hibernate-mapping
xmlns="urn:nhibernate-mapping-2.2"
schema=""
default-cascade="none"
auto-import="true"
assembly="Intelliun.Core" namespace="Intelliun.Core.Entities.billing"
>
<class name="Invoice"
table="INVOICE"
lazy="true"
>
<id name = "RecordId"
type = "Guid"
column="VEOID"
unsaved-value="0"
access="property"
>
<generator class="guid.comb"></generator>
</id>
<property name = "number"
column = "NUMBER"
type = "String"
access="field.camelcase-underscore"
/>
<property name = "date"
column = "DATE"
access="field.camelcase-underscore"
/>
<property name = "unpaidBalance"
column = "UNPAID_BALANCE"
access="field.camelcase-underscore"
/>


</class>
</hibernate-mapping>

I tried using other two methods using IQuery, same thing and Queires in native SQL and the later throws an error: no persister defined....

I really need to get this going, as this a proof of concept for a big project.
I am pulling my hairs out.

Here is the code.
Code:
               public EntityBag<Invoice> FindAllInvoices()
        {
            try
            {
                ITransaction tx = NHSession.BeginTransaction();
                //this does not work
                //ICriteria c = NHSession.CreateCriteria(typeof(Invoice));
                //IList<Invoice> l = c.List<Invoice>();
                //nor this
                //IQuery q = NHSession.CreateQuery("from Invoice inv");
                // IEnumerable l = q.Enumerable();
                //nor this
                //IList<Invoice> l = NHSession.CreateSQLQuery(
//"SELECT {inv.*} FROM INVOICE {inv}",
//"inv",
//typeof(Invoice)
//).List<Invoice>();
                  tx.Commit();
                return new EntityBag<Invoice>(l);
            }
       
            catch (Exception ex)
            {
                throw new InfrastrucureException(ex);
            }


Top
 Profile  
 
 Post subject:
PostPosted: Wed Apr 02, 2008 1:38 pm 
Regular
Regular

Joined: Mon Mar 20, 2006 10:49 pm
Posts: 59
How are you specifying that the assembly in which the mappings are embedded should be added to the NH configuration? Please post your web.config (or app.config), and the code used to create the NHibernate configuration and SessionFactory.

Also, it would be helpful if you could get log4net working and post the log output. To get log4net working you can do the following:

1) Execute log4net.Config.XmlConfigurator.Configure(); before doing any NHibernate configuration;
2) Add log4net config info tou your .config file. Something like this should work

<log4net debug="true">
<appender name="TraceAppender" type="log4net.Appender.TraceAppender">
<layout type="log4net.Layout.PatternLayout,log4net">
<param name="ConversionPattern" value="%d [%t] %-5p %c - %m%n"/>
</layout>
</appender>
<root>
<level value="DEBUG"/>
<appender-ref ref="TraceAppender"/>
</root>
</log4net>

_________________
Mike Abraham


Top
 Profile  
 
 Post subject:
PostPosted: Wed Apr 02, 2008 1:52 pm 
Regular
Regular

Joined: Tue Oct 16, 2007 9:45 am
Posts: 93
Web.config

Code:
<?xml version="1.0"?>
<!--
    Note: As an alternative to hand editing this file you can use the
    web admin tool to configure settings for your application. Use
    the Website->Asp.Net Configuration option in Visual Studio.
    A full list of settings and comments can be found in
    machine.config.comments usually located in
    \Windows\Microsoft.Net\Framework\v2.x\Config
-->
<configuration>
   <configSections>
      <sectionGroup name="system.web.extensions" type="System.Web.Configuration.SystemWebExtensionsSectionGroup, System.Web.Extensions, Version=3.5.0.0, Culture=neutral, PublicKeyToken=31BF3856AD364E35">
         <sectionGroup name="scripting" type="System.Web.Configuration.ScriptingSectionGroup, System.Web.Extensions, Version=3.5.0.0, Culture=neutral, PublicKeyToken=31BF3856AD364E35">
            <section name="scriptResourceHandler" type="System.Web.Configuration.ScriptingScriptResourceHandlerSection, System.Web.Extensions, Version=3.5.0.0, Culture=neutral, PublicKeyToken=31BF3856AD364E35" requirePermission="false" allowDefinition="MachineToApplication"/>
            <sectionGroup name="webServices" type="System.Web.Configuration.ScriptingWebServicesSectionGroup, System.Web.Extensions, Version=3.5.0.0, Culture=neutral, PublicKeyToken=31BF3856AD364E35">
               <section name="jsonSerialization" type="System.Web.Configuration.ScriptingJsonSerializationSection, System.Web.Extensions, Version=3.5.0.0, Culture=neutral, PublicKeyToken=31BF3856AD364E35" requirePermission="false" allowDefinition="Everywhere"/>
               <section name="profileService" type="System.Web.Configuration.ScriptingProfileServiceSection, System.Web.Extensions, Version=3.5.0.0, Culture=neutral, PublicKeyToken=31BF3856AD364E35" requirePermission="false" allowDefinition="MachineToApplication"/>
               <section name="authenticationService" type="System.Web.Configuration.ScriptingAuthenticationServiceSection, System.Web.Extensions, Version=3.5.0.0, Culture=neutral, PublicKeyToken=31BF3856AD364E35" requirePermission="false" allowDefinition="MachineToApplication"/>
               <section name="roleService" type="System.Web.Configuration.ScriptingRoleServiceSection, System.Web.Extensions, Version=3.5.0.0, Culture=neutral, PublicKeyToken=31BF3856AD364E35" requirePermission="false" allowDefinition="MachineToApplication"/>
            </sectionGroup>
         </sectionGroup>
      </sectionGroup>
   
    <section name="hibernate-configuration" type="NHibernate.Cfg.ConfigurationSectionHandler, NHibernate"/>
    <section name="log4net" type="log4net.Config.Log4NetConfigurationSectionHandler,log4net" />
   </configSections>
 
  <!-- This section is for NHibernate configuration-->
  <hibernate-configuration>
    <!-- an ISessionFactory instance -->
    <session-factory xmlns="urn:nhibernate-configuration-2.2">
      <property name="connection.provider">
        NHibernate.Connection.DriverConnectionProvider
      </property>
      <property name="dialect">
        NHibernate.Dialect.MsSql2005Dialect
      </property>
      <property name="connection.driver_class">
        NHibernate.Driver.SqlClientDriver
      </property>
      <property name="connection.connection_string">
        Server=INTELLIUNWD-PC\SQLEXPRESS;User Id=sa;Password=password;
      </property>
      <property name="show_sql">
        true
      </property>
     
      <!-- uncomment if using with ASP.NET application
      <property name="hibernate.current_session_context_class">
        NHibernate.Context.WebSessionContext, NHibernate
      </property>-->
     
      <!-- this is not supported yet
    <property name="current_session_context_class">
      web
    </property>-->

      <!-- use this setting for any kind of application other then ASP.NET
    <property name="current_session_context_class">
      call
    </property>-->

      <!-- mapping files
    <mapping   resource="Category.hbm.xml" assembly="Intelliun.Domain" />-->
    </session-factory>
  </hibernate-configuration>

  <!-- This section contains the log4net configuration settings -->
  <log4net debug="true">

    <!-- Define some output appenders -->
    <appender name="trace" type="log4net.Appender.TraceAppender, log4net">
      <layout type="log4net.Layout.PatternLayout,log4net">
        <param name="ConversionPattern" value="%d [%t] %-5p %c - %m%n" />
      </layout>
    </appender>

    <appender name="console" type="log4net.Appender.ConsoleAppender, log4net">
      <layout type="log4net.Layout.PatternLayout,log4net">
        <param name="ConversionPattern" value="%d [%t] %-5p %c - %m%n" />
      </layout>
    </appender>

    <appender name="rollingFile" type="log4net.Appender.RollingFileAppender,log4net" >

      <param name="File" value="log.txt" />
      <param name="AppendToFile" value="true" />
      <param name="RollingStyle" value="Date" />
      <param name="DatePattern" value="yyyy.MM.dd" />
      <param name="StaticLogFileName" value="true" />

      <layout type="log4net.Layout.PatternLayout,log4net">
        <param name="ConversionPattern" value="%d [%t] %-5p %c - %m%n" />
      </layout>
    </appender>

    <!-- Setup the root category, add the appenders and set the default priority -->

    <root>
      <priority value="DEBUG" />
      <appender-ref ref="console" />
    </root>
  </log4net>

  <appSettings>
    <add key="RepositoryFactory" value="Intelliun.Data.Factories.RepositoryFactory, Intelliun.Data"/>
   <!-- <add key="NHibernateConfigurationFile" value="/App.config"/>-->
  </appSettings>

  <connectionStrings/>
   <system.web>
      <!--
            Set compilation debug="true" to insert debugging
            symbols into the compiled page. Because this
            affects performance, set this value to true only
            during development.
    -->
      <compilation debug="true">
         <assemblies>
            <add assembly="System.Core, Version=3.5.0.0, Culture=neutral, PublicKeyToken=B77A5C561934E089"/>
            <add assembly="System.Web.Extensions, Version=3.5.0.0, Culture=neutral, PublicKeyToken=31BF3856AD364E35"/>
            <add assembly="System.Web.Abstractions, Version=3.5.0.0, Culture=neutral, PublicKeyToken=31BF3856AD364E35"/>
            <add assembly="System.Web.Routing, Version=3.5.0.0, Culture=neutral, PublicKeyToken=31BF3856AD364E35"/>
            <add assembly="System.Data.DataSetExtensions, Version=3.5.0.0, Culture=neutral, PublicKeyToken=B77A5C561934E089"/>
            <add assembly="System.Xml.Linq, Version=3.5.0.0, Culture=neutral, PublicKeyToken=B77A5C561934E089"/>
            <add assembly="System.Data.Linq, Version=3.5.0.0, Culture=neutral, PublicKeyToken=B77A5C561934E089"/>
         </assemblies>
      </compilation>
      <!--
            The <authentication> section enables configuration
            of the security authentication mode used by
            ASP.NET to identify an incoming user.
    -->
      <authentication mode="Windows"/>
      <!--
            The <customErrors> section enables configuration
            of what to do if/when an unhandled error occurs
            during the execution of a request. Specifically,
            it enables developers to configure html error pages
            to be displayed in place of a error stack trace.

        <customErrors mode="RemoteOnly" defaultRedirect="GenericErrorPage.htm">
            <error statusCode="403" redirect="NoAccess.htm" />
            <error statusCode="404" redirect="FileNotFound.htm" />
        </customErrors>
    -->
      <pages>
         <controls>
            <add tagPrefix="asp" namespace="System.Web.UI" assembly="System.Web.Extensions, Version=3.5.0.0, Culture=neutral, PublicKeyToken=31BF3856AD364E35"/>
            <add tagPrefix="asp" namespace="System.Web.UI.WebControls" assembly="System.Web.Extensions, Version=3.5.0.0, Culture=neutral, PublicKeyToken=31BF3856AD364E35"/>
         </controls>
         <namespaces>
            <add namespace="System.Web.Mvc"/>
            <add namespace="System.Web.Routing"/>
            <add namespace="System.Linq"/>
            <add namespace="System.Collections.Generic"/>
         </namespaces>
      </pages>
      <httpHandlers>
         <remove verb="*" path="*.asmx"/>
         <add verb="*" path="*.asmx" validate="false" type="System.Web.Script.Services.ScriptHandlerFactory, System.Web.Extensions, Version=3.5.0.0, Culture=neutral, PublicKeyToken=31BF3856AD364E35"/>
         <add verb="*" path="*_AppService.axd" validate="false" type="System.Web.Script.Services.ScriptHandlerFactory, System.Web.Extensions, Version=3.5.0.0, Culture=neutral, PublicKeyToken=31BF3856AD364E35"/>
         <add verb="GET,HEAD" path="ScriptResource.axd" type="System.Web.Handlers.ScriptResourceHandler, System.Web.Extensions, Version=3.5.0.0, Culture=neutral, PublicKeyToken=31BF3856AD364E35" validate="false"/>
      </httpHandlers>
      <httpModules>
         <add name="ScriptModule" type="System.Web.Handlers.ScriptModule, System.Web.Extensions, Version=3.5.0.0, Culture=neutral, PublicKeyToken=31BF3856AD364E35"/>
         <add name="UrlRoutingModule" type="System.Web.Routing.UrlRoutingModule, System.Web.Routing, Version=3.5.0.0, Culture=neutral, PublicKeyToken=31BF3856AD364E35"/>
      <add name="NHibernateSessionModule" type="Intelliun.NHibernateExtensions.NHibernateSessionModule"/>
      </httpModules>
   </system.web>
   <system.codedom>
      <compilers>
         <compiler language="c#;cs;csharp" extension=".cs" warningLevel="4" type="Microsoft.CSharp.CSharpCodeProvider, System, Version=2.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089">
            <providerOption name="CompilerVersion" value="v3.5"/>
            <providerOption name="WarnAsError" value="false"/>
         </compiler>
         <compiler language="vb;vbs;visualbasic;vbscript" extension=".vb" warningLevel="4" type="Microsoft.VisualBasic.VBCodeProvider, System, Version=2.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089">
            <providerOption name="CompilerVersion" value="v3.5"/>
            <providerOption name="OptionInfer" value="true"/>
            <providerOption name="WarnAsError" value="false"/>
         </compiler>
      </compilers>
   </system.codedom>
   <system.web.extensions/>
   <!--
        The system.webServer section is required for running ASP.NET AJAX under Internet
        Information Services 7.0.  It is not necessary for previous version of IIS.
  -->
   <system.webServer>
      <validation validateIntegratedModeConfiguration="false"/>
      <modules runAllManagedModulesForAllRequests="true">
         <remove name="ScriptModule"/>
         <remove name="UrlRoutingModule"/>
         <add name="ScriptModule" preCondition="managedHandler" type="System.Web.Handlers.ScriptModule, System.Web.Extensions, Version=3.5.0.0, Culture=neutral, PublicKeyToken=31BF3856AD364E35"/>
         <add name="UrlRoutingModule" type="System.Web.Routing.UrlRoutingModule, System.Web.Routing, Version=3.5.0.0, Culture=neutral, PublicKeyToken=31BF3856AD364E35"/>
      </modules>
      <handlers>
         <remove name="WebServiceHandlerFactory-Integrated"/>
         <remove name="ScriptHandlerFactory"/>
         <remove name="ScriptHandlerFactoryAppServices"/>
         <remove name="ScriptResource"/>
         <add name="ScriptHandlerFactory" verb="*" path="*.asmx" preCondition="integratedMode" type="System.Web.Script.Services.ScriptHandlerFactory, System.Web.Extensions, Version=3.5.0.0, Culture=neutral, PublicKeyToken=31BF3856AD364E35"/>
         <add name="ScriptHandlerFactoryAppServices" verb="*" path="*_AppService.axd" preCondition="integratedMode" type="System.Web.Script.Services.ScriptHandlerFactory, System.Web.Extensions, Version=3.5.0.0, Culture=neutral, PublicKeyToken=31BF3856AD364E35"/>
         <add name="ScriptResource" preCondition="integratedMode" verb="GET,HEAD" path="ScriptResource.axd" type="System.Web.Handlers.ScriptResourceHandler, System.Web.Extensions, Version=3.5.0.0, Culture=neutral, PublicKeyToken=31BF3856AD364E35"/>
         <add name="MvcScriptMap" preCondition="classicMode,bitness32" verb="*" path="*.mvc" modules="IsapiModule" scriptProcessor="%windir%\Microsoft.NET\Framework\v2.0.50727\aspnet_isapi.dll"/>
         <add name="MvcScriptMap64" preCondition="classicMode,bitness64" verb="*" path="*.mvc" modules="IsapiModule" scriptProcessor="%windir%\Microsoft.NET\Framework64\v2.0.50727\aspnet_isapi.dll"/>
         <add name="UrlRoutingHandler" preCondition="integratedMode" verb="*" path="UrlRouting.axd" type="System.Web.Routing.UrlRoutingHandler, System.Web.Routing, Version=3.5.0.0, Culture=neutral, PublicKeyToken=31BF3856AD364E35"/>
      </handlers>
   </system.webServer>
</configuration>



NHibernateHelper

Code:
using System;
using System.Collections.Generic;
using System.Text;
using System.Web;
using System.Web.Hosting;

using NHibernate;
using NHibernate.Cfg;
using NHibernate.Context;
using NHibernate.Exceptions;

namespace Intelliun.NHibernateExtensions
{
    public sealed class NHibernateHelper
    {
        public static readonly ISessionFactory SessionFactory;
        private const string CurrentSessionKey = "nhibernate.current_session";

        static NHibernateHelper()
        {
            //TODO: see how to read all of the configuration files at once
            try
            {
                //string path = HostingEnvironment.MapPath(
                //   System.Configuration.ConfigurationManager
                //       .AppSettings["NHibernateConfigurationFile"]);
                //Configuration cfg = new Configuration().Configure(path);

                Configuration cfg = new Configuration().Configure();
                //make all mapping files embeded resource in assembly
                cfg.AddAssembly("Intelliun.Core");

                //cfg.AddXmlFile(HostingEnvironment.MapPath("/NhibernateMapping/Invoice.hbm.xml"));
                SessionFactory = cfg.BuildSessionFactory();

            }
            catch (Exception ex)
            {
                throw new Exception("NHibernate initialization failed", ex);
            }
        }

        public static ISession GetCurrentSession()
        {
            HttpContext context = HttpContext.Current;
            ISession currentSession = context.Items[CurrentSessionKey] as ISession;
            if (currentSession == null)
            {
                currentSession = SessionFactory.OpenSession();
                context.Items[CurrentSessionKey] = currentSession;
            }
            return currentSession;
        }

        public static void CloseSession()
        {
            HttpContext context = HttpContext.Current;
            ISession currentSession = context.Items[CurrentSessionKey] as ISession;

            if (currentSession == null)
            {
                // No current session
                return;
            }

            currentSession.Close();
            context.Items.Remove(CurrentSessionKey);
        }

        public static void CloseSessionFactory()
        {
            if (SessionFactory != null)
            {
                SessionFactory.Close();
            }
        }


    }
}


NhibernateSessionModule

Code:
       private void Application_EndRequest(object sender, EventArgs e)
        {
            //NHibernate.ISession session = ManagedWebSessionContext.Unbind(HttpContext.Current,
            //        NHibernateHelper.SessionFactory);

            NHibernate.ISession session = NHibernateHelper.GetCurrentSession();
            if (session.Transaction.IsActive)
            {
                session.Transaction.Rollback();
            }

            if (session != null)
            {
                session.Close();
            }
        }
    }



BillingRepository
Code:
using System;
using System.Collections.Generic;
using System.Text;

using NHibernate;
using NHibernate.Expression;

using Intelliun.Data.Exceptions;
using Intelliun.Collections;
using Intelliun.Core.Entities.billing;
using Intelliun.Core.Repositories;

namespace Intelliun.Data.Repositories
{
    public class BillingRepository : GenericRepository, IBillingRepository
    {

        #region IBillingRepository Members

        public EntityBag<Invoice> FindAllInvoices()
        {
            try
            {
                ITransaction tx = NHSession.BeginTransaction();
                //this does not work
                //ICriteria c = NHSession.CreateCriteria(typeof(Invoice));
                //IList<Invoice> l = c.List<Invoice>();
                //nor this
                //IQuery q = NHSession.CreateQuery( "from INOVICE as Invoice");
                //IList<Invoice> l = q.List<Invoice>();
                //nor this
                //IList<Invoice> l = NHSession.CreateSQLQuery(
//"SELECT {inv.*} FROM INVOICE {inv}",
//"inv",
//typeof(Invoice)
//).List<Invoice>();
                  tx.Commit();
                return new EntityBag<Invoice>(l);
            }
       
            catch (Exception ex)
            {
                throw new InfrastrucureException(ex);
            }
            //return FindAll<Invoice>();
        }
        public EntityBag<LineItem> FindAllLineItems()
        {
            return FindAll<LineItem>();
        }

        #endregion
    }
}


Top
 Profile  
 
 Post subject:
PostPosted: Wed Apr 02, 2008 2:00 pm 
Regular
Regular

Joined: Tue Oct 16, 2007 9:45 am
Posts: 93
I added this to Global.asax

protected void Application_Start(object sender, EventArgs e)
{
log4net.Config.XmlConfigurator.Configure();
RegisterRoutes(RouteTable.Routes);
}


but I do not see any output anywher? Where should I look for log messages ( i am not familliar with log4net yet).


Top
 Profile  
 
 Post subject:
PostPosted: Wed Apr 02, 2008 2:05 pm 
Regular
Regular

Joined: Tue Oct 16, 2007 9:45 am
Posts: 93
ok I switched appender to file, here is the output

2008-04-02 13:02:18,089 [4] INFO NHibernate.Cfg.Environment - NHibernate 1.2.1.4000 (1.2.1.4000)
2008-04-02 13:02:18,132 [4] INFO NHibernate.Cfg.Environment - nhibernate section not found in application configuration file
2008-04-02 13:02:18,134 [4] INFO NHibernate.Cfg.Environment - Bytecode provider name : lcg
2008-04-02 13:02:18,137 [4] INFO NHibernate.Cfg.Environment - Using reflection optimizer
2008-04-02 13:02:18,194 [4] DEBUG NHibernate.Cfg.Configuration - connection.provider=
NHibernate.Connection.DriverConnectionProvider

2008-04-02 13:02:18,195 [4] DEBUG NHibernate.Cfg.Configuration - dialect=
NHibernate.Dialect.MsSql2005Dialect

2008-04-02 13:02:18,195 [4] DEBUG NHibernate.Cfg.Configuration - connection.driver_class=
NHibernate.Driver.SqlClientDriver

2008-04-02 13:02:18,195 [4] DEBUG NHibernate.Cfg.Configuration - connection.connection_string=
Server=INTELLIUNWD-PC\SQLEXPRESS;User Id=sa;Password=password;

2008-04-02 13:02:18,195 [4] DEBUG NHibernate.Cfg.Configuration - show_sql=
true

2008-04-02 13:02:18,195 [4] DEBUG NHibernate.Cfg.Configuration - properties: System.Collections.Hashtable
2008-04-02 13:02:18,195 [4] INFO NHibernate.Cfg.Configuration - Searching for mapped documents in assembly: Intelliun.Core
2008-04-02 13:02:18,198 [4] INFO NHibernate.Cfg.Configuration - checking mappings queue
2008-04-02 13:02:18,198 [4] INFO NHibernate.Cfg.Configuration - processing one-to-many association mappings
2008-04-02 13:02:18,198 [4] INFO NHibernate.Cfg.Configuration - processing one-to-one association property references
2008-04-02 13:02:18,198 [4] INFO NHibernate.Cfg.Configuration - processing foreign key constraints
2008-04-02 13:02:18,237 [4] INFO NHibernate.Dialect.Dialect - Using dialect: NHibernate.Dialect.MsSql2005Dialect
2008-04-02 13:02:18,244 [4] INFO NHibernate.Connection.ConnectionProviderFactory - Initializing connection provider:
NHibernate.Connection.DriverConnectionProvider

2008-04-02 13:02:18,245 [4] INFO NHibernate.Connection.ConnectionProvider - Configuring ConnectionProvider
2008-04-02 13:02:18,247 [4] INFO NHibernate.Cfg.SettingsFactory - Transaction factory: NHibernate.Transaction.AdoNetTransactionFactory
2008-04-02 13:02:18,247 [4] INFO NHibernate.Cfg.SettingsFactory - Optimize cache for minimal puts: False
2008-04-02 13:02:18,247 [4] INFO NHibernate.Cfg.SettingsFactory - Connection release mode: auto
2008-04-02 13:02:18,248 [4] INFO NHibernate.Cfg.SettingsFactory - echoing all SQL to stdout
2008-04-02 13:02:18,248 [4] INFO NHibernate.Cfg.SettingsFactory - Query translator: NHibernate.Hql.Classic.ClassicQueryTranslatorFactory
2008-04-02 13:02:18,250 [4] INFO NHibernate.Cfg.SettingsFactory - Query language substitutions: {}
2008-04-02 13:02:18,250 [4] INFO NHibernate.Cfg.SettingsFactory - cache provider: NHibernate.Cache.NoCacheProvider, NHibernate, Version=1.2.1.4000, Culture=neutral, PublicKeyToken=aa95f207798dfdb4
2008-04-02 13:02:18,259 [4] INFO NHibernate.Impl.SessionFactoryImpl - building session factory
2008-04-02 13:02:18,260 [4] DEBUG NHibernate.Impl.SessionFactoryImpl - instantiating session factory with properties: {hibernate.dialect=
NHibernate.Dialect.MsSql2005Dialect
, hibernate.connection.connection_string=
Server=INTELLIUNWD-PC\SQLEXPRESS;User Id=sa;Password=password;
, dialect=
NHibernate.Dialect.MsSql2005Dialect
, connection.driver_class=
NHibernate.Driver.SqlClientDriver
, hibernate.connection.driver_class=
NHibernate.Driver.SqlClientDriver
, hibernate.show_sql=
true
, hibernate.use_reflection_optimizer=true, connection.connection_string=
Server=INTELLIUNWD-PC\SQLEXPRESS;User Id=sa;Password=password;
, connection.provider=
NHibernate.Connection.DriverConnectionProvider
, hibernate.connection.provider=
NHibernate.Connection.DriverConnectionProvider
, show_sql=
true
}
2008-04-02 13:02:18,262 [4] DEBUG NHibernate.Impl.SessionFactoryObjectFactory - initializing class SessionFactoryObjectFactory
2008-04-02 13:02:18,263 [4] DEBUG NHibernate.Impl.SessionFactoryObjectFactory - registered: 52bd8ec570a84735b86c545a4ae81e75(unnamed)
2008-04-02 13:02:18,263 [4] INFO NHibernate.Impl.SessionFactoryObjectFactory - no name configured
2008-04-02 13:02:18,264 [4] DEBUG NHibernate.Impl.SessionFactoryImpl - Instantiated session factory
2008-04-02 13:02:18,273 [4] DEBUG NHibernate.Impl.SessionImpl - opened session
2008-04-02 13:02:18,276 [4] DEBUG NHibernate.Transaction.AdoTransaction - begin
2008-04-02 13:02:18,277 [4] DEBUG NHibernate.Connection.DriverConnectionProvider - Obtaining IDbConnection from Driver
2008-04-02 13:02:18,362 [4] DEBUG NHibernate.Impl.SessionImpl - flushing session
2008-04-02 13:02:18,368 [4] DEBUG NHibernate.Impl.SessionImpl - Flushing entities and processing referenced collections
2008-04-02 13:02:18,370 [4] DEBUG NHibernate.Impl.SessionImpl - Processing unreferenced collections
2008-04-02 13:02:18,370 [4] DEBUG NHibernate.Impl.SessionImpl - scheduling collection removes/(re)creates/updates
2008-04-02 13:02:18,370 [4] DEBUG NHibernate.Impl.SessionImpl - Flushed: 0 insertions, 0 updates, 0 deletions to 0 objects
2008-04-02 13:02:18,370 [4] DEBUG NHibernate.Impl.SessionImpl - Flushed: 0 (re)creations, 0 updates, 0 removals to 0 collections
2008-04-02 13:02:18,372 [4] DEBUG NHibernate.Impl.SessionImpl - dont need to execute flush
2008-04-02 13:02:18,374 [4] DEBUG NHibernate.Transaction.AdoTransaction - commit
2008-04-02 13:02:18,374 [4] DEBUG NHibernate.Impl.SessionImpl - flushing session
2008-04-02 13:02:18,374 [4] DEBUG NHibernate.Impl.SessionImpl - Flushing entities and processing referenced collections
2008-04-02 13:02:18,374 [4] DEBUG NHibernate.Impl.SessionImpl - Processing unreferenced collections
2008-04-02 13:02:18,374 [4] DEBUG NHibernate.Impl.SessionImpl - scheduling collection removes/(re)creates/updates
2008-04-02 13:02:18,374 [4] DEBUG NHibernate.Impl.SessionImpl - Flushed: 0 insertions, 0 updates, 0 deletions to 0 objects
2008-04-02 13:02:18,374 [4] DEBUG NHibernate.Impl.SessionImpl - Flushed: 0 (re)creations, 0 updates, 0 removals to 0 collections
2008-04-02 13:02:18,375 [4] DEBUG NHibernate.Impl.SessionImpl - executing flush
2008-04-02 13:02:18,375 [4] DEBUG NHibernate.Impl.ConnectionManager - registering flush begin
2008-04-02 13:02:18,376 [4] DEBUG NHibernate.Impl.ConnectionManager - registering flush end
2008-04-02 13:02:18,378 [4] DEBUG NHibernate.Impl.SessionImpl - post flush
2008-04-02 13:02:18,379 [4] DEBUG NHibernate.Impl.SessionImpl - before transaction completion
2008-04-02 13:02:18,382 [4] DEBUG NHibernate.Impl.ConnectionManager - aggressively releasing database connection
2008-04-02 13:02:18,384 [4] DEBUG NHibernate.Connection.ConnectionProvider - Closing connection
2008-04-02 13:02:18,384 [4] DEBUG NHibernate.Impl.SessionImpl - transaction completion
2008-04-02 13:02:18,385 [4] DEBUG NHibernate.Transaction.AdoTransaction - running AdoTransaction.Dispose()
2008-04-02 13:02:20,169 [4] DEBUG NHibernate.Impl.SessionImpl - closing session
2008-04-02 13:02:20,170 [4] DEBUG NHibernate.Impl.BatcherImpl - running BatcherImpl.Dispose(true)
2008-04-02 13:02:20,171 [4] DEBUG NHibernate.Transaction.AdoTransaction - running AdoTransaction.Dispose()
2008-04-02 13:02:20,279 [4] DEBUG NHibernate.Impl.SessionImpl - opened session
2008-04-02 13:02:20,279 [4] DEBUG NHibernate.Impl.SessionImpl - closing session
2008-04-02 13:02:20,279 [4] DEBUG NHibernate.Impl.BatcherImpl - running BatcherImpl.Dispose(true)
2008-04-02 13:02:20,279 [4] DEBUG NHibernate.Transaction.AdoTransaction - running AdoTransaction.Dispose()


Top
 Profile  
 
 Post subject:
PostPosted: Wed Apr 02, 2008 2:22 pm 
Regular
Regular

Joined: Tue Oct 16, 2007 9:45 am
Posts: 93
Ok, I think I know where the problem is ( I have new ones though). I was adding wrong assembly (Core vs. Data) when configuring session. Now I have new error

NHibernate.MappingException was caught
Message="Could not parse identifier unsaved-value: 0"
Source="NHibernate"
StackTrace:
at NHibernate.Engine.UnsavedValueFactory.GetUnsavedIdentifierValue(String unsavedValue, IGetter identifierGetter, IType identifierType, ConstructorInfo constructor)
at NHibernate.Tuple.PropertyFactory.BuildIdentifierProperty(PersistentClass mappedEntity, IIdentifierGenerator generator)
at NHibernate.Tuple.EntityMetamodel..ctor(PersistentClass persistentClass, ISessionFactoryImplementor sessionFactory)
at NHibernate.Persister.Entity.AbstractEntityPersister..ctor(PersistentClass persistentClass, ICacheConcurrencyStrategy cache, ISessionFactoryImplementor factory)
at NHibernate.Persister.Entity.SingleTableEntityPersister..ctor(PersistentClass model, ICacheConcurrencyStrategy cache, ISessionFactoryImplementor factory, IMapping mapping)
at NHibernate.Persister.PersisterFactory.CreateClassPersister(PersistentClass model, ICacheConcurrencyStrategy cache, ISessionFactoryImplementor factory, IMapping cfg)
at NHibernate.Impl.SessionFactoryImpl..ctor(Configuration cfg, IMapping mapping, Settings settings)
at NHibernate.Cfg.Configuration.BuildSessionFactory()
at Intelliun.NHibernateExtensions.NHibernateHelper..cctor() in C:\VE4_0\server\namespace\homes\Web\codegen\Demo\NhibernateSessionModule\NHibernateHelper.cs:line 34
InnerException: System.FormatException
Message="Guid should contain 32 digits with 4 dashes (xxxxxxxx-xxxx-xxxx-xxxx-xxxxxxxxxxxx)."
Source="mscorlib"
StackTrace:
at System.Guid..ctor(String g)
at NHibernate.Type.GuidType.FromStringValue(String xml)
at NHibernate.Type.NullableType.FromString(String xml)
at NHibernate.Type.GuidType.StringToObject(String xml)
at NHibernate.Engine.UnsavedValueFactory.GetUnsavedIdentifierValue(String unsavedValue, IGetter identifierGetter, IType identifierType, ConstructorInfo constructor)
InnerException:


Top
 Profile  
 
 Post subject:
PostPosted: Wed Apr 02, 2008 2:52 pm 
Regular
Regular

Joined: Mon Mar 20, 2006 10:49 pm
Posts: 59
I believe that your latest problem is that the id is of type Guid and it can't convert the unsaved-value (0) to a Guid. Try

unsaved-value="00000000-0000-0000-0000-000000000000"

_________________
Mike Abraham


Top
 Profile  
 
 Post subject:
PostPosted: Wed Apr 02, 2008 2:54 pm 
Regular
Regular

Joined: Mon Mar 20, 2006 10:49 pm
Posts: 59
I forgot to mention that the output from the TraceAppender will be in the Output/Debug window (open the Output window in VS and select Debug from the drop-down at the top of the window)

_________________
Mike Abraham


Top
 Profile  
 
 Post subject:
PostPosted: Wed Apr 02, 2008 2:55 pm 
Regular
Regular

Joined: Tue Oct 16, 2007 9:45 am
Posts: 93
Yep, your guess was right. I think I can remove unsaved valuie altogether. Thanks for your help. Also, I just realized I hijacked other persons thread. I one with the same name. Sorry.


Top
 Profile  
 
 Post subject:
PostPosted: Thu Apr 03, 2008 10:35 am 
Expert
Expert

Joined: Thu Dec 14, 2006 5:57 am
Posts: 1185
Location: Zurich, Switzerland
Hi doublemk,

have you solved yor problem ?

_________________
--Wolfgang


Top
 Profile  
 
Display posts from previous:  Sort by  
Forum locked This topic is locked, you cannot edit posts or make further replies.  [ 15 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:
cron
© Copyright 2014, Red Hat Inc. All rights reserved. JBoss and Hibernate are registered trademarks and servicemarks of Red Hat, Inc.