aboutsummaryrefslogtreecommitdiffstatshomepage
path: root/OpenSim/Data/NHibernate
diff options
context:
space:
mode:
Diffstat (limited to '')
-rw-r--r--OpenSim/Data/NHibernate/LLQuaternionUserType.cs6
-rw-r--r--OpenSim/Data/NHibernate/LLVector3UserType.cs7
-rw-r--r--OpenSim/Data/NHibernate/NHibernateAssetData.cs77
-rw-r--r--OpenSim/Data/NHibernate/NHibernateInventoryData.cs107
-rw-r--r--OpenSim/Data/NHibernate/NHibernateManager.cs142
-rw-r--r--OpenSim/Data/NHibernate/NHibernateRegionData.cs124
-rw-r--r--OpenSim/Data/NHibernate/NHibernateUserData.cs155
-rw-r--r--OpenSim/Data/NHibernate/Resources/AssetBase.hbm.xml2
-rw-r--r--OpenSim/Data/NHibernate/Resources/InventoryFolderBase.hbm.xml2
-rw-r--r--OpenSim/Data/NHibernate/Resources/InventoryItemBase.hbm.xml10
-rw-r--r--OpenSim/Data/NHibernate/Resources/MySQLDialect/002_RegionStore.sql4
-rw-r--r--OpenSim/Data/NHibernate/Resources/RegionStore.hbm.xml85
-rw-r--r--OpenSim/Data/NHibernate/Resources/UserAgentData.hbm.xml8
-rw-r--r--OpenSim/Data/NHibernate/Resources/UserProfileData.hbm.xml4
-rw-r--r--OpenSim/Data/NHibernate/Terrain.cs2
15 files changed, 385 insertions, 350 deletions
diff --git a/OpenSim/Data/NHibernate/LLQuaternionUserType.cs b/OpenSim/Data/NHibernate/LLQuaternionUserType.cs
index 0cd5c6f..7431433 100644
--- a/OpenSim/Data/NHibernate/LLQuaternionUserType.cs
+++ b/OpenSim/Data/NHibernate/LLQuaternionUserType.cs
@@ -78,11 +78,7 @@ namespace OpenSim.Data.NHibernate
78 int w = rs.GetOrdinal(names[3]); 78 int w = rs.GetOrdinal(names[3]);
79 if (!rs.IsDBNull(x)) 79 if (!rs.IsDBNull(x))
80 { 80 {
81 float X = (Single)Convert.ToDouble(rs[x].ToString()); 81 quat = new Quaternion((Single)rs[x], (Single)rs[y], (Single)rs[z], (Single)rs[w]);
82 float Y = (Single)Convert.ToDouble(rs[y].ToString());
83 float Z = (Single)Convert.ToDouble(rs[z].ToString());
84 float W = (Single)Convert.ToDouble(rs[w].ToString());
85 quat = new Quaternion(X, Y, Z, W);
86 } 82 }
87 return quat; 83 return quat;
88 } 84 }
diff --git a/OpenSim/Data/NHibernate/LLVector3UserType.cs b/OpenSim/Data/NHibernate/LLVector3UserType.cs
index 25a2bc6..cdd15ec 100644
--- a/OpenSim/Data/NHibernate/LLVector3UserType.cs
+++ b/OpenSim/Data/NHibernate/LLVector3UserType.cs
@@ -74,12 +74,9 @@ namespace OpenSim.Data.NHibernate
74 int x = rs.GetOrdinal(names[0]); 74 int x = rs.GetOrdinal(names[0]);
75 int y = rs.GetOrdinal(names[1]); 75 int y = rs.GetOrdinal(names[1]);
76 int z = rs.GetOrdinal(names[2]); 76 int z = rs.GetOrdinal(names[2]);
77 if (!rs.IsDBNull(x) && !rs.IsDBNull(y) && !rs.IsDBNull(z)) 77 if (!rs.IsDBNull(x))
78 { 78 {
79 float X = (Single)Convert.ToDouble(rs[x].ToString()); 79 vector = new Vector3((Single)rs[x], (Single)rs[y], (Single)rs[z]);
80 float Y = (Single)Convert.ToDouble(rs[y].ToString());
81 float Z = (Single)Convert.ToDouble(rs[z].ToString());
82 vector = new Vector3(X, Y, Z);
83 } 80 }
84 return vector; 81 return vector;
85 } 82 }
diff --git a/OpenSim/Data/NHibernate/NHibernateAssetData.cs b/OpenSim/Data/NHibernate/NHibernateAssetData.cs
index 90d41e3..6ee527e 100644
--- a/OpenSim/Data/NHibernate/NHibernateAssetData.cs
+++ b/OpenSim/Data/NHibernate/NHibernateAssetData.cs
@@ -33,7 +33,10 @@ using System.Text.RegularExpressions;
33using OpenMetaverse; 33using OpenMetaverse;
34using log4net; 34using log4net;
35using NHibernate; 35using NHibernate;
36using NHibernate.Cfg;
37using NHibernate.Expression;
36using NHibernate.Mapping.Attributes; 38using NHibernate.Mapping.Attributes;
39using NHibernate.Tool.hbm2ddl;
37using OpenSim.Framework; 40using OpenSim.Framework;
38using Environment=NHibernate.Cfg.Environment; 41using Environment=NHibernate.Cfg.Environment;
39 42
@@ -46,7 +49,9 @@ namespace OpenSim.Data.NHibernate
46 { 49 {
47 private static readonly ILog m_log = LogManager.GetLogger(MethodBase.GetCurrentMethod().DeclaringType); 50 private static readonly ILog m_log = LogManager.GetLogger(MethodBase.GetCurrentMethod().DeclaringType);
48 51
49 private NHibernateManager manager; 52 private Configuration cfg;
53 private ISessionFactory factory;
54 private ISession session;
50 55
51 override public void Dispose() { } 56 override public void Dispose() { }
52 57
@@ -57,23 +62,79 @@ namespace OpenSim.Data.NHibernate
57 62
58 public override void Initialise(string connect) 63 public override void Initialise(string connect)
59 { 64 {
65 // Split out the dialect, driver, and connect string
66 char[] split = {';'};
67 string[] parts = connect.Split(split, 3);
68 if (parts.Length != 3)
69 {
70 // TODO: make this a real exception type
71 throw new Exception("Malformed Inventory connection string '" + connect + "'");
72 }
73
74 string dialect = parts[0];
75
76 // NHibernate setup
77 cfg = new Configuration();
78 cfg.SetProperty(Environment.ConnectionProvider,
79 "NHibernate.Connection.DriverConnectionProvider");
80 cfg.SetProperty(Environment.Dialect,
81 "NHibernate.Dialect." + dialect);
82 cfg.SetProperty(Environment.ConnectionDriver,
83 "NHibernate.Driver." + parts[1]);
84 cfg.SetProperty(Environment.ConnectionString, parts[2]);
85 cfg.AddAssembly("OpenSim.Data.NHibernate");
86
60 87
61 m_log.InfoFormat("[NHIBERNATE] Initializing NHibernateAssetData"); 88
62 manager = new NHibernateManager(connect, "AssetStore"); 89 HbmSerializer.Default.Validate = true;
90 using (MemoryStream stream =
91 HbmSerializer.Default.Serialize(Assembly.GetExecutingAssembly()))
92 cfg.AddInputStream(stream);
93
94 factory = cfg.BuildSessionFactory();
95 session = factory.OpenSession();
96
97 // This actually does the roll forward assembly stuff
98 Assembly assem = GetType().Assembly;
99 Migration m = new Migration((System.Data.Common.DbConnection)factory.ConnectionProvider.GetConnection(), assem, dialect, "AssetStore");
100 m.Update();
63 101
64 } 102 }
65 103
66 override public AssetBase FetchAsset(UUID uuid) 104 override public AssetBase FetchAsset(UUID uuid)
67 { 105 {
68 return (AssetBase)manager.Load(typeof(AssetBase), uuid); 106 try
107 {
108 return session.Load(typeof(AssetBase), uuid) as AssetBase;
109 }
110 catch (ObjectNotFoundException)
111 {
112 m_log.ErrorFormat("[NHIBERNATE] no such asset {0}", uuid);
113 return null;
114 }
115 catch (Exception e)
116 {
117 m_log.Error("[NHIBERNATE] unexpected exception: ", e);
118 return null;
119 }
69 } 120 }
70 121
71 private void Save(AssetBase asset) 122 private void Save(AssetBase asset)
72 { 123 {
73 AssetBase temp = (AssetBase)manager.Load(typeof(AssetBase), asset.FullID); 124 try
74 if (temp == null)
75 { 125 {
76 manager.Save(asset); 126 // a is not used anywhere?
127 // AssetBase a = session.Load(typeof(AssetBase), asset.FullID) as AssetBase;
128 session.Load(typeof(AssetBase), asset.FullID);
129 }
130 catch (ObjectNotFoundException)
131 {
132 session.Save(asset);
133 session.Flush();
134 }
135 catch (Exception e)
136 {
137 m_log.Error("[NHIBERNATE] issue saving asset", e);
77 } 138 }
78 } 139 }
79 140
@@ -86,7 +147,7 @@ namespace OpenSim.Data.NHibernate
86 override public void UpdateAsset(AssetBase asset) 147 override public void UpdateAsset(AssetBase asset)
87 { 148 {
88 m_log.InfoFormat("[NHIBERNATE] updating asset {0}", asset.FullID); 149 m_log.InfoFormat("[NHIBERNATE] updating asset {0}", asset.FullID);
89 manager.Update(asset); 150 Save(asset);
90 } 151 }
91 152
92 // private void LogAssetLoad(AssetBase asset) 153 // private void LogAssetLoad(AssetBase asset)
diff --git a/OpenSim/Data/NHibernate/NHibernateInventoryData.cs b/OpenSim/Data/NHibernate/NHibernateInventoryData.cs
index f7de8eb..bceb5d5 100644
--- a/OpenSim/Data/NHibernate/NHibernateInventoryData.cs
+++ b/OpenSim/Data/NHibernate/NHibernateInventoryData.cs
@@ -33,7 +33,10 @@ using System.Text.RegularExpressions;
33using OpenMetaverse; 33using OpenMetaverse;
34using log4net; 34using log4net;
35using NHibernate; 35using NHibernate;
36using NHibernate.Criterion; 36using NHibernate.Cfg;
37using NHibernate.Expression;
38using NHibernate.Mapping.Attributes;
39using NHibernate.Tool.hbm2ddl;
37using OpenSim.Framework; 40using OpenSim.Framework;
38using Environment=NHibernate.Cfg.Environment; 41using Environment=NHibernate.Cfg.Environment;
39 42
@@ -43,7 +46,9 @@ namespace OpenSim.Data.NHibernate
43 { 46 {
44 private static readonly ILog m_log = LogManager.GetLogger(MethodBase.GetCurrentMethod().DeclaringType); 47 private static readonly ILog m_log = LogManager.GetLogger(MethodBase.GetCurrentMethod().DeclaringType);
45 48
46 private NHibernateManager manager; 49 private Configuration cfg;
50 private ISessionFactory factory;
51 private ISession session;
47 52
48 public void Initialise() 53 public void Initialise()
49 { 54 {
@@ -56,8 +61,35 @@ namespace OpenSim.Data.NHibernate
56 /// </summary> 61 /// </summary>
57 public void Initialise(string connect) 62 public void Initialise(string connect)
58 { 63 {
59 m_log.InfoFormat("[NHIBERNATE] Initializing NHibernateInventoryData"); 64 // Split out the dialect, driver, and connect string
60 manager = new NHibernateManager(connect, "InventoryStore"); 65 char[] split = {';'};
66 string[] parts = connect.Split(split, 3);
67 if (parts.Length != 3)
68 {
69 // TODO: make this a real exception type
70 throw new Exception("Malformed Inventory connection string '" + connect + "'");
71 }
72 string dialect = parts[0];
73
74 // Establish NHibernate Connection
75 cfg = new Configuration();
76 cfg.SetProperty(Environment.ConnectionProvider,
77 "NHibernate.Connection.DriverConnectionProvider");
78 cfg.SetProperty(Environment.Dialect,
79 "NHibernate.Dialect." + parts[0]);
80 cfg.SetProperty(Environment.ConnectionDriver,
81 "NHibernate.Driver." + parts[1]);
82 cfg.SetProperty(Environment.ConnectionString, parts[2]);
83 cfg.AddAssembly("OpenSim.Data.NHibernate");
84
85 factory = cfg.BuildSessionFactory();
86 session = factory.OpenSession();
87
88 // This actually does the roll forward assembly stuff
89 Assembly assem = GetType().Assembly;
90 Migration m = new Migration((System.Data.Common.DbConnection)factory.ConnectionProvider.GetConnection(), assem, dialect, "InventoryStore");
91 m.Update();
92
61 } 93 }
62 94
63 /***************************************************************** 95 /*****************************************************************
@@ -77,8 +109,7 @@ namespace OpenSim.Data.NHibernate
77 { 109 {
78 try 110 try
79 { 111 {
80 m_log.InfoFormat("[NHIBERNATE] getInventoryItem {0}", item); 112 return session.Load(typeof(InventoryItemBase), item) as InventoryItemBase;
81 return (InventoryItemBase)manager.Load(typeof(InventoryItemBase), item);
82 } 113 }
83 catch 114 catch
84 { 115 {
@@ -95,11 +126,15 @@ namespace OpenSim.Data.NHibernate
95 { 126 {
96 if (!ExistsItem(item.ID)) 127 if (!ExistsItem(item.ID))
97 { 128 {
98 manager.Save(item); 129 using (ITransaction transaction = session.BeginTransaction())
130 {
131 session.Save(item);
132 transaction.Commit();
133 }
99 } 134 }
100 else 135 else
101 { 136 {
102 m_log.ErrorFormat("[NHIBERNATE] Attempted to add Inventory Item {0} that already exists, updating instead", item.ID); 137 m_log.ErrorFormat("Attempted to add Inventory Item {0} that already exists, updating instead", item.ID);
103 updateInventoryItem(item); 138 updateInventoryItem(item);
104 } 139 }
105 } 140 }
@@ -112,11 +147,15 @@ namespace OpenSim.Data.NHibernate
112 { 147 {
113 if (ExistsItem(item.ID)) 148 if (ExistsItem(item.ID))
114 { 149 {
115 manager.Update(item); 150 using (ITransaction transaction = session.BeginTransaction())
151 {
152 session.Update(item);
153 transaction.Commit();
154 }
116 } 155 }
117 else 156 else
118 { 157 {
119 m_log.ErrorFormat("[NHIBERNATE] Attempted to add Inventory Item {0} that already exists", item.ID); 158 m_log.ErrorFormat("Attempted to add Inventory Item {0} that already exists", item.ID);
120 } 159 }
121 } 160 }
122 161
@@ -126,16 +165,11 @@ namespace OpenSim.Data.NHibernate
126 /// <param name="item"></param> 165 /// <param name="item"></param>
127 public void deleteInventoryItem(UUID itemID) 166 public void deleteInventoryItem(UUID itemID)
128 { 167 {
129 InventoryItemBase item = (InventoryItemBase)manager.Load(typeof(InventoryItemBase), itemID); 168 using (ITransaction transaction = session.BeginTransaction())
130 if (item != null)
131 { 169 {
132 manager.Delete(item); 170 session.Delete(itemID);
171 transaction.Commit();
133 } 172 }
134 else
135 {
136 m_log.ErrorFormat("[NHIBERNATE] Error deleting InventoryItemBase {0}", itemID);
137 }
138
139 } 173 }
140 174
141 /// <summary> 175 /// <summary>
@@ -147,11 +181,11 @@ namespace OpenSim.Data.NHibernate
147 { 181 {
148 try 182 try
149 { 183 {
150 return (InventoryFolderBase)manager.Load(typeof(InventoryFolderBase), folder); 184 return session.Load(typeof(InventoryFolderBase), folder) as InventoryFolderBase;
151 } 185 }
152 catch 186 catch
153 { 187 {
154 m_log.ErrorFormat("[NHIBERNATE] Couldn't find inventory item: {0}", folder); 188 m_log.ErrorFormat("Couldn't find inventory item: {0}", folder);
155 return null; 189 return null;
156 } 190 }
157 } 191 }
@@ -164,11 +198,15 @@ namespace OpenSim.Data.NHibernate
164 { 198 {
165 if (!ExistsFolder(folder.ID)) 199 if (!ExistsFolder(folder.ID))
166 { 200 {
167 manager.Save(folder); 201 using (ITransaction transaction = session.BeginTransaction())
202 {
203 session.Save(folder);
204 transaction.Commit();
205 }
168 } 206 }
169 else 207 else
170 { 208 {
171 m_log.ErrorFormat("[NHIBERNATE] Attempted to add Inventory Folder {0} that already exists, updating instead", folder.ID); 209 m_log.ErrorFormat("Attempted to add Inventory Folder {0} that already exists, updating instead", folder.ID);
172 updateInventoryFolder(folder); 210 updateInventoryFolder(folder);
173 } 211 }
174 } 212 }
@@ -181,11 +219,15 @@ namespace OpenSim.Data.NHibernate
181 { 219 {
182 if (ExistsFolder(folder.ID)) 220 if (ExistsFolder(folder.ID))
183 { 221 {
184 manager.Update(folder); 222 using (ITransaction transaction = session.BeginTransaction())
223 {
224 session.Update(folder);
225 transaction.Commit();
226 }
185 } 227 }
186 else 228 else
187 { 229 {
188 m_log.ErrorFormat("[NHIBERNATE] Attempted to add Inventory Folder {0} that already exists", folder.ID); 230 m_log.ErrorFormat("Attempted to add Inventory Folder {0} that already exists", folder.ID);
189 } 231 }
190 } 232 }
191 233
@@ -195,16 +237,11 @@ namespace OpenSim.Data.NHibernate
195 /// <param name="folder"></param> 237 /// <param name="folder"></param>
196 public void deleteInventoryFolder(UUID folderID) 238 public void deleteInventoryFolder(UUID folderID)
197 { 239 {
198 InventoryFolderBase item = (InventoryFolderBase)manager.Load(typeof(InventoryFolderBase), folderID); 240 using (ITransaction transaction = session.BeginTransaction())
199 if (item != null)
200 {
201 manager.Delete(item);
202 }
203 else
204 { 241 {
205 m_log.ErrorFormat("[NHIBERNATE] Error deleting InventoryFolderBase {0}", folderID); 242 session.Delete(folderID.ToString());
243 transaction.Commit();
206 } 244 }
207 manager.Delete(folderID);
208 } 245 }
209 246
210 // useful private methods 247 // useful private methods
@@ -280,7 +317,7 @@ namespace OpenSim.Data.NHibernate
280 public List<InventoryItemBase> getInventoryInFolder(UUID folderID) 317 public List<InventoryItemBase> getInventoryInFolder(UUID folderID)
281 { 318 {
282 // try { 319 // try {
283 ICriteria criteria = manager.GetSession().CreateCriteria(typeof(InventoryItemBase)); 320 ICriteria criteria = session.CreateCriteria(typeof(InventoryItemBase));
284 criteria.Add(Expression.Eq("Folder", folderID)); 321 criteria.Add(Expression.Eq("Folder", folderID));
285 List<InventoryItemBase> list = new List<InventoryItemBase>(); 322 List<InventoryItemBase> list = new List<InventoryItemBase>();
286 foreach (InventoryItemBase item in criteria.List()) 323 foreach (InventoryItemBase item in criteria.List())
@@ -303,7 +340,7 @@ namespace OpenSim.Data.NHibernate
303 // see InventoryItemBase.getUserRootFolder 340 // see InventoryItemBase.getUserRootFolder
304 public InventoryFolderBase getUserRootFolder(UUID user) 341 public InventoryFolderBase getUserRootFolder(UUID user)
305 { 342 {
306 ICriteria criteria = manager.GetSession().CreateCriteria(typeof(InventoryFolderBase)); 343 ICriteria criteria = session.CreateCriteria(typeof(InventoryFolderBase));
307 criteria.Add(Expression.Eq("ParentID", UUID.Zero)); 344 criteria.Add(Expression.Eq("ParentID", UUID.Zero));
308 criteria.Add(Expression.Eq("Owner", user)); 345 criteria.Add(Expression.Eq("Owner", user));
309 foreach (InventoryFolderBase folder in criteria.List()) 346 foreach (InventoryFolderBase folder in criteria.List())
@@ -321,7 +358,7 @@ namespace OpenSim.Data.NHibernate
321 /// <param name="parentID">ID of parent</param> 358 /// <param name="parentID">ID of parent</param>
322 private void getInventoryFolders(ref List<InventoryFolderBase> folders, UUID parentID) 359 private void getInventoryFolders(ref List<InventoryFolderBase> folders, UUID parentID)
323 { 360 {
324 ICriteria criteria = manager.GetSession().CreateCriteria(typeof(InventoryFolderBase)); 361 ICriteria criteria = session.CreateCriteria(typeof(InventoryFolderBase));
325 criteria.Add(Expression.Eq("ParentID", parentID)); 362 criteria.Add(Expression.Eq("ParentID", parentID));
326 foreach (InventoryFolderBase item in criteria.List()) 363 foreach (InventoryFolderBase item in criteria.List())
327 { 364 {
diff --git a/OpenSim/Data/NHibernate/NHibernateManager.cs b/OpenSim/Data/NHibernate/NHibernateManager.cs
index 36d84e2..161ec1d 100644
--- a/OpenSim/Data/NHibernate/NHibernateManager.cs
+++ b/OpenSim/Data/NHibernate/NHibernateManager.cs
@@ -25,141 +25,35 @@
25 * SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. 25 * SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
26 */ 26 */
27 27
28using System;
29using System.Reflection; 28using System.Reflection;
30using System.IO;
31using log4net; 29using log4net;
32using NHibernate; 30using NHibernate;
33using NHibernate.Cfg;
34using NHibernate.Mapping.Attributes;
35using NHibernate.Tool.hbm2ddl;
36using OpenMetaverse;
37using Environment = NHibernate.Cfg.Environment;
38 31
39namespace OpenSim.Data.NHibernate 32namespace OpenSim.Data.NHibernate
40{ 33{
41 public class NHibernateManager 34 internal class NHibernateManager
42 { 35 {
43 private static readonly ILog m_log = LogManager.GetLogger(MethodBase.GetCurrentMethod().DeclaringType); 36 // private static readonly ILog m_log = LogManager.GetLogger(MethodBase.GetCurrentMethod().DeclaringType);
44 37
45 private string dialect; 38 // private ISessionFactory factory;
46 private Configuration cfg; 39 // private ISession session;
47 private ISessionFactory factory; 40 // private ITransaction transaction;
48 private ISession session;
49 41
50 public NHibernateManager(string connect, string store) 42 public NHibernateManager()
51 { 43 {
52 44 // This is stubbing for now, it will become dynamic later and support different db backends
53 // Split out the dialect, driver, and connect string 45// NHibernate.Cfg.Configuration cfg = new NHibernate.Cfg.Configuration();
54 char[] split = { ';' }; 46// cfg.Properties[NHibernate.Cfg.Environment.ConnectionProvider] =
55 string[] parts = connect.Split(split, 3); 47// "NHibernate.Connection.DriverConnectionProvider";
56 if (parts.Length != 3) 48// cfg.Properties[NHibernate.Cfg.Environment.Dialect] =
57 { 49// "NHibernate.Dialect.SQLite";
58 // TODO: make this a real exception type 50// cfg.Properties[NHibernate.Cfg.Environment.ConnectionDriver] =
59 throw new Exception("Malformed Inventory connection string '" + connect + "'"); 51// "NHibernate.Driver.SqliteClientDriver";
60 } 52// cfg.Properties[NHibernate.Cfg.Environment.ConnectionString] =
61 53// "URI=file:opensim-nh.db,version=3";
62 dialect = parts[0]; 54
63 55// factory = cfg.BuildSessionFactory();
64 // NHibernate setup
65 cfg = new Configuration();
66 cfg.SetProperty(Environment.ConnectionProvider,
67 "NHibernate.Connection.DriverConnectionProvider");
68 cfg.SetProperty(Environment.Dialect,
69 "NHibernate.Dialect." + dialect);
70 cfg.SetProperty(Environment.ConnectionDriver,
71 "NHibernate.Driver." + parts[1]);
72 cfg.SetProperty(Environment.ConnectionString, parts[2]);
73 cfg.AddAssembly("OpenSim.Data.NHibernate");
74
75 //To create sql file uncomment code below and write the name of the file
76 //SchemaExport exp = new SchemaExport(cfg);
77 //exp.SetOutputFile("nameofthefile.sql");
78 //exp.Create(false, true);
79
80 HbmSerializer.Default.Validate = true;
81 using (MemoryStream stream =
82 HbmSerializer.Default.Serialize(Assembly.GetExecutingAssembly()))
83 cfg.AddInputStream(stream);
84
85 factory = cfg.BuildSessionFactory();
86 session = factory.OpenSession();
87
88 Assembly assem = GetType().Assembly;
89 Migration m = new Migration((System.Data.Common.DbConnection)factory.ConnectionProvider.GetConnection(), assem, dialect, store);
90 m.Update();
91 } 56 }
92 57
93 public object Load(Type type, UUID uuid)
94 {
95 object obj = null;
96 try
97 {
98 obj = session.Load(type, uuid);
99 }
100 catch (Exception)
101 {
102 m_log.ErrorFormat("[NHIBERNATE] {0} not found with ID {1} ", type.Name, uuid);
103 }
104 return obj;
105
106 }
107
108 public bool Save(object obj)
109 {
110 try
111 {
112 session.BeginTransaction();
113 session.Save(obj);
114 session.Transaction.Commit();
115 session.Flush();
116 return true;
117 }
118 catch (Exception e)
119 {
120 m_log.Error("[NHIBERNATE] issue saving object ", e);
121 }
122 return false;
123 }
124
125 public bool Update(object obj)
126 {
127 try
128 {
129 session.BeginTransaction();
130 session.Update(obj);
131 session.Transaction.Commit();
132 session.Flush();
133 return true;
134 }
135 catch (Exception e)
136 {
137 m_log.Error("[NHIBERNATE] issue updating object ", e);
138 }
139 return false;
140 }
141
142 public bool Delete(object obj)
143 {
144 try
145 {
146 session.BeginTransaction();
147 session.Delete(obj);
148 session.Transaction.Commit();
149 session.Flush();
150 return true;
151 }
152 catch (Exception e)
153 {
154
155 m_log.Error("[NHIBERNATE] issue deleting object ", e);
156 }
157 return false;
158 }
159
160 public ISession GetSession()
161 {
162 return session;
163 }
164 } 58 }
165} 59}
diff --git a/OpenSim/Data/NHibernate/NHibernateRegionData.cs b/OpenSim/Data/NHibernate/NHibernateRegionData.cs
index 0aba58c..475cd71 100644
--- a/OpenSim/Data/NHibernate/NHibernateRegionData.cs
+++ b/OpenSim/Data/NHibernate/NHibernateRegionData.cs
@@ -34,7 +34,10 @@ using System.Text.RegularExpressions;
34using OpenMetaverse; 34using OpenMetaverse;
35using log4net; 35using log4net;
36using NHibernate; 36using NHibernate;
37using NHibernate.Criterion; 37using NHibernate.Cfg;
38using NHibernate.Expression;
39using NHibernate.Mapping.Attributes;
40using NHibernate.Tool.hbm2ddl;
38using OpenSim.Framework; 41using OpenSim.Framework;
39using OpenSim.Region.Environment.Interfaces; 42using OpenSim.Region.Environment.Interfaces;
40using OpenSim.Region.Environment.Scenes; 43using OpenSim.Region.Environment.Scenes;
@@ -49,12 +52,51 @@ namespace OpenSim.Data.NHibernate
49 { 52 {
50 private static readonly ILog m_log = LogManager.GetLogger(MethodBase.GetCurrentMethod().DeclaringType); 53 private static readonly ILog m_log = LogManager.GetLogger(MethodBase.GetCurrentMethod().DeclaringType);
51 54
52 private NHibernateManager manager; 55 private Configuration cfg;
56 private ISessionFactory factory;
57 private ISession session;
58
59 // public void Initialise()
60 // {
61 // Initialise("SQLiteDialect;SqliteClientDriver;URI=file:OpenSim.db,version=3", true);
62 // }
53 63
54 public void Initialise(string connect) 64 public void Initialise(string connect)
55 { 65 {
56 m_log.InfoFormat("[NHIBERNATE] Initializing NHibernateRegionData"); 66 // Split out the dialect, driver, and connect string
57 manager = new NHibernateManager(connect, "RegionStore"); 67 char[] split = {';'};
68 string[] parts = connect.Split(split, 3);
69 if (parts.Length != 3)
70 {
71 // TODO: make this a real exception type
72 throw new Exception("Malformed Region connection string '" + connect + "'");
73 }
74
75 string dialect = parts[0];
76
77 // NHibernate setup
78 cfg = new Configuration();
79 cfg.SetProperty(Environment.ConnectionProvider,
80 "NHibernate.Connection.DriverConnectionProvider");
81 cfg.SetProperty(Environment.Dialect,
82 "NHibernate.Dialect." + dialect);
83 cfg.SetProperty(Environment.ConnectionDriver,
84 "NHibernate.Driver." + parts[1]);
85 cfg.SetProperty(Environment.ConnectionString, parts[2]);
86 cfg.AddAssembly("OpenSim.Data.NHibernate");
87
88 HbmSerializer.Default.Validate = true;
89 using (MemoryStream stream =
90 HbmSerializer.Default.Serialize(Assembly.GetExecutingAssembly()))
91 cfg.AddInputStream(stream);
92
93 factory = cfg.BuildSessionFactory();
94 session = factory.OpenSession();
95
96 // This actually does the roll forward assembly stuff
97 Assembly assem = GetType().Assembly;
98 Migration m = new Migration((System.Data.Common.DbConnection)factory.ConnectionProvider.GetConnection(), assem, dialect, "RegionStore");
99 m.Update();
58 } 100 }
59 101
60 /*********************************************************************** 102 /***********************************************************************
@@ -80,18 +122,15 @@ namespace OpenSim.Data.NHibernate
80 { 122 {
81 try 123 try
82 { 124 {
83 SceneObjectPart old = (SceneObjectPart)manager.Load(typeof(SceneObjectPart), p.UUID); 125 SceneObjectPart old = session.Load(typeof(SceneObjectPart), p.UUID) as SceneObjectPart;
84 if (old != null) 126 session.Evict(old);
85 { 127 session.Update(p);
86 m_log.InfoFormat("[NHIBERNATE] updating object {0}", p.UUID); 128 m_log.InfoFormat("[NHIBERNATE] updating object {0}", p.UUID);
87 manager.Update(old); 129 }
88 } 130 catch (ObjectNotFoundException)
89 else 131 {
90 { 132 m_log.InfoFormat("[NHIBERNATE] saving object {0}", p.UUID);
91 m_log.InfoFormat("[NHIBERNATE] saving object {0}", p.UUID); 133 session.Save(p);
92 manager.Save(p);
93 }
94
95 } 134 }
96 catch (Exception e) 135 catch (Exception e)
97 { 136 {
@@ -103,19 +142,15 @@ namespace OpenSim.Data.NHibernate
103 { 142 {
104 try 143 try
105 { 144 {
106 145 Terrain old = session.Load(typeof(Terrain), t.RegionID) as Terrain;
107 Terrain old = (Terrain)manager.Load(typeof(Terrain), t.RegionID); 146 session.Evict(old);
108 if (old != null) 147 session.Update(t);
109 { 148 session.Flush();
110 m_log.InfoFormat("[NHIBERNATE] updating terrain {0}", t.RegionID); 149 }
111 manager.Update(old); 150 catch (ObjectNotFoundException)
112 } 151 {
113 else 152 session.Save(t);
114 { 153 session.Flush();
115 m_log.InfoFormat("[NHIBERNATE] saving terrain {0}", t.RegionID);
116 manager.Save(t);
117 }
118
119 } 154 }
120 catch (Exception e) 155 catch (Exception e)
121 { 156 {
@@ -138,6 +173,7 @@ namespace OpenSim.Data.NHibernate
138 m_log.InfoFormat("Storing part {0}", part.UUID); 173 m_log.InfoFormat("Storing part {0}", part.UUID);
139 SaveOrUpdate(part); 174 SaveOrUpdate(part);
140 } 175 }
176 session.Flush();
141 } 177 }
142 catch (Exception e) 178 catch (Exception e)
143 { 179 {
@@ -149,7 +185,7 @@ namespace OpenSim.Data.NHibernate
149 { 185 {
150 SceneObjectGroup group = new SceneObjectGroup(); 186 SceneObjectGroup group = new SceneObjectGroup();
151 187
152 ICriteria criteria = manager.GetSession().CreateCriteria(typeof(SceneObjectPart)); 188 ICriteria criteria = session.CreateCriteria(typeof(SceneObjectPart));
153 criteria.Add(Expression.Eq("RegionID", region)); 189 criteria.Add(Expression.Eq("RegionID", region));
154 criteria.Add(Expression.Eq("ParentUUID", uuid)); 190 criteria.Add(Expression.Eq("ParentUUID", uuid));
155 criteria.AddOrder( Order.Asc("ParentID") ); 191 criteria.AddOrder( Order.Asc("ParentID") );
@@ -180,8 +216,9 @@ namespace OpenSim.Data.NHibernate
180 SceneObjectGroup g = LoadObject(obj, regionUUID); 216 SceneObjectGroup g = LoadObject(obj, regionUUID);
181 foreach (SceneObjectPart p in g.Children.Values) 217 foreach (SceneObjectPart p in g.Children.Values)
182 { 218 {
183 manager.Delete(p); 219 session.Delete(p);
184 } 220 }
221 session.Flush();
185 222
186 m_log.InfoFormat("[REGION DB]: Removing obj: {0} from region: {1}", obj.Guid, regionUUID); 223 m_log.InfoFormat("[REGION DB]: Removing obj: {0} from region: {1}", obj.Guid, regionUUID);
187 224
@@ -197,7 +234,7 @@ namespace OpenSim.Data.NHibernate
197 Dictionary<UUID, SceneObjectGroup> SOG = new Dictionary<UUID, SceneObjectGroup>(); 234 Dictionary<UUID, SceneObjectGroup> SOG = new Dictionary<UUID, SceneObjectGroup>();
198 List<SceneObjectGroup> ret = new List<SceneObjectGroup>(); 235 List<SceneObjectGroup> ret = new List<SceneObjectGroup>();
199 236
200 ICriteria criteria = manager.GetSession().CreateCriteria(typeof(SceneObjectPart)); 237 ICriteria criteria = session.CreateCriteria(typeof(SceneObjectPart));
201 criteria.Add(Expression.Eq("RegionID", regionUUID)); 238 criteria.Add(Expression.Eq("RegionID", regionUUID));
202 criteria.AddOrder( Order.Asc("ParentID") ); 239 criteria.AddOrder( Order.Asc("ParentID") );
203 foreach (SceneObjectPart p in criteria.List()) 240 foreach (SceneObjectPart p in criteria.List())
@@ -215,7 +252,7 @@ namespace OpenSim.Data.NHibernate
215 } 252 }
216 // get the inventory 253 // get the inventory
217 254
218 ICriteria InvCriteria = manager.GetSession().CreateCriteria(typeof(TaskInventoryItem)); 255 ICriteria InvCriteria = session.CreateCriteria(typeof(TaskInventoryItem));
219 InvCriteria.Add(Expression.Eq("ParentPartID", p.UUID)); 256 InvCriteria.Add(Expression.Eq("ParentPartID", p.UUID));
220 IList<TaskInventoryItem> inventory = new List<TaskInventoryItem>(); 257 IList<TaskInventoryItem> inventory = new List<TaskInventoryItem>();
221 foreach (TaskInventoryItem i in InvCriteria.List()) 258 foreach (TaskInventoryItem i in InvCriteria.List())
@@ -254,14 +291,16 @@ namespace OpenSim.Data.NHibernate
254 /// <returns>Heightfield data</returns> 291 /// <returns>Heightfield data</returns>
255 public double[,] LoadTerrain(UUID regionID) 292 public double[,] LoadTerrain(UUID regionID)
256 { 293 {
257 Terrain t = (Terrain)manager.Load(typeof(Terrain), regionID); 294 try
258 if (t != null)
259 { 295 {
296 Terrain t = session.Load(typeof(Terrain), regionID) as Terrain;
260 return t.Doubles; 297 return t.Doubles;
261 } 298 }
262 299 catch (ObjectNotFoundException)
263 m_log.Info("No terrain yet"); 300 {
264 return null; 301 m_log.Info("No terrain yet");
302 return null;
303 }
265 } 304 }
266 305
267 /// <summary> 306 /// <summary>
@@ -300,7 +339,7 @@ namespace OpenSim.Data.NHibernate
300 /// </summary> 339 /// </summary>
301 public void Shutdown() 340 public void Shutdown()
302 { 341 {
303 //session.Flush(); 342 session.Flush();
304 } 343 }
305 344
306 /// <summary> 345 /// <summary>
@@ -358,20 +397,21 @@ namespace OpenSim.Data.NHibernate
358 /// <param name="items"></param> 397 /// <param name="items"></param>
359 public void StorePrimInventory(UUID primID, ICollection<TaskInventoryItem> items) 398 public void StorePrimInventory(UUID primID, ICollection<TaskInventoryItem> items)
360 { 399 {
361 ICriteria criteria = manager.GetSession().CreateCriteria(typeof(TaskInventoryItem)); 400 ICriteria criteria = session.CreateCriteria(typeof(TaskInventoryItem));
362 criteria.Add(Expression.Eq("ParentPartID", primID)); 401 criteria.Add(Expression.Eq("ParentPartID", primID));
363 try 402 try
364 { 403 {
365 foreach (TaskInventoryItem i in criteria.List()) 404 foreach (TaskInventoryItem i in criteria.List())
366 { 405 {
367 manager.Delete(i); 406 session.Delete(i);
368 } 407 }
369 408
370 foreach (TaskInventoryItem i in items) 409 foreach (TaskInventoryItem i in items)
371 { 410 {
372 manager.Save(i); 411 session.Save(i);
373 412
374 } 413 }
414 session.Flush();
375 } 415 }
376 catch (Exception e) 416 catch (Exception e)
377 { 417 {
diff --git a/OpenSim/Data/NHibernate/NHibernateUserData.cs b/OpenSim/Data/NHibernate/NHibernateUserData.cs
index ee0d2b8..3a22dc3 100644
--- a/OpenSim/Data/NHibernate/NHibernateUserData.cs
+++ b/OpenSim/Data/NHibernate/NHibernateUserData.cs
@@ -33,7 +33,10 @@ using System.Text.RegularExpressions;
33using OpenMetaverse; 33using OpenMetaverse;
34using log4net; 34using log4net;
35using NHibernate; 35using NHibernate;
36using NHibernate.Criterion; 36using NHibernate.Cfg;
37using NHibernate.Expression;
38using NHibernate.Mapping.Attributes;
39using NHibernate.Tool.hbm2ddl;
37using OpenSim.Framework; 40using OpenSim.Framework;
38using Environment=NHibernate.Cfg.Environment; 41using Environment=NHibernate.Cfg.Environment;
39 42
@@ -46,7 +49,9 @@ namespace OpenSim.Data.NHibernate
46 { 49 {
47 private static readonly ILog m_log = LogManager.GetLogger(MethodBase.GetCurrentMethod().DeclaringType); 50 private static readonly ILog m_log = LogManager.GetLogger(MethodBase.GetCurrentMethod().DeclaringType);
48 51
49 private NHibernateManager manager; 52 private Configuration cfg;
53 private ISessionFactory factory;
54 private ISession session;
50 55
51 public override void Initialise() 56 public override void Initialise()
52 { 57 {
@@ -56,40 +61,62 @@ namespace OpenSim.Data.NHibernate
56 61
57 public override void Initialise(string connect) 62 public override void Initialise(string connect)
58 { 63 {
59 m_log.InfoFormat("[NHIBERNATE] Initializing NHibernateUserData"); 64 char[] split = {';'};
60 manager = new NHibernateManager(connect, "UserStore"); 65 string[] parts = connect.Split(split, 3);
66 if (parts.Length != 3)
67 {
68 // TODO: make this a real exception type
69 throw new Exception("Malformed Inventory connection string '" + connect + "'");
70 }
71 string dialect = parts[0];
72
73 // This is stubbing for now, it will become dynamic later and support different db backends
74 cfg = new Configuration();
75 cfg.SetProperty(Environment.ConnectionProvider,
76 "NHibernate.Connection.DriverConnectionProvider");
77 cfg.SetProperty(Environment.Dialect,
78 "NHibernate.Dialect." + parts[0]);
79 cfg.SetProperty(Environment.ConnectionDriver,
80 "NHibernate.Driver." + parts[1]);
81 cfg.SetProperty(Environment.ConnectionString, parts[2]);
82 cfg.AddAssembly("OpenSim.Data.NHibernate");
83
84 factory = cfg.BuildSessionFactory();
85 session = factory.OpenSession();
86
87 // This actually does the roll forward assembly stuff
88 Assembly assem = GetType().Assembly;
89 Migration m = new Migration((System.Data.Common.DbConnection)factory.ConnectionProvider.GetConnection(), assem, dialect, "UserStore");
90 m.Update();
61 } 91 }
62 92
63 private bool ExistsUser(UUID uuid) 93 private bool ExistsUser(UUID uuid)
64 { 94 {
65 UserProfileData user = null; 95 UserProfileData user = null;
66 96 try
67 m_log.InfoFormat("[NHIBERNATE] ExistsUser; {0}", uuid);
68 user = (UserProfileData)manager.Load(typeof(UserProfileData), uuid);
69
70 if (user == null)
71 { 97 {
72 m_log.InfoFormat("[NHIBERNATE] User with given UUID does not exist {0} ", uuid); 98 user = session.Load(typeof(UserProfileData), uuid) as UserProfileData;
73 return false; 99 }
100 catch (ObjectNotFoundException)
101 {
102 user = null;
74 } 103 }
75 104
76 return true; 105 return (user != null);
77
78 } 106 }
79 107
80 override public UserProfileData GetUserByUUID(UUID uuid) 108 override public UserProfileData GetUserByUUID(UUID uuid)
81 { 109 {
82 UserProfileData user; 110 UserProfileData user;
83 m_log.InfoFormat("[NHIBERNATE] GetUserByUUID: {0} ", uuid); 111 // TODO: I'm sure I'll have to do something silly here
84 112 try
85 user = (UserProfileData)manager.Load(typeof(UserProfileData), uuid);
86 if (user != null)
87 { 113 {
88 UserAgentData agent = GetAgentByUUID(uuid); 114 user = session.Load(typeof(UserProfileData), uuid) as UserProfileData;
89 if (agent != null) 115 user.CurrentAgent = GetAgentByUUID(uuid);
90 { 116 }
91 user.CurrentAgent = agent; 117 catch (ObjectNotFoundException)
92 } 118 {
119 user = null;
93 } 120 }
94 121
95 return user; 122 return user;
@@ -99,30 +126,33 @@ namespace OpenSim.Data.NHibernate
99 { 126 {
100 if (!ExistsUser(profile.ID)) 127 if (!ExistsUser(profile.ID))
101 { 128 {
102 m_log.InfoFormat("[NHIBERNATE] AddNewUserProfile {0}", profile.ID); 129 session.Save(profile);
103 manager.Save(profile);
104 SetAgentData(profile.ID, profile.CurrentAgent); 130 SetAgentData(profile.ID, profile.CurrentAgent);
105
106 } 131 }
107 else 132 else
108 { 133 {
109 m_log.ErrorFormat("[NHIBERNATE] Attempted to add User {0} {1} that already exists, updating instead", profile.FirstName, profile.SurName); 134 m_log.ErrorFormat("Attempted to add User {0} {1} that already exists, updating instead", profile.FirstName, profile.SurName);
110 UpdateUserProfile(profile); 135 UpdateUserProfile(profile);
111 } 136 }
112 } 137 }
113 138
114 private void SetAgentData(UUID uuid, UserAgentData agent) 139 private void SetAgentData(UUID uuid, UserAgentData agent)
115 { 140 {
116 UserAgentData old = (UserAgentData)manager.Load(typeof(UserAgentData), uuid); 141 if (agent == null)
117 if (old != null)
118 { 142 {
119 m_log.InfoFormat("[NHIBERNATE] SetAgentData deleting old: {0} ",uuid); 143 // TODO: got to figure out how to do a delete right
120 manager.Delete(old);
121 } 144 }
122 if (agent != null) 145 else
123 { 146 {
124 m_log.InfoFormat("[NHIBERNATE] SetAgentData: {0} ", agent.ProfileID); 147 try
125 manager.Save(agent); 148 {
149 UserAgentData old = session.Load(typeof(UserAgentData), uuid) as UserAgentData;
150 session.Delete(old);
151 }
152 catch (ObjectNotFoundException)
153 {
154 }
155 session.Save(agent);
126 } 156 }
127 157
128 } 158 }
@@ -130,13 +160,13 @@ namespace OpenSim.Data.NHibernate
130 { 160 {
131 if (ExistsUser(profile.ID)) 161 if (ExistsUser(profile.ID))
132 { 162 {
133 manager.Update(profile); 163 session.Update(profile);
134 SetAgentData(profile.ID, profile.CurrentAgent); 164 SetAgentData(profile.ID, profile.CurrentAgent);
135 return true; 165 return true;
136 } 166 }
137 else 167 else
138 { 168 {
139 m_log.ErrorFormat("[NHIBERNATE] Attempted to update User {0} {1} that doesn't exist, updating instead", profile.FirstName, profile.SurName); 169 m_log.ErrorFormat("Attempted to update User {0} {1} that doesn't exist, updating instead", profile.FirstName, profile.SurName);
140 AddNewUserProfile(profile); 170 AddNewUserProfile(profile);
141 return true; 171 return true;
142 } 172 }
@@ -144,32 +174,37 @@ namespace OpenSim.Data.NHibernate
144 174
145 override public void AddNewUserAgent(UserAgentData agent) 175 override public void AddNewUserAgent(UserAgentData agent)
146 { 176 {
147 UserAgentData old = (UserAgentData)manager.Load(typeof(UserAgentData), agent.ProfileID); 177 try
148 if (old != null)
149 { 178 {
150 manager.Delete(old); 179 UserAgentData old = session.Load(typeof(UserAgentData), agent.ProfileID) as UserAgentData;
180 session.Delete(old);
151 } 181 }
152 182 catch (ObjectNotFoundException)
153 manager.Save(agent); 183 {
154 184 }
185 session.Save(agent);
155 } 186 }
156 187
157 public void UpdateUserAgent(UserAgentData agent) 188 public void UpdateUserAgent(UserAgentData agent)
158 { 189 {
159 m_log.InfoFormat("[NHIBERNATE] UpdateUserAgent: {0} ", agent.ProfileID); 190 session.Update(agent);
160 manager.Update(agent);
161 } 191 }
162 192
163 override public UserAgentData GetAgentByUUID(UUID uuid) 193 override public UserAgentData GetAgentByUUID(UUID uuid)
164 { 194 {
165 m_log.InfoFormat("[NHIBERNATE] GetAgentByUUID: {0} ", uuid); 195 try
166 return (UserAgentData)manager.Load(typeof(UserAgentData), uuid); 196 {
197 return session.Load(typeof(UserAgentData), uuid) as UserAgentData;
198 }
199 catch
200 {
201 return null;
202 }
167 } 203 }
168 204
169 override public UserProfileData GetUserByName(string fname, string lname) 205 override public UserProfileData GetUserByName(string fname, string lname)
170 { 206 {
171 m_log.InfoFormat("[NHIBERNATE] GetUserByName: {0} {1} ", fname, lname); 207 ICriteria criteria = session.CreateCriteria(typeof(UserProfileData));
172 ICriteria criteria = manager.GetSession().CreateCriteria(typeof(UserProfileData));
173 criteria.Add(Expression.Eq("FirstName", fname)); 208 criteria.Add(Expression.Eq("FirstName", fname));
174 criteria.Add(Expression.Eq("SurName", lname)); 209 criteria.Add(Expression.Eq("SurName", lname));
175 foreach (UserProfileData profile in criteria.List()) 210 foreach (UserProfileData profile in criteria.List())
@@ -198,7 +233,7 @@ namespace OpenSim.Data.NHibernate
198 233
199 if (querysplit.Length == 2) 234 if (querysplit.Length == 2)
200 { 235 {
201 ICriteria criteria = manager.GetSession().CreateCriteria(typeof(UserProfileData)); 236 ICriteria criteria = session.CreateCriteria(typeof(UserProfileData));
202 criteria.Add(Expression.Like("FirstName", querysplit[0])); 237 criteria.Add(Expression.Like("FirstName", querysplit[0]));
203 criteria.Add(Expression.Like("SurName", querysplit[1])); 238 criteria.Add(Expression.Like("SurName", querysplit[1]));
204 foreach (UserProfileData profile in criteria.List()) 239 foreach (UserProfileData profile in criteria.List())
@@ -227,18 +262,26 @@ namespace OpenSim.Data.NHibernate
227 /// TODO: stubs for now to get us to a compiling state gently 262 /// TODO: stubs for now to get us to a compiling state gently
228 public override AvatarAppearance GetUserAppearance(UUID user) 263 public override AvatarAppearance GetUserAppearance(UUID user)
229 { 264 {
230 return (AvatarAppearance)manager.Load(typeof(AvatarAppearance), user); 265 AvatarAppearance appearance;
266 // TODO: I'm sure I'll have to do something silly here
267 try {
268 appearance = session.Load(typeof(AvatarAppearance), user) as AvatarAppearance;
269 } catch (ObjectNotFoundException) {
270 appearance = null;
271 }
272 return appearance;
231 } 273 }
232 274
233 private bool ExistsAppearance(UUID uuid) 275 private bool ExistsAppearance(UUID uuid)
234 { 276 {
235 AvatarAppearance appearance = (AvatarAppearance)manager.Load(typeof(AvatarAppearance), uuid); 277 AvatarAppearance appearance;
236 if (appearance == null) 278 try {
237 { 279 appearance = session.Load(typeof(AvatarAppearance), uuid) as AvatarAppearance;
238 return false; 280 } catch (ObjectNotFoundException) {
281 appearance = null;
239 } 282 }
240 283
241 return true; 284 return (appearance == null) ? false : true;
242 } 285 }
243 286
244 287
@@ -252,11 +295,11 @@ namespace OpenSim.Data.NHibernate
252 bool exists = ExistsAppearance(user); 295 bool exists = ExistsAppearance(user);
253 if (exists) 296 if (exists)
254 { 297 {
255 manager.Update(appearance); 298 session.Update(appearance);
256 } 299 }
257 else 300 else
258 { 301 {
259 manager.Save(appearance); 302 session.Save(appearance);
260 } 303 }
261 } 304 }
262 305
diff --git a/OpenSim/Data/NHibernate/Resources/AssetBase.hbm.xml b/OpenSim/Data/NHibernate/Resources/AssetBase.hbm.xml
index 7c42609..7c3d8cf 100644
--- a/OpenSim/Data/NHibernate/Resources/AssetBase.hbm.xml
+++ b/OpenSim/Data/NHibernate/Resources/AssetBase.hbm.xml
@@ -4,7 +4,7 @@
4 <id name="FullID" column="ID" type="OpenSim.Data.NHibernate.UUIDUserType, OpenSim.Data.NHibernate"> 4 <id name="FullID" column="ID" type="OpenSim.Data.NHibernate.UUIDUserType, OpenSim.Data.NHibernate">
5 <generator class="assigned" /> 5 <generator class="assigned" />
6 </id> 6 </id>
7 <property name="Type" type="OpenSim.Data.NHibernate.SByteType, OpenSim.Data.NHibernate" /> 7 <property name="Type" type="System.SByte" />
8 <property name="Name" type="String" length="64" /> 8 <property name="Name" type="String" length="64" />
9 <property name="Description" type="String" length="64" /> 9 <property name="Description" type="String" length="64" />
10 <property name="Local" type="boolean" /> 10 <property name="Local" type="boolean" />
diff --git a/OpenSim/Data/NHibernate/Resources/InventoryFolderBase.hbm.xml b/OpenSim/Data/NHibernate/Resources/InventoryFolderBase.hbm.xml
index c5f0115..6afe9fa 100644
--- a/OpenSim/Data/NHibernate/Resources/InventoryFolderBase.hbm.xml
+++ b/OpenSim/Data/NHibernate/Resources/InventoryFolderBase.hbm.xml
@@ -5,7 +5,7 @@
5 <generator class="assigned" /> 5 <generator class="assigned" />
6 </id> 6 </id>
7 <property name="Type" type="Int16" /> 7 <property name="Type" type="Int16" />
8 <property name="Version" type="OpenSim.Data.NHibernate.UInt16Type, OpenSim.Data.NHibernate" /> 8 <property name="Version" type="System.UInt16" />
9 <property name="ParentID" index="folder_parent_id" type="OpenSim.Data.NHibernate.UUIDUserType, OpenSim.Data.NHibernate" /> 9 <property name="ParentID" index="folder_parent_id" type="OpenSim.Data.NHibernate.UUIDUserType, OpenSim.Data.NHibernate" />
10 <property name="Owner" index="folder_owner_id" type="OpenSim.Data.NHibernate.UUIDUserType, OpenSim.Data.NHibernate" /> 10 <property name="Owner" index="folder_owner_id" type="OpenSim.Data.NHibernate.UUIDUserType, OpenSim.Data.NHibernate" />
11 <property name="Name" type="String" length="64" /> 11 <property name="Name" type="String" length="64" />
diff --git a/OpenSim/Data/NHibernate/Resources/InventoryItemBase.hbm.xml b/OpenSim/Data/NHibernate/Resources/InventoryItemBase.hbm.xml
index f5e365b..9a4d7ca 100644
--- a/OpenSim/Data/NHibernate/Resources/InventoryItemBase.hbm.xml
+++ b/OpenSim/Data/NHibernate/Resources/InventoryItemBase.hbm.xml
@@ -12,15 +12,15 @@
12 <property name="Creator" type="OpenSim.Data.NHibernate.UUIDUserType, OpenSim.Data.NHibernate" /> 12 <property name="Creator" type="OpenSim.Data.NHibernate.UUIDUserType, OpenSim.Data.NHibernate" />
13 <property name="Name" type="String" length="64" /> 13 <property name="Name" type="String" length="64" />
14 <property name="Description" type="String" length="64" /> 14 <property name="Description" type="String" length="64" />
15 <property name="NextPermissions" type="OpenSim.Data.NHibernate.UInt32Type, OpenSim.Data.NHibernate" /> 15 <property name="NextPermissions" type="System.UInt32" />
16 <property name="CurrentPermissions" type="OpenSim.Data.NHibernate.UInt32Type, OpenSim.Data.NHibernate" /> 16 <property name="CurrentPermissions" type="System.UInt32" />
17 <property name="BasePermissions" type="OpenSim.Data.NHibernate.UInt32Type, OpenSim.Data.NHibernate" /> 17 <property name="BasePermissions" type="System.UInt32" />
18 <property name="EveryOnePermissions" type="OpenSim.Data.NHibernate.UInt32Type, OpenSim.Data.NHibernate" /> 18 <property name="EveryOnePermissions" type="System.UInt32" />
19 <property name="GroupID" index="item_group_id" type="OpenSim.Data.NHibernate.UUIDUserType, OpenSim.Data.NHibernate" /> 19 <property name="GroupID" index="item_group_id" type="OpenSim.Data.NHibernate.UUIDUserType, OpenSim.Data.NHibernate" />
20 <property name="GroupOwned" type="boolean" /> 20 <property name="GroupOwned" type="boolean" />
21 <property name="SalePrice" type="System.Int32" /> 21 <property name="SalePrice" type="System.Int32" />
22 <property name="SaleType" type="System.Byte" /> 22 <property name="SaleType" type="System.Byte" />
23 <property name="Flags" type="OpenSim.Data.NHibernate.UInt32Type, OpenSim.Data.NHibernate" /> 23 <property name="Flags" type="System.UInt32" />
24 <property name="CreationDate" type="System.Int32" /> 24 <property name="CreationDate" type="System.Int32" />
25 </class> 25 </class>
26</hibernate-mapping> 26</hibernate-mapping>
diff --git a/OpenSim/Data/NHibernate/Resources/MySQLDialect/002_RegionStore.sql b/OpenSim/Data/NHibernate/Resources/MySQLDialect/002_RegionStore.sql
index d34d44e..fc11e95 100644
--- a/OpenSim/Data/NHibernate/Resources/MySQLDialect/002_RegionStore.sql
+++ b/OpenSim/Data/NHibernate/Resources/MySQLDialect/002_RegionStore.sql
@@ -2,8 +2,8 @@ BEGIN;
2 2
3CREATE TABLE `Terrain` ( 3CREATE TABLE `Terrain` (
4 `RegionID` char(36) not null, 4 `RegionID` char(36) not null,
5 `MapData` longblob, 5 `Map` longblob,
6 PRIMARY KEY (`RegionID`) 6 PRIMARY KEY (`RegionID`)
7) ENGINE=InnoDB DEFAULT CHARSET=utf8; 7) ENGINE=InnoDB DEFAULT CHARSET=utf8;
8 8
9COMMIT; 9COMMIT; \ No newline at end of file
diff --git a/OpenSim/Data/NHibernate/Resources/RegionStore.hbm.xml b/OpenSim/Data/NHibernate/Resources/RegionStore.hbm.xml
index 1851904..fe055bb 100644
--- a/OpenSim/Data/NHibernate/Resources/RegionStore.hbm.xml
+++ b/OpenSim/Data/NHibernate/Resources/RegionStore.hbm.xml
@@ -4,7 +4,7 @@
4 <id name="UUID" type="OpenSim.Data.NHibernate.UUIDUserType, OpenSim.Data.NHibernate"> 4 <id name="UUID" type="OpenSim.Data.NHibernate.UUIDUserType, OpenSim.Data.NHibernate">
5 <generator class="assigned" /> 5 <generator class="assigned" />
6 </id> 6 </id>
7 <property name="ParentID" type="OpenSim.Data.NHibernate.UInt32Type, OpenSim.Data.NHibernate"/> 7 <property name="ParentID" type="System.UInt32"/>
8 <property name="ParentUUID" type="OpenSim.Data.NHibernate.UUIDUserType, OpenSim.Data.NHibernate" /> 8 <property name="ParentUUID" type="OpenSim.Data.NHibernate.UUIDUserType, OpenSim.Data.NHibernate" />
9 <property name="RegionID" type="OpenSim.Data.NHibernate.UUIDUserType, OpenSim.Data.NHibernate" /> 9 <property name="RegionID" type="OpenSim.Data.NHibernate.UUIDUserType, OpenSim.Data.NHibernate" />
10 <property name="CreationDate" type="System.Int32" /> 10 <property name="CreationDate" type="System.Int32" />
@@ -14,17 +14,17 @@
14 <property name="SitName" type="String" length="255" /> 14 <property name="SitName" type="String" length="255" />
15 <property name="TouchName" type="String" length="255" /> 15 <property name="TouchName" type="String" length="255" />
16 16
17 <property name="ObjectFlags" type="OpenSim.Data.NHibernate.UInt32Type, OpenSim.Data.NHibernate" /> 17 <property name="ObjectFlags" type="System.UInt32" />
18 <property name="CreatorID" type="OpenSim.Data.NHibernate.UUIDUserType, OpenSim.Data.NHibernate" /> 18 <property name="CreatorID" type="OpenSim.Data.NHibernate.UUIDUserType, OpenSim.Data.NHibernate" />
19 <property name="OwnerID" type="OpenSim.Data.NHibernate.UUIDUserType, OpenSim.Data.NHibernate" /> 19 <property name="OwnerID" type="OpenSim.Data.NHibernate.UUIDUserType, OpenSim.Data.NHibernate" />
20 <property name="GroupID" type="OpenSim.Data.NHibernate.UUIDUserType, OpenSim.Data.NHibernate" /> 20 <property name="GroupID" type="OpenSim.Data.NHibernate.UUIDUserType, OpenSim.Data.NHibernate" />
21 <property name="LastOwnerID" type="OpenSim.Data.NHibernate.UUIDUserType, OpenSim.Data.NHibernate" /> 21 <property name="LastOwnerID" type="OpenSim.Data.NHibernate.UUIDUserType, OpenSim.Data.NHibernate" />
22 22
23 <property name="OwnerMask" type="OpenSim.Data.NHibernate.UInt32Type, OpenSim.Data.NHibernate" /> 23 <property name="OwnerMask" type="System.UInt32" />
24 <property name="NextOwnerMask" type="OpenSim.Data.NHibernate.UInt32Type, OpenSim.Data.NHibernate" /> 24 <property name="NextOwnerMask" type="System.UInt32" />
25 <property name="GroupMask" type="OpenSim.Data.NHibernate.UInt32Type, OpenSim.Data.NHibernate" /> 25 <property name="GroupMask" type="System.UInt32" />
26 <property name="EveryoneMask" type="OpenSim.Data.NHibernate.UInt32Type, OpenSim.Data.NHibernate" /> 26 <property name="EveryoneMask" type="System.UInt32" />
27 <property name="BaseMask" type="OpenSim.Data.NHibernate.UInt32Type, OpenSim.Data.NHibernate" /> 27 <property name="BaseMask" type="System.UInt32" />
28 28
29 <property name="OffsetPosition" type="OpenSim.Data.NHibernate.Vector3UserType, OpenSim.Data.NHibernate" > 29 <property name="OffsetPosition" type="OpenSim.Data.NHibernate.Vector3UserType, OpenSim.Data.NHibernate" >
30 <column name="PositionX" /> 30 <column name="PositionX" />
@@ -83,24 +83,24 @@
83 <column name="ScaleZ" /> 83 <column name="ScaleZ" />
84 </property> 84 </property>
85 <property name="PCode" type="System.Byte" /> 85 <property name="PCode" type="System.Byte" />
86 <property name="PathBegin" type="OpenSim.Data.NHibernate.UInt16Type, OpenSim.Data.NHibernate" /> 86 <property name="PathBegin" type="System.UInt16" />
87 <property name="PathEnd" type="OpenSim.Data.NHibernate.UInt16Type, OpenSim.Data.NHibernate" /> 87 <property name="PathEnd" type="System.UInt16" />
88 <property name="PathScaleX" type="System.Byte" /> 88 <property name="PathScaleX" type="System.Byte" />
89 <property name="PathScaleY" type="System.Byte" /> 89 <property name="PathScaleY" type="System.Byte" />
90 <property name="PathShearX" type="System.Byte" /> 90 <property name="PathShearX" type="System.Byte" />
91 <property name="PathShearY" type="System.Byte" /> 91 <property name="PathShearY" type="System.Byte" />
92 <property name="PathSkew" type="OpenSim.Data.NHibernate.SByteType, OpenSim.Data.NHibernate" /> 92 <property name="PathSkew" type="System.SByte" />
93 <property name="PathCurve" type="System.Byte" /> 93 <property name="PathCurve" type="System.Byte" />
94 <property name="PathRadiusOffset" type="OpenSim.Data.NHibernate.SByteType, OpenSim.Data.NHibernate" /> 94 <property name="PathRadiusOffset" type="System.SByte" />
95 <property name="PathRevolutions" type="System.Byte" /> 95 <property name="PathRevolutions" type="System.Byte" />
96 <property name="PathTaperX" type="OpenSim.Data.NHibernate.SByteType, OpenSim.Data.NHibernate" /> 96 <property name="PathTaperX" type="System.SByte" />
97 <property name="PathTwist" type="OpenSim.Data.NHibernate.SByteType, OpenSim.Data.NHibernate" /> 97 <property name="PathTwist" type="System.SByte" />
98 <property name="ProfileBegin" type="OpenSim.Data.NHibernate.UInt16Type, OpenSim.Data.NHibernate" /> 98 <property name="ProfileBegin" type="System.UInt16" />
99 <property name="ProfileEnd" type="OpenSim.Data.NHibernate.UInt16Type, OpenSim.Data.NHibernate" /> 99 <property name="ProfileEnd" type="System.UInt16" />
100 <property name="ProfileCurve" type="System.Byte" /> 100 <property name="ProfileCurve" type="System.Byte" />
101 <property name="ProfileHollow" type="OpenSim.Data.NHibernate.UInt16Type, OpenSim.Data.NHibernate" /> 101 <property name="ProfileHollow" type="System.UInt16" />
102 <property name="TextureEntry" column="Texture" type="binary" /> 102 <property name="TextureEntry" column="Texture" type="System.Byte[]" />
103 <property name="ExtraParams" type="binary" /> 103 <property name="ExtraParams" type="System.Byte[]" />
104 <property name="State" type="System.Byte" /> 104 <property name="State" type="System.Byte" />
105 </component> 105 </component>
106 </class> 106 </class>
@@ -108,8 +108,7 @@
108 <id name="RegionID" type="OpenSim.Data.NHibernate.UUIDUserType, OpenSim.Data.NHibernate"> 108 <id name="RegionID" type="OpenSim.Data.NHibernate.UUIDUserType, OpenSim.Data.NHibernate">
109 <generator class="assigned" /> 109 <generator class="assigned" />
110 </id> 110 </id>
111 <!-- <property name="MapData" type="OpenSim.Data.NHibernate.BlobType, OpenSim.Data.NHibernate" /> --> 111 <property name="Map" type="System.Byte[]" />
112 <property name="MapData" type="binary" />
113 </class> 112 </class>
114 <class name="OpenSim.Framework.TaskInventoryItem, OpenSim.Framework" table="PrimItems" lazy="false"> 113 <class name="OpenSim.Framework.TaskInventoryItem, OpenSim.Framework" table="PrimItems" lazy="false">
115 <id name="ItemID" type="OpenSim.Data.NHibernate.UUIDUserType, OpenSim.Data.NHibernate"> 114 <id name="ItemID" type="OpenSim.Data.NHibernate.UUIDUserType, OpenSim.Data.NHibernate">
@@ -122,47 +121,15 @@
122 <property name="OwnerID" type="OpenSim.Data.NHibernate.UUIDUserType, OpenSim.Data.NHibernate"/> 121 <property name="OwnerID" type="OpenSim.Data.NHibernate.UUIDUserType, OpenSim.Data.NHibernate"/>
123 <property name="GroupID" type="OpenSim.Data.NHibernate.UUIDUserType, OpenSim.Data.NHibernate"/> 122 <property name="GroupID" type="OpenSim.Data.NHibernate.UUIDUserType, OpenSim.Data.NHibernate"/>
124 <property name="LastOwnerID" type="OpenSim.Data.NHibernate.UUIDUserType, OpenSim.Data.NHibernate"/> 123 <property name="LastOwnerID" type="OpenSim.Data.NHibernate.UUIDUserType, OpenSim.Data.NHibernate"/>
125 <property name="CurrentPermissions" type="OpenSim.Data.NHibernate.UInt32Type, OpenSim.Data.NHibernate" /> 124 <property name="CurrentPermissions" type="System.UInt32" />
126 <property name="BasePermissions" type="OpenSim.Data.NHibernate.UInt32Type, OpenSim.Data.NHibernate" /> 125 <property name="BasePermissions" type="System.UInt32" />
127 <property name="EveryonePermissions" type="OpenSim.Data.NHibernate.UInt32Type, OpenSim.Data.NHibernate" /> 126 <property name="EveryonePermissions" type="System.UInt32" />
128 <property name="GroupPermissions" type="OpenSim.Data.NHibernate.UInt32Type, OpenSim.Data.NHibernate" /> 127 <property name="GroupPermissions" type="System.UInt32" />
129 <property name="NextPermissions" type="OpenSim.Data.NHibernate.UInt32Type, OpenSim.Data.NHibernate" /> 128 <property name="NextPermissions" type="System.UInt32" />
130 <property name="Name" type="String" length="255" /> 129 <property name="Name" type="String" length="255" />
131 <property name="Description" type="String" length="255" /> 130 <property name="Description" type="String" length="255" />
132 <property name="CreationDate" type="OpenSim.Data.NHibernate.UInt32Type, OpenSim.Data.NHibernate" /> 131 <property name="CreationDate" type="System.UInt32" />
133 <property name="Flags" type="OpenSim.Data.NHibernate.UInt32Type, OpenSim.Data.NHibernate" /> 132 <property name="Flags" type="System.UInt32" />
134 <property name="InvType" type="System.Int32" /> 133 <property name="InvType" type="System.Int32" />
135 </class> 134 </class>
136 <class name="OpenSim.Data.RegionProfileData, OpenSim.Data" table="Regions" lazy="false">
137 <id name="Uuid" type="OpenSim.Data.NHibernate.UUIDUserType, OpenSim.Data.NHibernate">
138 <generator class="assigned" />
139 </id>
140 <property name="RegionHandle" index="region_handle" type="OpenSim.Data.NHibernate.UInt64Type, OpenSim.Data.NHibernate" />
141 <property name="RegionName" index="region_name" type="String" length="32"/>
142 <property name="RegionRecvKey" type="String" length="128"/>
143 <property name="RegionSendKey" type="String" length="128"/>
144 <property name="RegionSecret" type="String" length="128"/>
145 <property name="RegionDataURI" type="String" length="255"/>
146 <property name="ServerIP" type="String" length="64"/>
147 <property name="ServerPort" type="OpenSim.Data.NHibernate.UInt32Type, OpenSim.Data.NHibernate" />
148 <property name="ServerURI" type="String" length="255"/>
149 <property name="RegionLocX" type="OpenSim.Data.NHibernate.UInt32Type, OpenSim.Data.NHibernate" />
150 <property name="RegionLocY" type="OpenSim.Data.NHibernate.UInt32Type, OpenSim.Data.NHibernate" />
151 <property name="RegionLocZ" type="OpenSim.Data.NHibernate.UInt32Type, OpenSim.Data.NHibernate" />
152 <property name="EastOverrideHandle" index="overrideHandles" type="OpenSim.Data.NHibernate.UInt64Type, OpenSim.Data.NHibernate" />
153 <property name="WestOverrideHandle" index="overrideHandles" type="OpenSim.Data.NHibernate.UInt64Type, OpenSim.Data.NHibernate" />
154 <property name="SouthOverrideHandle" index="overrideHandles" type="OpenSim.Data.NHibernate.UInt64Type, OpenSim.Data.NHibernate" />
155 <property name="NorthOverrideHandle" index="overrideHandles" type="OpenSim.Data.NHibernate.UInt64Type, OpenSim.Data.NHibernate" />
156 <property name="RegionAssetURI" type="String" length="255"/>
157 <property name="RegionAssetRecvKey" type="String" length="128"/>
158 <property name="RegionAssetSendKey" type="String" length="128"/>
159 <property name="RegionUserURI" type="String" length="255"/>
160 <property name="RegionUserRecvKey" type="String" length="128"/>
161 <property name="RegionUserSendKey" type="String" length="128"/>
162 <property name="ServerHttpPort" type="OpenSim.Data.NHibernate.UInt32Type, OpenSim.Data.NHibernate" />
163 <property name="ServerRemotingPort" type="OpenSim.Data.NHibernate.UInt32Type, OpenSim.Data.NHibernate" />
164 <property name="RegionMapTextureID" type="OpenSim.Data.NHibernate.UUIDUserType, OpenSim.Data.NHibernate"/>
165 <property name="Owner_uuid" type="OpenSim.Data.NHibernate.UUIDUserType, OpenSim.Data.NHibernate"/>
166 <property name="OriginUUID" type="OpenSim.Data.NHibernate.UUIDUserType, OpenSim.Data.NHibernate"/>
167 </class>
168</hibernate-mapping> 135</hibernate-mapping>
diff --git a/OpenSim/Data/NHibernate/Resources/UserAgentData.hbm.xml b/OpenSim/Data/NHibernate/Resources/UserAgentData.hbm.xml
index e10fb8f..0beddaf 100644
--- a/OpenSim/Data/NHibernate/Resources/UserAgentData.hbm.xml
+++ b/OpenSim/Data/NHibernate/Resources/UserAgentData.hbm.xml
@@ -5,7 +5,7 @@
5 <generator class="assigned" /> 5 <generator class="assigned" />
6 </id> 6 </id>
7 <property name="AgentIP" type="String" length="24" /> 7 <property name="AgentIP" type="String" length="24" />
8 <property name="AgentPort" type="OpenSim.Data.NHibernate.UInt32Type, OpenSim.Data.NHibernate" /> 8 <property name="AgentPort" type="Int32" />
9 <property name="AgentOnline" type="boolean" /> 9 <property name="AgentOnline" type="boolean" />
10 <property name="SessionID" type="OpenSim.Data.NHibernate.UUIDUserType, OpenSim.Data.NHibernate" /> 10 <property name="SessionID" type="OpenSim.Data.NHibernate.UUIDUserType, OpenSim.Data.NHibernate" />
11 <property name="SecureSessionID" type="OpenSim.Data.NHibernate.UUIDUserType, OpenSim.Data.NHibernate" /> 11 <property name="SecureSessionID" type="OpenSim.Data.NHibernate.UUIDUserType, OpenSim.Data.NHibernate" />
@@ -13,9 +13,9 @@
13 <property name="Region" type="OpenSim.Data.NHibernate.UUIDUserType, OpenSim.Data.NHibernate" /> 13 <property name="Region" type="OpenSim.Data.NHibernate.UUIDUserType, OpenSim.Data.NHibernate" />
14 <property name="LoginTime" type="Int32" /> 14 <property name="LoginTime" type="Int32" />
15 <property name="LogoutTime" type="Int32" /> 15 <property name="LogoutTime" type="Int32" />
16 <property name="Handle" type="OpenSim.Data.NHibernate.UInt64Type, OpenSim.Data.NHibernate" /> 16 <property name="Handle" type="Int64" />
17 <!-- <property name="PositionX" type="Single" /> 17 <property name="PositionX" type="Single" />
18 <property name="PositionY" type="Single" /> 18 <property name="PositionY" type="Single" />
19 <property name="PositionZ" type="Single" /> --> 19 <property name="PositionZ" type="Single" />
20 </class> 20 </class>
21</hibernate-mapping> 21</hibernate-mapping>
diff --git a/OpenSim/Data/NHibernate/Resources/UserProfileData.hbm.xml b/OpenSim/Data/NHibernate/Resources/UserProfileData.hbm.xml
index 740a9f1..873930b 100644
--- a/OpenSim/Data/NHibernate/Resources/UserProfileData.hbm.xml
+++ b/OpenSim/Data/NHibernate/Resources/UserProfileData.hbm.xml
@@ -9,8 +9,8 @@
9 <property name="PasswordHash" type="String" length="32" /> 9 <property name="PasswordHash" type="String" length="32" />
10 <property name="PasswordSalt" type="String" length="32" /> 10 <property name="PasswordSalt" type="String" length="32" />
11 <property name="WebLoginKey" type="OpenSim.Data.NHibernate.UUIDUserType, OpenSim.Data.NHibernate" /> 11 <property name="WebLoginKey" type="OpenSim.Data.NHibernate.UUIDUserType, OpenSim.Data.NHibernate" />
12 <property name="HomeRegionX" type="OpenSim.Data.NHibernate.UInt32Type, OpenSim.Data.NHibernate" /> 12 <property name="HomeRegionX" type="System.UInt32" />
13 <property name="HomeRegionY" type="OpenSim.Data.NHibernate.UInt32Type, OpenSim.Data.NHibernate" /> 13 <property name="HomeRegionY" type="System.UInt32" />
14 <property name="HomeLocationX" type="Single" /> 14 <property name="HomeLocationX" type="Single" />
15 <property name="HomeLocationY" type="Single" /> 15 <property name="HomeLocationY" type="Single" />
16 <property name="HomeLocationZ" type="Single" /> 16 <property name="HomeLocationZ" type="Single" />
diff --git a/OpenSim/Data/NHibernate/Terrain.cs b/OpenSim/Data/NHibernate/Terrain.cs
index 88be17f..dd0da44 100644
--- a/OpenSim/Data/NHibernate/Terrain.cs
+++ b/OpenSim/Data/NHibernate/Terrain.cs
@@ -60,7 +60,7 @@ namespace OpenSim.Data.NHibernate
60 set { regionID = value; } 60 set { regionID = value; }
61 } 61 }
62 62
63 public byte[] MapData 63 public byte[] Map
64 { 64 {
65 get { return serializeTerrain(map); } 65 get { return serializeTerrain(map); }
66 set { map = parseTerrain(value); } 66 set { map = parseTerrain(value); }