aboutsummaryrefslogtreecommitdiffstatshomepage
path: root/OpenSim/Data/NHibernate/NHibernateRegionData.cs
diff options
context:
space:
mode:
authorSean Dague2008-07-18 15:06:24 +0000
committerSean Dague2008-07-18 15:06:24 +0000
commitaec5f0ceed08b3ac9f94752a7d18ffe73d5abbf2 (patch)
treeb977e0a529d3012d9de7b1674d1664d2c4f6f852 /OpenSim/Data/NHibernate/NHibernateRegionData.cs
parent* refactor: break out sog loading code into two parts so that post-deserializ... (diff)
downloadopensim-SC_OLD-aec5f0ceed08b3ac9f94752a7d18ffe73d5abbf2.zip
opensim-SC_OLD-aec5f0ceed08b3ac9f94752a7d18ffe73d5abbf2.tar.gz
opensim-SC_OLD-aec5f0ceed08b3ac9f94752a7d18ffe73d5abbf2.tar.bz2
opensim-SC_OLD-aec5f0ceed08b3ac9f94752a7d18ffe73d5abbf2.tar.xz
found a better pattern for SaveOrUpdate with nhibernate
cleaned up the asset path a bit
Diffstat (limited to 'OpenSim/Data/NHibernate/NHibernateRegionData.cs')
-rw-r--r--OpenSim/Data/NHibernate/NHibernateRegionData.cs56
1 files changed, 21 insertions, 35 deletions
diff --git a/OpenSim/Data/NHibernate/NHibernateRegionData.cs b/OpenSim/Data/NHibernate/NHibernateRegionData.cs
index 3d2d0e6..40861ae 100644
--- a/OpenSim/Data/NHibernate/NHibernateRegionData.cs
+++ b/OpenSim/Data/NHibernate/NHibernateRegionData.cs
@@ -114,31 +114,25 @@ namespace OpenSim.Data.NHibernate
114 return null; 114 return null;
115 } 115 }
116 116
117 // This looks inefficient, but it turns out that it isn't
118 // based on trial runs with nhibernate 1.2
117 private void SaveOrUpdate(SceneObjectPart p) 119 private void SaveOrUpdate(SceneObjectPart p)
118 { 120 {
119 try 121 try
120 { 122 {
121 ICriteria criteria = session.CreateCriteria(typeof(SceneObjectPart)); 123 SceneObjectPart old = session.Load(typeof(SceneObjectPart), p.UUID) as SceneObjectPart;
122 criteria.Add(Expression.Eq("UUID", p.UUID)); 124 session.Evict(old);
123 ArrayList l = (ArrayList)criteria.List(); 125 session.Update(p);
124 if (l.Count < 1) 126 m_log.InfoFormat("[NHIBERNATE] updating object {0}", p.UUID);
125 { 127 }
126 session.Save(p); 128 catch (ObjectNotFoundException e)
127 } 129 {
128 else if (l.Count == 1) 130 m_log.InfoFormat("[NHIBERNATE] saving object {0}", p.UUID);
129 { 131 session.Save(p);
130 SceneObjectPart old = (SceneObjectPart)l[0];
131 session.Evict(old);
132 session.Update(p);
133 }
134 else
135 {
136 m_log.Error("Not unique");
137 }
138 } 132 }
139 catch (Exception e) 133 catch (Exception e)
140 { 134 {
141 m_log.Error("[NHIBERNATE] issue saving prim", e); 135 m_log.Error("[NHIBERNATE] issue saving part", e);
142 } 136 }
143 } 137 }
144 138
@@ -146,23 +140,15 @@ namespace OpenSim.Data.NHibernate
146 { 140 {
147 try 141 try
148 { 142 {
149 ICriteria criteria = session.CreateCriteria(typeof(Terrain)); 143 Terrain old = session.Load(typeof(Terrain), t.RegionID) as Terrain;
150 criteria.Add(Expression.Eq("RegionID", t.RegionID)); 144 session.Evict(old);
151 ArrayList l = (ArrayList)criteria.List(); 145 session.Update(t);
152 if (l.Count < 1) 146 session.Flush();
153 { 147 }
154 session.Save(t); 148 catch (ObjectNotFoundException e)
155 } 149 {
156 else if (l.Count == 1) 150 session.Save(t);
157 { 151 session.Flush();
158 Terrain old = (Terrain)l[0];
159 session.Evict(old);
160 session.Update(t);
161 }
162 else
163 {
164 m_log.Error("Not unique");
165 }
166 } 152 }
167 catch (Exception e) 153 catch (Exception e)
168 { 154 {