From d5e0a3a184d52121a82e2f5f4c7f2acf5befe3e4 Mon Sep 17 00:00:00 2001 From: Sean Dague Date: Thu, 17 Jul 2008 18:58:47 +0000 Subject: got basic region object saves working time for lunch --- OpenSim/Data/NHibernate/NHibernateRegionData.cs | 30 ++++++++++++++++++++++++- 1 file changed, 29 insertions(+), 1 deletion(-) 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 @@ */ using System; +using System.Collections; using System.Collections.Generic; using System.IO; using System.Reflection; @@ -112,6 +113,33 @@ namespace OpenSim.Data.NHibernate { return null; } + + private void SaveOrUpdate(SceneObjectPart p) + { + try + { + ICriteria criteria = session.CreateCriteria(typeof(SceneObjectPart)); + criteria.Add(Expression.Eq("UUID", p.UUID)); + if (criteria.List().Count < 1) + { + session.Save(p); + } + else if (criteria.List().Count == 1) + { + SceneObjectPart old = (SceneObjectPart)criteria.List()[0]; + session.Evict(old); + session.Update(p); + } + else + { + m_log.Error("Not unique"); + } + } + catch (Exception e) + { + m_log.Error("[NHIBERNATE] issue saving asset", e); + } + } /// /// Adds an object into region storage @@ -125,7 +153,7 @@ namespace OpenSim.Data.NHibernate foreach (SceneObjectPart part in obj.Children.Values) { m_log.InfoFormat("Storing part {0}", part.UUID); - session.SaveOrUpdate(part); + SaveOrUpdate(part); } session.Flush(); } -- cgit v1.1