aboutsummaryrefslogtreecommitdiffstatshomepage
path: root/OpenSim/Data/NHibernate/NHibernateAssetData.cs
diff options
context:
space:
mode:
Diffstat (limited to '')
-rw-r--r--OpenSim/Data/NHibernate/NHibernateAssetData.cs45
1 files changed, 28 insertions, 17 deletions
diff --git a/OpenSim/Data/NHibernate/NHibernateAssetData.cs b/OpenSim/Data/NHibernate/NHibernateAssetData.cs
index eb4e14c..488cae4 100644
--- a/OpenSim/Data/NHibernate/NHibernateAssetData.cs
+++ b/OpenSim/Data/NHibernate/NHibernateAssetData.cs
@@ -26,6 +26,7 @@
26 */ 26 */
27 27
28using System; 28using System;
29using System.Collections;
29using System.IO; 30using System.IO;
30using System.Reflection; 31using System.Reflection;
31using System.Text.RegularExpressions; 32using System.Text.RegularExpressions;
@@ -33,6 +34,7 @@ using libsecondlife;
33using log4net; 34using log4net;
34using NHibernate; 35using NHibernate;
35using NHibernate.Cfg; 36using NHibernate.Cfg;
37using NHibernate.Expression;
36using NHibernate.Mapping.Attributes; 38using NHibernate.Mapping.Attributes;
37using NHibernate.Tool.hbm2ddl; 39using NHibernate.Tool.hbm2ddl;
38using OpenSim.Framework; 40using OpenSim.Framework;
@@ -105,36 +107,45 @@ namespace OpenSim.Data.NHibernate
105 { 107 {
106 return session.Load(typeof(AssetBase), uuid) as AssetBase; 108 return session.Load(typeof(AssetBase), uuid) as AssetBase;
107 } 109 }
110 catch (ObjectNotFoundException e)
111 {
112 m_log.ErrorFormat("[NHIBERNATE] no such asset {0}", uuid);
113 return null;
114 }
108 catch (Exception e) 115 catch (Exception e)
109 { 116 {
110 m_log.Error("[NHIBERNATE] issue loading asset", e); 117 m_log.Error("[NHIBERNATE] unexpected exception: ", e);
111 return null; 118 return null;
112 } 119 }
113 } 120 }
114 121
115 override public void CreateAsset(AssetBase asset) 122 private void Save(AssetBase asset)
116 { 123 {
117 if (!ExistsAsset(asset.FullID)) 124 try
125 {
126 AssetBase a = session.Load(typeof(AssetBase), asset.FullID) as AssetBase;
127 }
128 catch (ObjectNotFoundException e)
129 {
130 session.Save(asset);
131 session.Flush();
132 }
133 catch (Exception e)
118 { 134 {
119 m_log.InfoFormat("[NHIBERNATE] inserting asset {0}", asset.FullID); 135 m_log.Error("[NHIBERNATE] issue saving asset", e);
120 using (ITransaction transaction = session.BeginTransaction())
121 {
122 session.Save(asset);
123 transaction.Commit();
124 }
125 } 136 }
126 } 137 }
127 138
139 override public void CreateAsset(AssetBase asset)
140 {
141 m_log.InfoFormat("[NHIBERNATE] inserting asset {0}", asset.FullID);
142 Save(asset);
143 }
144
128 override public void UpdateAsset(AssetBase asset) 145 override public void UpdateAsset(AssetBase asset)
129 { 146 {
130 if (ExistsAsset(asset.FullID)) 147 m_log.InfoFormat("[NHIBERNATE] updating asset {0}", asset.FullID);
131 { 148 Save(asset);
132 using (ITransaction transaction = session.BeginTransaction())
133 {
134 session.Update(asset);
135 transaction.Commit();
136 }
137 }
138 } 149 }
139 150
140 // private void LogAssetLoad(AssetBase asset) 151 // private void LogAssetLoad(AssetBase asset)