From 6dea8f34350d03b94ba6f52d8634598cc2de7503 Mon Sep 17 00:00:00 2001 From: Sean Dague Date: Wed, 18 Jun 2008 21:14:19 +0000 Subject: clean up the nhibernate definitions to work with mysql integrate migration support into nhibernate --- OpenSim/Data/NHibernate/NHibernateAssetData.cs | 27 -------------- OpenSim/Data/NHibernate/NHibernateInventoryData.cs | 42 +++------------------- OpenSim/Data/NHibernate/NHibernateUserData.cs | 38 +++----------------- .../Data/NHibernate/Resources/AssetBase.hbm.xml | 8 ++--- .../Resources/InventoryFolderBase.hbm.xml | 4 +-- .../NHibernate/Resources/InventoryItemBase.hbm.xml | 16 ++++----- .../NHibernate/Resources/UserAgentData.hbm.xml | 4 +-- .../NHibernate/Resources/UserProfileData.hbm.xml | 8 ++--- 8 files changed, 30 insertions(+), 117 deletions(-) (limited to 'OpenSim/Data') diff --git a/OpenSim/Data/NHibernate/NHibernateAssetData.cs b/OpenSim/Data/NHibernate/NHibernateAssetData.cs index bb5a3f3..5c691a7 100644 --- a/OpenSim/Data/NHibernate/NHibernateAssetData.cs +++ b/OpenSim/Data/NHibernate/NHibernateAssetData.cs @@ -93,33 +93,6 @@ namespace OpenSim.Data.NHibernate Assembly assem = GetType().Assembly; Migration m = new Migration((System.Data.Common.DbConnection)factory.ConnectionProvider.GetConnection(), assem, dialect, "AssetStore"); m.Update(); - - } - - private void InitDB() - { - string regex = @"no such table: Assets"; - Regex RE = new Regex(regex, RegexOptions.Multiline); - try - { - using (ISession session = factory.OpenSession()) - { - session.Load(typeof(AssetBase), LLUUID.Zero); - } - } - catch (ObjectNotFoundException) - { - // yes, we know it's not there, but that's ok - } - catch (ADOException e) - { - Match m = RE.Match(e.ToString()); - if (m.Success) - { - // We don't have this table, so create it. - new SchemaExport(cfg).Create(true, true); - } - } } override public AssetBase FetchAsset(LLUUID uuid) diff --git a/OpenSim/Data/NHibernate/NHibernateInventoryData.cs b/OpenSim/Data/NHibernate/NHibernateInventoryData.cs index 902ecfb..2b36386 100644 --- a/OpenSim/Data/NHibernate/NHibernateInventoryData.cs +++ b/OpenSim/Data/NHibernate/NHibernateInventoryData.cs @@ -62,6 +62,7 @@ namespace OpenSim.Data.NHibernate // TODO: make this a real exception type throw new Exception("Malformed Inventory connection string '" + connect + "'"); } + string dialect = parts[0]; // Establish NHibernate Connection cfg = new Configuration(); @@ -74,46 +75,13 @@ namespace OpenSim.Data.NHibernate cfg.SetProperty(Environment.ConnectionString, parts[2]); cfg.AddAssembly("OpenSim.Data.NHibernate"); - HbmSerializer.Default.Validate = true; - using (MemoryStream stream = - 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(); - InitDB(); - } + // This actually does the roll forward assembly stuff + Assembly assem = GetType().Assembly; + Migration m = new Migration((System.Data.Common.DbConnection)factory.ConnectionProvider.GetConnection(), assem, dialect, "AssetStore"); + m.Update(); - private void InitDB() - { - string regex = @"no such table: Inventory"; - Regex RE = new Regex(regex, RegexOptions.Multiline); - try - { - using (ISession session = factory.OpenSession()) - { - session.Load(typeof(InventoryItemBase), LLUUID.Zero); - } - } - catch (ObjectNotFoundException) - { - // yes, we know it's not there, but that's ok - } - catch (ADOException e) - { - Match m = RE.Match(e.ToString()); - if (m.Success) - { - // We don't have this table, so create it. - new SchemaExport(cfg).Create(true, true); - } - } } /***************************************************************** diff --git a/OpenSim/Data/NHibernate/NHibernateUserData.cs b/OpenSim/Data/NHibernate/NHibernateUserData.cs index af9020d..044c14a 100644 --- a/OpenSim/Data/NHibernate/NHibernateUserData.cs +++ b/OpenSim/Data/NHibernate/NHibernateUserData.cs @@ -61,6 +61,7 @@ namespace OpenSim.Data.NHibernate // TODO: make this a real exception type throw new Exception("Malformed Inventory connection string '" + connect + "'"); } + string dialect = parts[0]; // This is stubbing for now, it will become dynamic later and support different db backends cfg = new Configuration(); @@ -73,41 +74,12 @@ namespace OpenSim.Data.NHibernate cfg.SetProperty(Environment.ConnectionString, parts[2]); cfg.AddAssembly("OpenSim.Data.NHibernate"); - HbmSerializer.Default.Validate = true; - using (MemoryStream stream = - HbmSerializer.Default.Serialize(Assembly.GetExecutingAssembly())) - cfg.AddInputStream(stream); - - // new SchemaExport(cfg).Create(true, true); - factory = cfg.BuildSessionFactory(); - InitDB(); - } - private void InitDB() - { - string regex = @"no such table: UserProfiles"; - Regex RE = new Regex(regex, RegexOptions.Multiline); - try - { - using (ISession session = factory.OpenSession()) - { - session.Load(typeof(UserProfileData), LLUUID.Zero); - } - } - catch (ObjectNotFoundException) - { - // yes, we know it's not there, but that's ok - } - catch (ADOException e) - { - Match m = RE.Match(e.ToString()); - if (m.Success) - { - // We don't have this table, so create it. - new SchemaExport(cfg).Create(true, true); - } - } + // This actually does the roll forward assembly stuff + Assembly assem = GetType().Assembly; + Migration m = new Migration((System.Data.Common.DbConnection)factory.ConnectionProvider.GetConnection(), assem, dialect, "AssetStore"); + m.Update(); } private bool ExistsUser(LLUUID uuid) diff --git a/OpenSim/Data/NHibernate/Resources/AssetBase.hbm.xml b/OpenSim/Data/NHibernate/Resources/AssetBase.hbm.xml index 12ab981..261c136 100644 --- a/OpenSim/Data/NHibernate/Resources/AssetBase.hbm.xml +++ b/OpenSim/Data/NHibernate/Resources/AssetBase.hbm.xml @@ -4,10 +4,10 @@ - - - - + + + + diff --git a/OpenSim/Data/NHibernate/Resources/InventoryFolderBase.hbm.xml b/OpenSim/Data/NHibernate/Resources/InventoryFolderBase.hbm.xml index 4411071..8c6d02b 100644 --- a/OpenSim/Data/NHibernate/Resources/InventoryFolderBase.hbm.xml +++ b/OpenSim/Data/NHibernate/Resources/InventoryFolderBase.hbm.xml @@ -4,8 +4,8 @@ - - + + diff --git a/OpenSim/Data/NHibernate/Resources/InventoryItemBase.hbm.xml b/OpenSim/Data/NHibernate/Resources/InventoryItemBase.hbm.xml index c2e5c17..debb2e5 100644 --- a/OpenSim/Data/NHibernate/Resources/InventoryItemBase.hbm.xml +++ b/OpenSim/Data/NHibernate/Resources/InventoryItemBase.hbm.xml @@ -4,23 +4,23 @@ - - + + - - - - + + + + - - + + \ No newline at end of file diff --git a/OpenSim/Data/NHibernate/Resources/UserAgentData.hbm.xml b/OpenSim/Data/NHibernate/Resources/UserAgentData.hbm.xml index b2abeae..718cb98 100644 --- a/OpenSim/Data/NHibernate/Resources/UserAgentData.hbm.xml +++ b/OpenSim/Data/NHibernate/Resources/UserAgentData.hbm.xml @@ -5,7 +5,7 @@ - + @@ -13,7 +13,7 @@ - + diff --git a/OpenSim/Data/NHibernate/Resources/UserProfileData.hbm.xml b/OpenSim/Data/NHibernate/Resources/UserProfileData.hbm.xml index 3e4b5aa..cb83e2c 100644 --- a/OpenSim/Data/NHibernate/Resources/UserProfileData.hbm.xml +++ b/OpenSim/Data/NHibernate/Resources/UserProfileData.hbm.xml @@ -9,16 +9,16 @@ - - + + - - + + -- cgit v1.1