got basic region object saves working time for lunch

0.6.0-stable
Sean Dague 2008-07-17 18:58:47 +00:00
parent 9aa0302e5b
commit d5e0a3a184
1 changed files with 29 additions and 1 deletions

View File

@ -26,6 +26,7 @@
*/ */
using System; using System;
using System.Collections;
using System.Collections.Generic; using System.Collections.Generic;
using System.IO; using System.IO;
using System.Reflection; using System.Reflection;
@ -113,6 +114,33 @@ namespace OpenSim.Data.NHibernate
return null; 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);
}
}
/// <summary> /// <summary>
/// Adds an object into region storage /// Adds an object into region storage
/// </summary> /// </summary>
@ -125,7 +153,7 @@ namespace OpenSim.Data.NHibernate
foreach (SceneObjectPart part in obj.Children.Values) foreach (SceneObjectPart part in obj.Children.Values)
{ {
m_log.InfoFormat("Storing part {0}", part.UUID); m_log.InfoFormat("Storing part {0}", part.UUID);
session.SaveOrUpdate(part); SaveOrUpdate(part);
} }
session.Flush(); session.Flush();
} }