aboutsummaryrefslogtreecommitdiffstatshomepage
path: root/OpenSim/Data
diff options
context:
space:
mode:
Diffstat (limited to 'OpenSim/Data')
-rw-r--r--OpenSim/Data/NHibernate/NHibernateRegionData.cs30
1 files changed, 29 insertions, 1 deletions
diff --git a/OpenSim/Data/NHibernate/NHibernateRegionData.cs b/OpenSim/Data/NHibernate/NHibernateRegionData.cs
index 8ca0afe..3ba3556 100644
--- a/OpenSim/Data/NHibernate/NHibernateRegionData.cs
+++ b/OpenSim/Data/NHibernate/NHibernateRegionData.cs
@@ -26,6 +26,7 @@
26 */ 26 */
27 27
28using System; 28using System;
29using System.Collections;
29using System.Collections.Generic; 30using System.Collections.Generic;
30using System.IO; 31using System.IO;
31using System.Reflection; 32using System.Reflection;
@@ -112,6 +113,33 @@ namespace OpenSim.Data.NHibernate
112 { 113 {
113 return null; 114 return null;
114 } 115 }
116
117 private void SaveOrUpdate(SceneObjectPart p)
118 {
119 try
120 {
121 ICriteria criteria = session.CreateCriteria(typeof(SceneObjectPart));
122 criteria.Add(Expression.Eq("UUID", p.UUID));
123 if (criteria.List().Count < 1)
124 {
125 session.Save(p);
126 }
127 else if (criteria.List().Count == 1)
128 {
129 SceneObjectPart old = (SceneObjectPart)criteria.List()[0];
130 session.Evict(old);
131 session.Update(p);
132 }
133 else
134 {
135 m_log.Error("Not unique");
136 }
137 }
138 catch (Exception e)
139 {
140 m_log.Error("[NHIBERNATE] issue saving asset", e);
141 }
142 }
115 143
116 /// <summary> 144 /// <summary>
117 /// Adds an object into region storage 145 /// Adds an object into region storage
@@ -125,7 +153,7 @@ namespace OpenSim.Data.NHibernate
125 foreach (SceneObjectPart part in obj.Children.Values) 153 foreach (SceneObjectPart part in obj.Children.Values)
126 { 154 {
127 m_log.InfoFormat("Storing part {0}", part.UUID); 155 m_log.InfoFormat("Storing part {0}", part.UUID);
128 session.SaveOrUpdate(part); 156 SaveOrUpdate(part);
129 } 157 }
130 session.Flush(); 158 session.Flush();
131 } 159 }