aboutsummaryrefslogtreecommitdiffstatshomepage
path: root/OpenSim/Data
diff options
context:
space:
mode:
authorSean Dague2008-06-20 20:23:55 +0000
committerSean Dague2008-06-20 20:23:55 +0000
commit17fd6cf66113b4c6482d72ac54a79382408eec9c (patch)
tree56b7a0d3ebc4e59548d13ad186067793cb66de9a /OpenSim/Data
parentcontent fridays. A whole bunch of new stock animations from Mo Hax (diff)
downloadopensim-SC_OLD-17fd6cf66113b4c6482d72ac54a79382408eec9c.zip
opensim-SC_OLD-17fd6cf66113b4c6482d72ac54a79382408eec9c.tar.gz
opensim-SC_OLD-17fd6cf66113b4c6482d72ac54a79382408eec9c.tar.bz2
opensim-SC_OLD-17fd6cf66113b4c6482d72ac54a79382408eec9c.tar.xz
lots of futzing with nhibernate to make it more efficient. I
don't think this works, but I don't want to loose the work before the weekend, and it doesn't break the build.
Diffstat (limited to 'OpenSim/Data')
-rw-r--r--OpenSim/Data/NHibernate/NHibernateAssetData.cs39
-rw-r--r--OpenSim/Data/NHibernate/NHibernateInventoryData.cs146
-rw-r--r--OpenSim/Data/NHibernate/NHibernateUserData.cs157
-rw-r--r--OpenSim/Data/NHibernate/Resources/InventoryItemBase.hbm.xml6
4 files changed, 136 insertions, 212 deletions
diff --git a/OpenSim/Data/NHibernate/NHibernateAssetData.cs b/OpenSim/Data/NHibernate/NHibernateAssetData.cs
index db77942..89f907f 100644
--- a/OpenSim/Data/NHibernate/NHibernateAssetData.cs
+++ b/OpenSim/Data/NHibernate/NHibernateAssetData.cs
@@ -49,6 +49,7 @@ namespace OpenSim.Data.NHibernate
49 49
50 private Configuration cfg; 50 private Configuration cfg;
51 private ISessionFactory factory; 51 private ISessionFactory factory;
52 private ISession session;
52 53
53 public override void Initialise() 54 public override void Initialise()
54 { 55 {
@@ -87,27 +88,25 @@ namespace OpenSim.Data.NHibernate
87 cfg.AddInputStream(stream); 88 cfg.AddInputStream(stream);
88 89
89 factory = cfg.BuildSessionFactory(); 90 factory = cfg.BuildSessionFactory();
90 91 session = factory.OpenSession();
91 92
92 // This actually does the roll forward assembly stuff 93 // This actually does the roll forward assembly stuff
93 Assembly assem = GetType().Assembly; 94 Assembly assem = GetType().Assembly;
94 Migration m = new Migration((System.Data.Common.DbConnection)factory.ConnectionProvider.GetConnection(), assem, dialect, "AssetStore"); 95 Migration m = new Migration((System.Data.Common.DbConnection)factory.ConnectionProvider.GetConnection(), assem, dialect, "AssetStore");
95 m.Update(); 96 m.Update();
97
96 } 98 }
97 99
98 override public AssetBase FetchAsset(LLUUID uuid) 100 override public AssetBase FetchAsset(LLUUID uuid)
99 { 101 {
100 using (ISession session = factory.OpenSession()) 102 try
101 { 103 {
102 try 104 return session.Load(typeof(AssetBase), uuid) as AssetBase;
103 { 105 }
104 return session.Load(typeof(AssetBase), uuid) as AssetBase; 106 catch (Exception e)
105 } 107 {
106 catch (Exception e) 108 m_log.Error("[NHIBERNATE] issue loading asset", e);
107 { 109 return null;
108 m_log.Error("[NHIBERNATE] issue loading asset", e);
109 return null;
110 }
111 } 110 }
112 } 111 }
113 112
@@ -116,13 +115,10 @@ namespace OpenSim.Data.NHibernate
116 if (!ExistsAsset(asset.FullID)) 115 if (!ExistsAsset(asset.FullID))
117 { 116 {
118 m_log.InfoFormat("[NHIBERNATE] inserting asset {0}", asset.FullID); 117 m_log.InfoFormat("[NHIBERNATE] inserting asset {0}", asset.FullID);
119 using (ISession session = factory.OpenSession()) 118 using (ITransaction transaction = session.BeginTransaction())
120 { 119 {
121 using (ITransaction transaction = session.BeginTransaction()) 120 session.Save(asset);
122 { 121 transaction.Commit();
123 session.Save(asset);
124 transaction.Commit();
125 }
126 } 122 }
127 } 123 }
128 } 124 }
@@ -131,13 +127,10 @@ namespace OpenSim.Data.NHibernate
131 { 127 {
132 if (ExistsAsset(asset.FullID)) 128 if (ExistsAsset(asset.FullID))
133 { 129 {
134 using (ISession session = factory.OpenSession()) 130 using (ITransaction transaction = session.BeginTransaction())
135 { 131 {
136 using (ITransaction transaction = session.BeginTransaction()) 132 session.Update(asset);
137 { 133 transaction.Commit();
138 session.Update(asset);
139 transaction.Commit();
140 }
141 } 134 }
142 } 135 }
143 } 136 }
diff --git a/OpenSim/Data/NHibernate/NHibernateInventoryData.cs b/OpenSim/Data/NHibernate/NHibernateInventoryData.cs
index 017759e..46dcbad 100644
--- a/OpenSim/Data/NHibernate/NHibernateInventoryData.cs
+++ b/OpenSim/Data/NHibernate/NHibernateInventoryData.cs
@@ -48,6 +48,7 @@ namespace OpenSim.Data.NHibernate
48 48
49 private Configuration cfg; 49 private Configuration cfg;
50 private ISessionFactory factory; 50 private ISessionFactory factory;
51 private ISession session;
51 52
52 /// <summary> 53 /// <summary>
53 /// Initialises the interface 54 /// Initialises the interface
@@ -76,6 +77,7 @@ namespace OpenSim.Data.NHibernate
76 cfg.AddAssembly("OpenSim.Data.NHibernate"); 77 cfg.AddAssembly("OpenSim.Data.NHibernate");
77 78
78 factory = cfg.BuildSessionFactory(); 79 factory = cfg.BuildSessionFactory();
80 session = factory.OpenSession();
79 81
80 // This actually does the roll forward assembly stuff 82 // This actually does the roll forward assembly stuff
81 Assembly assem = GetType().Assembly; 83 Assembly assem = GetType().Assembly;
@@ -99,17 +101,14 @@ namespace OpenSim.Data.NHibernate
99 /// <returns>A class containing item information</returns> 101 /// <returns>A class containing item information</returns>
100 public InventoryItemBase getInventoryItem(LLUUID item) 102 public InventoryItemBase getInventoryItem(LLUUID item)
101 { 103 {
102 using (ISession session = factory.OpenSession()) 104 try
103 { 105 {
104 try 106 return session.Load(typeof(InventoryItemBase), item) as InventoryItemBase;
105 { 107 }
106 return session.Load(typeof(InventoryItemBase), item) as InventoryItemBase; 108 catch
107 } 109 {
108 catch 110 m_log.ErrorFormat("Couldn't find inventory item: {0}", item);
109 { 111 return null;
110 m_log.ErrorFormat("Couldn't find inventory item: {0}", item);
111 return null;
112 }
113 } 112 }
114 } 113 }
115 114
@@ -121,13 +120,10 @@ namespace OpenSim.Data.NHibernate
121 { 120 {
122 if (!ExistsItem(item.ID)) 121 if (!ExistsItem(item.ID))
123 { 122 {
124 using (ISession session = factory.OpenSession()) 123 using (ITransaction transaction = session.BeginTransaction())
125 { 124 {
126 using (ITransaction transaction = session.BeginTransaction()) 125 session.Save(item);
127 { 126 transaction.Commit();
128 session.Save(item);
129 transaction.Commit();
130 }
131 } 127 }
132 } 128 }
133 else 129 else
@@ -145,13 +141,10 @@ namespace OpenSim.Data.NHibernate
145 { 141 {
146 if (ExistsItem(item.ID)) 142 if (ExistsItem(item.ID))
147 { 143 {
148 using (ISession session = factory.OpenSession()) 144 using (ITransaction transaction = session.BeginTransaction())
149 { 145 {
150 using (ITransaction transaction = session.BeginTransaction()) 146 session.Update(item);
151 { 147 transaction.Commit();
152 session.Update(item);
153 transaction.Commit();
154 }
155 } 148 }
156 } 149 }
157 else 150 else
@@ -166,13 +159,10 @@ namespace OpenSim.Data.NHibernate
166 /// <param name="item"></param> 159 /// <param name="item"></param>
167 public void deleteInventoryItem(LLUUID itemID) 160 public void deleteInventoryItem(LLUUID itemID)
168 { 161 {
169 using (ISession session = factory.OpenSession()) 162 using (ITransaction transaction = session.BeginTransaction())
170 { 163 {
171 using (ITransaction transaction = session.BeginTransaction()) 164 session.Delete(itemID);
172 { 165 transaction.Commit();
173 session.Delete(itemID);
174 transaction.Commit();
175 }
176 } 166 }
177 } 167 }
178 168
@@ -183,17 +173,14 @@ namespace OpenSim.Data.NHibernate
183 /// <returns>A class containing folder information</returns> 173 /// <returns>A class containing folder information</returns>
184 public InventoryFolderBase getInventoryFolder(LLUUID folder) 174 public InventoryFolderBase getInventoryFolder(LLUUID folder)
185 { 175 {
186 using (ISession session = factory.OpenSession()) 176 try
187 { 177 {
188 try 178 return session.Load(typeof(InventoryFolderBase), folder) as InventoryFolderBase;
189 { 179 }
190 return session.Load(typeof(InventoryFolderBase), folder) as InventoryFolderBase; 180 catch
191 } 181 {
192 catch 182 m_log.ErrorFormat("Couldn't find inventory item: {0}", folder);
193 { 183 return null;
194 m_log.ErrorFormat("Couldn't find inventory item: {0}", folder);
195 return null;
196 }
197 } 184 }
198 } 185 }
199 186
@@ -205,13 +192,10 @@ namespace OpenSim.Data.NHibernate
205 { 192 {
206 if (!ExistsFolder(folder.ID)) 193 if (!ExistsFolder(folder.ID))
207 { 194 {
208 using (ISession session = factory.OpenSession()) 195 using (ITransaction transaction = session.BeginTransaction())
209 { 196 {
210 using (ITransaction transaction = session.BeginTransaction()) 197 session.Save(folder);
211 { 198 transaction.Commit();
212 session.Save(folder);
213 transaction.Commit();
214 }
215 } 199 }
216 } 200 }
217 else 201 else
@@ -229,13 +213,10 @@ namespace OpenSim.Data.NHibernate
229 { 213 {
230 if (ExistsFolder(folder.ID)) 214 if (ExistsFolder(folder.ID))
231 { 215 {
232 using (ISession session = factory.OpenSession()) 216 using (ITransaction transaction = session.BeginTransaction())
233 { 217 {
234 using (ITransaction transaction = session.BeginTransaction()) 218 session.Update(folder);
235 { 219 transaction.Commit();
236 session.Update(folder);
237 transaction.Commit();
238 }
239 } 220 }
240 } 221 }
241 else 222 else
@@ -250,13 +231,10 @@ namespace OpenSim.Data.NHibernate
250 /// <param name="folder"></param> 231 /// <param name="folder"></param>
251 public void deleteInventoryFolder(LLUUID folderID) 232 public void deleteInventoryFolder(LLUUID folderID)
252 { 233 {
253 using (ISession session = factory.OpenSession()) 234 using (ITransaction transaction = session.BeginTransaction())
254 { 235 {
255 using (ITransaction transaction = session.BeginTransaction()) 236 session.Delete(folderID.ToString());
256 { 237 transaction.Commit();
257 session.Delete(folderID.ToString());
258 transaction.Commit();
259 }
260 } 238 }
261 } 239 }
262 240
@@ -329,23 +307,20 @@ namespace OpenSim.Data.NHibernate
329 /// <returns>A List of InventoryItemBase items</returns> 307 /// <returns>A List of InventoryItemBase items</returns>
330 public List<InventoryItemBase> getInventoryInFolder(LLUUID folderID) 308 public List<InventoryItemBase> getInventoryInFolder(LLUUID folderID)
331 { 309 {
332 using (ISession session = factory.OpenSession()) 310 // try {
311 ICriteria criteria = session.CreateCriteria(typeof(InventoryItemBase));
312 criteria.Add(Expression.Eq("Folder", folderID));
313 List<InventoryItemBase> list = new List<InventoryItemBase>();
314 foreach (InventoryItemBase item in criteria.List())
333 { 315 {
334 // try { 316 list.Add(item);
335 ICriteria criteria = session.CreateCriteria(typeof(InventoryItemBase));
336 criteria.Add(Expression.Eq("Folder", folderID));
337 List<InventoryItemBase> list = new List<InventoryItemBase>();
338 foreach (InventoryItemBase item in criteria.List())
339 {
340 list.Add(item);
341 }
342 return list;
343// }
344// catch
345// {
346// return new List<InventoryItemBase>();
347// }
348 } 317 }
318 return list;
319 // }
320 // catch
321 // {
322 // return new List<InventoryItemBase>();
323 // }
349 } 324 }
350 325
351 public List<InventoryFolderBase> getUserRootFolders(LLUUID user) 326 public List<InventoryFolderBase> getUserRootFolders(LLUUID user)
@@ -356,18 +331,15 @@ namespace OpenSim.Data.NHibernate
356 // see InventoryItemBase.getUserRootFolder 331 // see InventoryItemBase.getUserRootFolder
357 public InventoryFolderBase getUserRootFolder(LLUUID user) 332 public InventoryFolderBase getUserRootFolder(LLUUID user)
358 { 333 {
359 using (ISession session = factory.OpenSession()) 334 ICriteria criteria = session.CreateCriteria(typeof(InventoryFolderBase));
335 criteria.Add(Expression.Eq("ParentID", LLUUID.Zero));
336 criteria.Add(Expression.Eq("Owner", user));
337 foreach (InventoryFolderBase folder in criteria.List())
360 { 338 {
361 ICriteria criteria = session.CreateCriteria(typeof(InventoryFolderBase)); 339 return folder;
362 criteria.Add(Expression.Eq("ParentID", LLUUID.Zero));
363 criteria.Add(Expression.Eq("Owner", user));
364 foreach (InventoryFolderBase folder in criteria.List())
365 {
366 return folder;
367 }
368 m_log.ErrorFormat("No Inventory Root Folder Found for: {0}", user);
369 return null;
370 } 340 }
341 m_log.ErrorFormat("No Inventory Root Folder Found for: {0}", user);
342 return null;
371 } 343 }
372 344
373 /// <summary> 345 /// <summary>
@@ -377,15 +349,11 @@ namespace OpenSim.Data.NHibernate
377 /// <param name="parentID">ID of parent</param> 349 /// <param name="parentID">ID of parent</param>
378 private void getInventoryFolders(ref List<InventoryFolderBase> folders, LLUUID parentID) 350 private void getInventoryFolders(ref List<InventoryFolderBase> folders, LLUUID parentID)
379 { 351 {
380 using (ISession session = factory.OpenSession()) 352 ICriteria criteria = session.CreateCriteria(typeof(InventoryFolderBase));
353 criteria.Add(Expression.Eq("ParentID", parentID));
354 foreach (InventoryFolderBase item in criteria.List())
381 { 355 {
382 356 folders.Add(item);
383 ICriteria criteria = session.CreateCriteria(typeof(InventoryFolderBase));
384 criteria.Add(Expression.Eq("ParentID", parentID));
385 foreach (InventoryFolderBase item in criteria.List())
386 {
387 folders.Add(item);
388 }
389 } 357 }
390 } 358 }
391 359
diff --git a/OpenSim/Data/NHibernate/NHibernateUserData.cs b/OpenSim/Data/NHibernate/NHibernateUserData.cs
index 2bec02c..0fb297f 100644
--- a/OpenSim/Data/NHibernate/NHibernateUserData.cs
+++ b/OpenSim/Data/NHibernate/NHibernateUserData.cs
@@ -51,6 +51,7 @@ namespace OpenSim.Data.NHibernate
51 51
52 private Configuration cfg; 52 private Configuration cfg;
53 private ISessionFactory factory; 53 private ISessionFactory factory;
54 private ISession session;
54 55
55 public override void Initialise(string connect) 56 public override void Initialise(string connect)
56 { 57 {
@@ -75,7 +76,8 @@ namespace OpenSim.Data.NHibernate
75 cfg.AddAssembly("OpenSim.Data.NHibernate"); 76 cfg.AddAssembly("OpenSim.Data.NHibernate");
76 77
77 factory = cfg.BuildSessionFactory(); 78 factory = cfg.BuildSessionFactory();
78 79 session = factory.OpenSession();
80
79 // This actually does the roll forward assembly stuff 81 // This actually does the roll forward assembly stuff
80 Assembly assem = GetType().Assembly; 82 Assembly assem = GetType().Assembly;
81 Migration m = new Migration((System.Data.Common.DbConnection)factory.ConnectionProvider.GetConnection(), assem, dialect, "UserStore"); 83 Migration m = new Migration((System.Data.Common.DbConnection)factory.ConnectionProvider.GetConnection(), assem, dialect, "UserStore");
@@ -87,10 +89,7 @@ namespace OpenSim.Data.NHibernate
87 UserProfileData user = null; 89 UserProfileData user = null;
88 try 90 try
89 { 91 {
90 using (ISession session = factory.OpenSession()) 92 user = session.Load(typeof(UserProfileData), uuid) as UserProfileData;
91 {
92 user = session.Load(typeof(UserProfileData), uuid) as UserProfileData;
93 }
94 } 93 }
95 catch (Exception) {} 94 catch (Exception) {}
96 95
@@ -101,11 +100,9 @@ namespace OpenSim.Data.NHibernate
101 { 100 {
102 UserProfileData user; 101 UserProfileData user;
103 // TODO: I'm sure I'll have to do something silly here 102 // TODO: I'm sure I'll have to do something silly here
104 using (ISession session = factory.OpenSession()) 103 user = session.Load(typeof(UserProfileData), uuid) as UserProfileData;
105 { 104 user.CurrentAgent = GetAgentByUUID(uuid);
106 user = session.Load(typeof(UserProfileData), uuid) as UserProfileData; 105
107 user.CurrentAgent = GetAgentByUUID(uuid);
108 }
109 return user; 106 return user;
110 } 107 }
111 108
@@ -113,16 +110,10 @@ namespace OpenSim.Data.NHibernate
113 { 110 {
114 if (!ExistsUser(profile.ID)) 111 if (!ExistsUser(profile.ID))
115 { 112 {
116 using (ISession session = factory.OpenSession()) 113 session.Save(profile);
117 { 114 SetAgentData(profile.ID, profile.CurrentAgent);
118 using (ITransaction transaction = session.BeginTransaction()) 115 // TODO: save agent
119 { 116 session.Transaction.Commit();
120 session.Save(profile);
121 SetAgentData(profile.ID, profile.CurrentAgent, session);
122 // TODO: save agent
123 transaction.Commit();
124 }
125 }
126 } 117 }
127 else 118 else
128 { 119 {
@@ -131,7 +122,7 @@ namespace OpenSim.Data.NHibernate
131 } 122 }
132 } 123 }
133 124
134 private static void SetAgentData(LLUUID uuid, UserAgentData agent, ISession session) 125 private void SetAgentData(LLUUID uuid, UserAgentData agent)
135 { 126 {
136 if (agent == null) 127 if (agent == null)
137 { 128 {
@@ -140,14 +131,12 @@ namespace OpenSim.Data.NHibernate
140 else 131 else
141 { 132 {
142 UserAgentData old = session.Load(typeof(UserAgentData), uuid) as UserAgentData; 133 UserAgentData old = session.Load(typeof(UserAgentData), uuid) as UserAgentData;
143 if (old == null) 134 if (old != null)
144 { 135 {
145 session.Save(agent); 136 session.Delete(old);
146 }
147 else
148 {
149 session.Update(agent);
150 } 137 }
138
139 session.Save(agent);
151 } 140 }
152 141
153 } 142 }
@@ -155,16 +144,10 @@ namespace OpenSim.Data.NHibernate
155 { 144 {
156 if (ExistsUser(profile.ID)) 145 if (ExistsUser(profile.ID))
157 { 146 {
158 using (ISession session = factory.OpenSession()) 147 session.Update(profile);
159 { 148 SetAgentData(profile.ID, profile.CurrentAgent);
160 using (ITransaction transaction = session.BeginTransaction()) 149 session.Transaction.Commit();
161 { 150 return true;
162 session.Update(profile);
163 SetAgentData(profile.ID, profile.CurrentAgent, session);
164 transaction.Commit();
165 return true;
166 }
167 }
168 } 151 }
169 else 152 else
170 { 153 {
@@ -176,36 +159,27 @@ namespace OpenSim.Data.NHibernate
176 159
177 override public void AddNewUserAgent(UserAgentData agent) 160 override public void AddNewUserAgent(UserAgentData agent)
178 { 161 {
179 using (ISession session = factory.OpenSession()) 162 UserAgentData old = session.Load(typeof(UserAgentData), agent.ProfileID) as UserAgentData;
180 { 163
181 using (ITransaction transaction = session.BeginTransaction()) 164 if (old == null) {
182 { 165 session.Save(agent);
183 session.Save(agent); 166 session.Transaction.Commit();
184 transaction.Commit(); 167 } else {
185 } 168 UpdateUserAgent(agent);
186 } 169 }
187 } 170 }
188 171
189 public void UpdateUserAgent(UserAgentData agent) 172 public void UpdateUserAgent(UserAgentData agent)
190 { 173 {
191 using (ISession session = factory.OpenSession()) 174 session.Update(agent);
192 { 175 session.Transaction.Commit();
193 using (ITransaction transaction = session.BeginTransaction())
194 {
195 session.Update(agent);
196 transaction.Commit();
197 }
198 }
199 } 176 }
200 177
201 override public UserAgentData GetAgentByUUID(LLUUID uuid) 178 override public UserAgentData GetAgentByUUID(LLUUID uuid)
202 { 179 {
203 try 180 try
204 { 181 {
205 using (ISession session = factory.OpenSession()) 182 return session.Load(typeof(UserAgentData), uuid) as UserAgentData;
206 {
207 return session.Load(typeof(UserAgentData), uuid) as UserAgentData;
208 }
209 } 183 }
210 catch 184 catch
211 { 185 {
@@ -215,18 +189,15 @@ namespace OpenSim.Data.NHibernate
215 189
216 override public UserProfileData GetUserByName(string fname, string lname) 190 override public UserProfileData GetUserByName(string fname, string lname)
217 { 191 {
218 using (ISession session = factory.OpenSession()) 192 ICriteria criteria = session.CreateCriteria(typeof(UserProfileData));
193 criteria.Add(Expression.Eq("FirstName", fname));
194 criteria.Add(Expression.Eq("SurName", lname));
195 foreach (UserProfileData profile in criteria.List())
219 { 196 {
220 ICriteria criteria = session.CreateCriteria(typeof(UserProfileData)); 197 profile.CurrentAgent = GetAgentByUUID(profile.ID);
221 criteria.Add(Expression.Eq("FirstName", fname)); 198 return profile;
222 criteria.Add(Expression.Eq("SurName", lname));
223 foreach (UserProfileData profile in criteria.List())
224 {
225 profile.CurrentAgent = GetAgentByUUID(profile.ID);
226 return profile;
227 }
228 return null;
229 } 199 }
200 return null;
230 } 201 }
231 202
232 override public UserAgentData GetAgentByName(string fname, string lname) 203 override public UserAgentData GetAgentByName(string fname, string lname)
@@ -247,19 +218,16 @@ namespace OpenSim.Data.NHibernate
247 218
248 if (querysplit.Length == 2) 219 if (querysplit.Length == 2)
249 { 220 {
250 using (ISession session = factory.OpenSession()) 221 ICriteria criteria = session.CreateCriteria(typeof(UserProfileData));
222 criteria.Add(Expression.Like("FirstName", querysplit[0]));
223 criteria.Add(Expression.Like("SurName", querysplit[1]));
224 foreach (UserProfileData profile in criteria.List())
251 { 225 {
252 ICriteria criteria = session.CreateCriteria(typeof(UserProfileData)); 226 AvatarPickerAvatar user = new AvatarPickerAvatar();
253 criteria.Add(Expression.Like("FirstName", querysplit[0])); 227 user.AvatarID = profile.ID;
254 criteria.Add(Expression.Like("SurName", querysplit[1])); 228 user.firstName = profile.FirstName;
255 foreach (UserProfileData profile in criteria.List()) 229 user.lastName = profile.SurName;
256 { 230 results.Add(user);
257 AvatarPickerAvatar user = new AvatarPickerAvatar();
258 user.AvatarID = profile.ID;
259 user.firstName = profile.FirstName;
260 user.lastName = profile.SurName;
261 results.Add(user);
262 }
263 } 231 }
264 } 232 }
265 return results; 233 return results;
@@ -281,20 +249,17 @@ namespace OpenSim.Data.NHibernate
281 { 249 {
282 AvatarAppearance appearance; 250 AvatarAppearance appearance;
283 // TODO: I'm sure I'll have to do something silly here 251 // TODO: I'm sure I'll have to do something silly here
284 using (ISession session = factory.OpenSession()) 252 appearance = session.Load(typeof(AvatarAppearance), user) as AvatarAppearance;
285 { 253
286 appearance = session.Load(typeof(AvatarAppearance), user) as AvatarAppearance;
287 }
288 return appearance; 254 return appearance;
289 } 255 }
290 256
291 private bool ExistsAppearance(LLUUID uuid) 257 private bool ExistsAppearance(LLUUID uuid)
292 { 258 {
293 AvatarAppearance appearance; 259 AvatarAppearance appearance;
294 using (ISession session = factory.OpenSession()) 260
295 { 261 appearance = session.Load(typeof(AvatarAppearance), uuid) as AvatarAppearance;
296 appearance = session.Load(typeof(AvatarAppearance), uuid) as AvatarAppearance; 262
297 }
298 return (appearance == null) ? false : true; 263 return (appearance == null) ? false : true;
299 } 264 }
300 265
@@ -302,20 +267,18 @@ namespace OpenSim.Data.NHibernate
302 public override void UpdateUserAppearance(LLUUID user, AvatarAppearance appearance) 267 public override void UpdateUserAppearance(LLUUID user, AvatarAppearance appearance)
303 { 268 {
304 bool exists = ExistsAppearance(user); 269 bool exists = ExistsAppearance(user);
305 using (ISession session = factory.OpenSession()) 270
271 using (ITransaction transaction = session.BeginTransaction())
306 { 272 {
307 using (ITransaction transaction = session.BeginTransaction()) 273 if (exists)
274 {
275 session.Update(appearance);
276 }
277 else
308 { 278 {
309 if (exists) 279 session.Save(appearance);
310 {
311 session.Update(appearance);
312 }
313 else
314 {
315 session.Save(appearance);
316 }
317 transaction.Commit();
318 } 280 }
281 transaction.Commit();
319 } 282 }
320 } 283 }
321 284
diff --git a/OpenSim/Data/NHibernate/Resources/InventoryItemBase.hbm.xml b/OpenSim/Data/NHibernate/Resources/InventoryItemBase.hbm.xml
index 82a810e..167dd5b 100644
--- a/OpenSim/Data/NHibernate/Resources/InventoryItemBase.hbm.xml
+++ b/OpenSim/Data/NHibernate/Resources/InventoryItemBase.hbm.xml
@@ -18,9 +18,9 @@
18 <property name="EveryOnePermissions" type="System.UInt32" /> 18 <property name="EveryOnePermissions" type="System.UInt32" />
19 <property name="GroupID" index="item_group_id" type="OpenSim.Data.NHibernate.LLUUIDUserType, OpenSim.Data.NHibernate" /> 19 <property name="GroupID" index="item_group_id" type="OpenSim.Data.NHibernate.LLUUIDUserType, OpenSim.Data.NHibernate" />
20 <property name="GroupOwned" type="boolean" /> 20 <property name="GroupOwned" type="boolean" />
21 <property name="SalePrice" type="Int32" /> 21 <property name="SalePrice" type="System.Int32" />
22 <property name="SaleType" type="Int16" /> 22 <property name="SaleType" type="System.Byte" />
23 <property name="Flags" type="Int32" /> 23 <property name="Flags" type="Syste.UInt32" />
24 <property name="CreationDate" type="Int32" /> 24 <property name="CreationDate" type="Int32" />
25 </class> 25 </class>
26</hibernate-mapping> \ No newline at end of file 26</hibernate-mapping> \ No newline at end of file