aboutsummaryrefslogtreecommitdiffstatshomepage
path: root/OpenSim
diff options
context:
space:
mode:
authorSean Dague2008-07-16 21:27:59 +0000
committerSean Dague2008-07-16 21:27:59 +0000
commit6adac3bd5af422b80d04bac437076920b2391122 (patch)
tree2325829b27cdf51bbdff25af57811029ebfc1605 /OpenSim
parentmake ParentUUID be a cached value, but allow setting it for (diff)
downloadopensim-SC_OLD-6adac3bd5af422b80d04bac437076920b2391122.zip
opensim-SC_OLD-6adac3bd5af422b80d04bac437076920b2391122.tar.gz
opensim-SC_OLD-6adac3bd5af422b80d04bac437076920b2391122.tar.bz2
opensim-SC_OLD-6adac3bd5af422b80d04bac437076920b2391122.tar.xz
getting close on saving prims via nhibernate
Diffstat (limited to 'OpenSim')
-rw-r--r--OpenSim/Data/NHibernate/NHibernateRegionData.cs35
-rw-r--r--OpenSim/Data/NHibernate/Resources/RegionStore.hbm.xml8
2 files changed, 36 insertions, 7 deletions
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;
34using log4net; 34using log4net;
35using NHibernate; 35using NHibernate;
36using NHibernate.Cfg; 36using NHibernate.Cfg;
37using NHibernate.Expression;
37using NHibernate.Mapping.Attributes; 38using NHibernate.Mapping.Attributes;
38using NHibernate.Tool.hbm2ddl; 39using NHibernate.Tool.hbm2ddl;
39using OpenSim.Framework; 40using OpenSim.Framework;
@@ -123,12 +124,15 @@ namespace OpenSim.Data.NHibernate
123 { 124 {
124 try 125 try
125 { 126 {
127 m_log.InfoFormat("Storing part {0}", part.UUID);
126 session.SaveOrUpdate(part); 128 session.SaveOrUpdate(part);
129 session.Flush();
127 } 130 }
128 catch (Exception e) 131 catch (Exception e)
129 { 132 {
130 m_log.Error("Can't save: ", e); 133 m_log.Error("Can't save: ", e);
131 } 134 }
135
132 } 136 }
133 137
134 } 138 }
@@ -151,8 +155,33 @@ namespace OpenSim.Data.NHibernate
151 /// <returns>List of loaded groups</returns> 155 /// <returns>List of loaded groups</returns>
152 public List<SceneObjectGroup> LoadObjects(LLUUID regionUUID) 156 public List<SceneObjectGroup> LoadObjects(LLUUID regionUUID)
153 { 157 {
154 List<SceneObjectGroup> prims = new List<SceneObjectGroup>(); 158 Dictionary<LLUUID, SceneObjectGroup> SOG = new Dictionary<LLUUID, SceneObjectGroup>();
155 return prims; 159 List<SceneObjectGroup> ret = new List<SceneObjectGroup>();
160
161 ICriteria criteria = session.CreateCriteria(typeof(SceneObjectPart));
162 criteria.Add(Expression.Eq("RegionID", regionUUID));
163 criteria.AddOrder( Order.Asc("ParentID") );
164 foreach (SceneObjectPart p in criteria.List())
165 {
166 // root part
167 if (p.UUID == p.ParentUUID)
168 {
169 SceneObjectGroup group = new SceneObjectGroup();
170 group.AddPart(p);
171 group.RootPart = p;
172 SOG.Add(p.ParentUUID, group);
173 }
174 else
175 {
176 SOG[p.ParentUUID].AddPart(p);
177 }
178 }
179 foreach (SceneObjectGroup g in SOG.Values)
180 {
181 ret.Add(g);
182 }
183
184 return ret;
156 } 185 }
157 186
158 /// <summary> 187 /// <summary>
@@ -215,7 +244,7 @@ namespace OpenSim.Data.NHibernate
215 /// </summary> 244 /// </summary>
216 public void Shutdown() 245 public void Shutdown()
217 { 246 {
218 247 session.Flush();
219 } 248 }
220 249
221 /// <summary> 250 /// <summary>
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 @@
1<?xml version="1.0" encoding="utf-8" ?> 1<?xml version="1.0" encoding="utf-8" ?>
2<hibernate-mapping xmlns="urn:nhibernate-mapping-2.2"> 2<hibernate-mapping xmlns="urn:nhibernate-mapping-2.2">
3 <class name="OpenSim.Region.Environment.Scenes.SceneObjectPart, OpenSim.Region.Environment" table="Prims" lazy="false"> 3 <class name="OpenSim.Region.Environment.Scenes.SceneObjectPart, OpenSim.Region.Environment" table="Prims" lazy="false">
4 <id name="UUID" column="ID" type="OpenSim.Data.NHibernate.LLUUIDUserType, OpenSim.Data.NHibernate"> 4 <id name="UUID" type="OpenSim.Data.NHibernate.LLUUIDUserType, OpenSim.Data.NHibernate">
5 <generator class="assigned" /> 5 <generator class="assigned" />
6 </id> 6 </id>
7 <property name="ParentID" type="OpenSim.Data.NHibernate.LLUUIDUserType, OpenSim.Data.NHibernate" /> 7 <property name="ParentID" type="OpenSim.Data.NHibernate.LLUUIDUserType, OpenSim.Data.NHibernate" />
@@ -56,9 +56,9 @@
56 </property> 56 </property>
57 57
58 <property name="SitTargetPositionLL" type="OpenSim.Data.NHibernate.LLVector3UserType, OpenSim.Data.NHibernate" > 58 <property name="SitTargetPositionLL" type="OpenSim.Data.NHibernate.LLVector3UserType, OpenSim.Data.NHibernate" >
59 <column name="SitTargetPosX" /> 59 <column name="SitTargetOffsetX" />
60 <column name="SitTargetPosY" /> 60 <column name="SitTargetOffsetY" />
61 <column name="SitTargetPosZ" /> 61 <column name="SitTargetOffsetZ" />
62 </property> 62 </property>
63 63
64 <property name="RotationOffset" type="OpenSim.Data.NHibernate.LLQuaternionUserType, OpenSim.Data.NHibernate" > 64 <property name="RotationOffset" type="OpenSim.Data.NHibernate.LLQuaternionUserType, OpenSim.Data.NHibernate" >