From 6adac3bd5af422b80d04bac437076920b2391122 Mon Sep 17 00:00:00 2001
From: Sean Dague
Date: Wed, 16 Jul 2008 21:27:59 +0000
Subject: getting close on saving prims via nhibernate
---
OpenSim/Data/NHibernate/NHibernateRegionData.cs | 35 ++++++++++++++++++++++---
1 file changed, 32 insertions(+), 3 deletions(-)
(limited to 'OpenSim/Data/NHibernate/NHibernateRegionData.cs')
diff --git a/OpenSim/Data/NHibernate/NHibernateRegionData.cs b/OpenSim/Data/NHibernate/NHibernateRegionData.cs
index 98d82a1..1f997e7 100644
--- a/OpenSim/Data/NHibernate/NHibernateRegionData.cs
+++ b/OpenSim/Data/NHibernate/NHibernateRegionData.cs
@@ -34,6 +34,7 @@ using libsecondlife;
using log4net;
using NHibernate;
using NHibernate.Cfg;
+using NHibernate.Expression;
using NHibernate.Mapping.Attributes;
using NHibernate.Tool.hbm2ddl;
using OpenSim.Framework;
@@ -123,12 +124,15 @@ namespace OpenSim.Data.NHibernate
{
try
{
+ m_log.InfoFormat("Storing part {0}", part.UUID);
session.SaveOrUpdate(part);
+ session.Flush();
}
catch (Exception e)
{
m_log.Error("Can't save: ", e);
}
+
}
}
@@ -151,8 +155,33 @@ namespace OpenSim.Data.NHibernate
/// List of loaded groups
public List LoadObjects(LLUUID regionUUID)
{
- List prims = new List();
- return prims;
+ Dictionary SOG = new Dictionary();
+ List ret = new List();
+
+ ICriteria criteria = session.CreateCriteria(typeof(SceneObjectPart));
+ criteria.Add(Expression.Eq("RegionID", regionUUID));
+ criteria.AddOrder( Order.Asc("ParentID") );
+ foreach (SceneObjectPart p in criteria.List())
+ {
+ // root part
+ if (p.UUID == p.ParentUUID)
+ {
+ SceneObjectGroup group = new SceneObjectGroup();
+ group.AddPart(p);
+ group.RootPart = p;
+ SOG.Add(p.ParentUUID, group);
+ }
+ else
+ {
+ SOG[p.ParentUUID].AddPart(p);
+ }
+ }
+ foreach (SceneObjectGroup g in SOG.Values)
+ {
+ ret.Add(g);
+ }
+
+ return ret;
}
///
@@ -215,7 +244,7 @@ namespace OpenSim.Data.NHibernate
///
public void Shutdown()
{
-
+ session.Flush();
}
///
--
cgit v1.1