David,
I copied your code into my test application, unfortunately I get the
same problem. I also have a reference to the Oracle.DataAccess.dll
(copy local was set to false, but I tried true to no avail).
The full error stack is:
FluentNHibernate.Cfg.FluentConfigurationException was unhandled
Message="An invalid or incomplete configuration was used while
creating a SessionFactory. Check PotentialReasons collection, and
InnerException for more detail.\r\n\r\n"
Source="FluentNHibernate"
StackTrace:
at FluentNHibernate.Cfg.FluentConfiguration.BuildSessionFactory
() in d:\Builds\FluentNH\src\FluentNHibernate\Cfg
\FluentConfiguration.cs:line 98
at ConsoleApplication2.Program.CreateSessionFactory() in C:
\Documents and Settings\Chris.Young\My Documents\Visual Studio
2008\Projects\ConsoleApplication2\ConsoleApplication2\Program.cs:line
141
at ConsoleApplication2.Program.Main() in C:\Documents and
Settings\Chris.Young\My Documents\Visual Studio 2008\Projects
\ConsoleApplication2\ConsoleApplication2\Program.cs:line 22
at System.AppDomain._nExecuteAssembly(Assembly assembly, String
[] args)
at System.AppDomain.ExecuteAssembly(String assemblyFile,
Evidence assemblySecurity, String[] args)
at
Microsoft.VisualStudio.HostingProcess.HostProc.RunUsersAssembly()
at System.Threading.ThreadHelper.ThreadStart_Context(Object
state)
at System.Threading.ExecutionContext.Run(ExecutionContext
executionContext, ContextCallback callback, Object state)
at System.Threading.ThreadHelper.ThreadStart()
InnerException: System.InvalidCastException
Message="Unable to cast object of type
'Oracle.DataAccess.Client.OracleConnection' to type
'System.Data.Common.DbConnection'."
Source="NHibernate"
StackTrace:
at
NHibernate.Tool.hbm2ddl.SuppliedConnectionProviderConnectionHelper.Prepare
()
at
NHibernate.Tool.hbm2ddl.SchemaMetadataUpdater.GetReservedWords(Dialect
dialect, IConnectionHelper connectionHelper)
at NHibernate.Tool.hbm2ddl.SchemaMetadataUpdater.Update
(ISessionFactory sessionFactory)
at NHibernate.Impl.SessionFactoryImpl..ctor(Configuration
cfg, IMapping mapping, Settings settings, EventListeners listeners)
at NHibernate.Cfg.Configuration.BuildSessionFactory()
at
FluentNHibernate.Cfg.FluentConfiguration.BuildSessionFactory() in d:
\Builds\FluentNH\src\FluentNHibernate\Cfg\FluentConfiguration.cs:line
93
InnerException:
The entire program I am using is:
using System;
using System.IO;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Data.OracleClient;
using ConsoleApplication2.Entities;
using FluentNHibernate.Cfg;
using FluentNHibernate.Cfg.Db;
using Oracle.DataAccess.Client;
using Oracle.DataAccess.Types;
using NHibernate;
using NHibernate.Cfg;
using NHibernate.Tool.hbm2ddl;
namespace ConsoleApplication2
{
class Program
{
static void Main()
{
var sessionFactory = CreateSessionFactory();
using (var session = sessionFactory.OpenSession())
{
using (var transaction = session.BeginTransaction())
{
// create a couple of Stores each with some
Products and Employees
var barginBasin = new Store { Name = "Bargin
Basin" };
var superMart = new Store { Name = "SuperMart" };
var potatoes = new Product { Name = "Potatoes",
Price = 3.60 };
var fish = new Product { Name = "Fish", Price =
4.49 };
var milk = new Product { Name = "Milk", Price =
0.79 };
var bread = new Product { Name = "Bread", Price =
1.29 };
var cheese = new Product { Name = "Cheese", Price
= 2.10 };
var waffles = new Product { Name = "Waffles",
Price = 2.41 };
var daisy = new Employee { FirstName = "Daisy",
LastName = "Harrison" };
var jack = new Employee { FirstName = "Jack",
LastName = "Torrance" };
var sue = new Employee { FirstName = "Sue",
LastName = "Walkters" };
var bill = new Employee { FirstName = "Bill",
LastName = "Taft" };
var joan = new Employee { FirstName = "Joan",
LastName = "Pope" };
// add products to the stores, there's some
crossover in the products in each
// store, because the store-product relationship
is many-to-many
AddProductsToStore(barginBasin, potatoes, fish,
milk, bread, cheese);
AddProductsToStore(superMart, bread, cheese,
waffles);
// add employees to the stores, this relationship
is a one-to-many, so one
// employee can only work at one store at a time
AddEmployeesToStore(barginBasin, daisy, jack,
sue);
AddEmployeesToStore(superMart, bill, joan);
// save both stores, this saves everything else
via cascading
session.SaveOrUpdate(barginBasin);
session.SaveOrUpdate(superMart);
transaction.Commit();
}
// retreive all stores and display them
using (session.BeginTransaction())
{
var stores = session.CreateCriteria(typeof(Store))
.List<Store>();
foreach (var store in stores)
{
WriteStorePretty(store);
}
}
Console.ReadKey();
}
}
public static void AddEmployeesToStore(Store store, params
Employee[] employees)
{
foreach (var employee in employees)
{
store.AddEmployee(employee);
}
}
private static ISessionFactory CreateSessionFactory()
{
var idk = Fluently
.Configure()
.Database(OracleDataClientConfiguration
.Oracle10
.UseReflectionOptimizer()
.MaxFetchDepth(3)
.AdoNetBatchSize(500)
//.DefaultSchema("production")
//.Cache(c => c.UseQueryCache()
// .ProviderClass<SysCacheProvider>
()
//)
.ConnectionString(cs => cs
.Server("hostname")
.Port(1521)
.Instance("dbname")
.Username("username")
.Password("password")
.Pooling(true)
.StatementCacheSize(100)
.OtherOptions("Min Pool
Size=10;Incr Pool Size=5;Decr Pool Size=2;")
)
// It does this automatically.. but I like to be
explicit ;)
.ProxyFactoryFactory
("NHibernate.ByteCode.Castle.ProxyFactoryFactory,NHibernate.ByteCode.Castle")
// Testing/NHProf stuff
//.Raw("generate_statistics", "true")
//.ShowSql()
)
.Mappings(mappings => mappings
.FluentMappings.AddFromAssemblyOf<Program>
());
return idk.BuildSessionFactory();
}
private static void BuildSchema(Configuration config)
{
// this NHibernate tool takes a configuration (with
mapping info in)
// and exports a database schema from it
new SchemaExport(config)
.Create(false, true);
}
private static void WriteStorePretty(Store store)
{
Console.WriteLine(store.Name);
Console.WriteLine(" Products:");
foreach (var product in store.Products)
{
Console.WriteLine(" " + product.Name);
}
Console.WriteLine(" Staff:");
foreach (var employee in store.Staff)
{
Console.WriteLine(" " + employee.FirstName + " " +
employee.LastName);
}
Console.WriteLine();
}
public static void AddProductsToStore(Store store, params
Product[] products)
{
foreach (var product in products)
{
store.AddProduct(product);
}
}
}
}
The entities and maping files are the ones from the Getting started
application at
http://github.com/jagregory/fluent-nhibernate/tree/master/src/Example...
The exception is generated when BuildSessionFactory() is called. From
the stack trace, it looks as though the problem is in NHibernate
itself, not Fluent.
Chris.
On Sep 2, 12:35 pm, "David R. Longnecker" <
tiredstud...@gmail.com>
wrote: