diff --git a/OpenSim/Data/NHibernate/NHibernateRegionData.cs b/OpenSim/Data/NHibernate/NHibernateRegionData.cs index 98d82a1c09..1f997e7d1a 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 4fe01e1780..a605e486b9 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 @@ - - - + + +