From 3dd98a112f4308532d768943690b13c403dff68b Mon Sep 17 00:00:00 2001 From: Sean Dague Date: Wed, 23 Apr 2008 20:48:23 +0000 Subject: allow for Inventory database source to be specified in main configs. This works with sqlite and nhibernate backends, and stays with default seperate ini files for mysql and mssql until someone writes those. --- OpenSim/Data/NHibernate/NHibernateInventoryData.cs | 26 +++++++++++----------- 1 file changed, 13 insertions(+), 13 deletions(-) (limited to 'OpenSim/Data/NHibernate/NHibernateInventoryData.cs') diff --git a/OpenSim/Data/NHibernate/NHibernateInventoryData.cs b/OpenSim/Data/NHibernate/NHibernateInventoryData.cs index 1ac0f0c..938f47c 100644 --- a/OpenSim/Data/NHibernate/NHibernateInventoryData.cs +++ b/OpenSim/Data/NHibernate/NHibernateInventoryData.cs @@ -50,25 +50,21 @@ namespace OpenSim.Data.NHibernate /// /// Initialises the interface /// - public void Initialise() + public void Initialise(string connect) { - Initialise("Inventory.db", "Inventory"); - } - - public void Initialise(string dbfile, string dbname) - { - // TODO: hard coding for sqlite based stuff to begin with, just making it easier to test - - // This is stubbing for now, it will become dynamic later and support different db backends + // Split out the dialect, driver, and connect string + char[] split = {';'}; + string[] parts = connect.Split(split); + + // Establish NHibernate Connection cfg = new Configuration(); cfg.SetProperty(Environment.ConnectionProvider, "NHibernate.Connection.DriverConnectionProvider"); cfg.SetProperty(Environment.Dialect, - "NHibernate.Dialect.SQLiteDialect"); + "NHibernate.Dialect." + parts[0]); cfg.SetProperty(Environment.ConnectionDriver, - "NHibernate.Driver.SqliteClientDriver"); - cfg.SetProperty(Environment.ConnectionString, - "URI=file:" + dbfile + ",version=3"); + "NHibernate.Driver." + parts[1]); + cfg.SetProperty(Environment.ConnectionString, parts[2]); cfg.AddAssembly("OpenSim.Data.NHibernate"); HbmSerializer.Default.Validate = true; @@ -76,6 +72,10 @@ namespace OpenSim.Data.NHibernate HbmSerializer.Default.Serialize(Assembly.GetExecutingAssembly())) cfg.AddInputStream(stream); + // If uncommented this will auto create tables, but it + // does drops of the old tables, so we need a smarter way + // to acturally manage this. + // new SchemaExport(cfg).Create(true, true); factory = cfg.BuildSessionFactory(); -- cgit v1.1