Hi,
As a starting point to my NHibernate development, I have tried to set
up my first unit test on the famous Northwind database sample, with
SQLite as a backend. I have let the configuration files at the end of
this post, and my code goes like this :
ISessionFactory sessionFactory=new Configuration().BuildSessionFactory
();
ISession session=sessionFactory.OpenSession();
IList<Customer> list=session.CreateCriteria<Customer>().List<Customer>
();
Assert.AreEqual(91, list.Count);
The test always fails because no Customer is retrieved (list.Count is
0). I have tried to pass my own IDbConnection to the OpenSession
method (I am positively 100% sure of both the database and the
connection setups). I have tried to use MS Access and Sql Server 2008
as backends, to no avail.
I have tried to configure the whole thing so that some SQL could be
shown on the VS2008 output (see App.config below), but nothing ever
appears.
For now, I can only bet that something is wrong with my configuration
files, but I can't see what. Any help would be very appreciated.
Mac
App.config :
<hibernate-configuration xmlns="urn:nhibernate-configuration-2.2">
<session-factory>
<property name="dialect">NHibernate.Dialect.SQLiteDialect</
property>
<property
name="connection.provider">NHibernate.Connection.DriverConnectionProvider</
property>
<property
name="connection.driver_class">NHibernate.Driver.SQLite20Driver</
property>
<property name="connection.connection_string">Data Source=S:\Work
\SVN\src\Northwind\SQL\Northwind.db</property>
<property
name='proxyfactory.factory_class'>NHibernate.ByteCode.LinFu.ProxyFactoryFactory,
NHibernate.ByteCode.LinFu</property>
<property name="show_sql">true</property>
</session-factory>
</hibernate-configuration>
<log4net>
<appender name="DebugSQL" type="log4net.Appender.TraceAppender">
<layout type="log4net.Layout.PatternLayout">
<conversionPattern value="%date [%thread] %-5level %logger
[%property{NDC}] - %message%newline" />
</layout>
</appender>
<root>
<level value="DEBUG" />
<appender-ref ref="DebugSQL" />
</root>
</log4net>
Customer.cs :
public class Customer
{
public string CustomerID { get; set; }
public string CompanyName { get; set; }
public string ContactName { get; set; }
public string ContactTitle { get; set; }
public string Address { get; set; }
public string City { get; set; }
public string Region { get; set; }
public string PostalCode { get; set; }
public string Country { get; set; }
public string Phone { get; set; }
public string Fax { get; set; }
}
Customer.hbm.xml :
<hibernate-mapping
xmlns="urn:nhibernate-mapping-2.2"
assembly="Northwind.DomainModel"
namespace="Northwind.DomainModel.NHibernate"
>
<class name="Customer" table="Customers">
<id name="CustomerID" column="CustomerID" type="String"
length="20">
<generator class="assigned" />
</id>
<property name="CompanyName" />
<property name="ContactName" />
<property name="ContactTitle" />
<property name="Street" />
<property name="City" />
<property name="Region" />
<property name="PostalCode" />
<property name="Country" />
<property name="PhoneNumber" />
<property name="Fax" />
</class>
</hibernate-mapping>
--~--~---------~--~----~------------~-------~--~----~
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
-~----------~----~----~----~------~----~------~--~---