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 ++++++++++++++++++++--
.../Data/NHibernate/Resources/RegionStore.hbm.xml | 8 ++---
2 files changed, 36 insertions(+), 7 deletions(-)
(limited to 'OpenSim')
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();
}
///
diff --git a/OpenSim/Data/NHibernate/Resources/RegionStore.hbm.xml b/OpenSim/Data/NHibernate/Resources/RegionStore.hbm.xml
index 4fe01e1..a605e48 100644
--- a/OpenSim/Data/NHibernate/Resources/RegionStore.hbm.xml
+++ b/OpenSim/Data/NHibernate/Resources/RegionStore.hbm.xml
@@ -1,7 +1,7 @@
-
+
@@ -56,9 +56,9 @@
-
-
-
+
+
+
--
cgit v1.1