aboutsummaryrefslogtreecommitdiffstatshomepage
path: root/OpenSim/Data/NHibernate/NHibernateAssetData.cs
diff options
context:
space:
mode:
Diffstat (limited to 'OpenSim/Data/NHibernate/NHibernateAssetData.cs')
-rw-r--r--OpenSim/Data/NHibernate/NHibernateAssetData.cs39
1 files changed, 16 insertions, 23 deletions
diff --git a/OpenSim/Data/NHibernate/NHibernateAssetData.cs b/OpenSim/Data/NHibernate/NHibernateAssetData.cs
index db77942..89f907f 100644
--- a/OpenSim/Data/NHibernate/NHibernateAssetData.cs
+++ b/OpenSim/Data/NHibernate/NHibernateAssetData.cs
@@ -49,6 +49,7 @@ namespace OpenSim.Data.NHibernate
49 49
50 private Configuration cfg; 50 private Configuration cfg;
51 private ISessionFactory factory; 51 private ISessionFactory factory;
52 private ISession session;
52 53
53 public override void Initialise() 54 public override void Initialise()
54 { 55 {
@@ -87,27 +88,25 @@ namespace OpenSim.Data.NHibernate
87 cfg.AddInputStream(stream); 88 cfg.AddInputStream(stream);
88 89
89 factory = cfg.BuildSessionFactory(); 90 factory = cfg.BuildSessionFactory();
90 91 session = factory.OpenSession();
91 92
92 // This actually does the roll forward assembly stuff 93 // This actually does the roll forward assembly stuff
93 Assembly assem = GetType().Assembly; 94 Assembly assem = GetType().Assembly;
94 Migration m = new Migration((System.Data.Common.DbConnection)factory.ConnectionProvider.GetConnection(), assem, dialect, "AssetStore"); 95 Migration m = new Migration((System.Data.Common.DbConnection)factory.ConnectionProvider.GetConnection(), assem, dialect, "AssetStore");
95 m.Update(); 96 m.Update();
97
96 } 98 }
97 99
98 override public AssetBase FetchAsset(LLUUID uuid) 100 override public AssetBase FetchAsset(LLUUID uuid)
99 { 101 {
100 using (ISession session = factory.OpenSession()) 102 try
101 { 103 {
102 try 104 return session.Load(typeof(AssetBase), uuid) as AssetBase;
103 { 105 }
104 return session.Load(typeof(AssetBase), uuid) as AssetBase; 106 catch (Exception e)
105 } 107 {
106 catch (Exception e) 108 m_log.Error("[NHIBERNATE] issue loading asset", e);
107 { 109 return null;
108 m_log.Error("[NHIBERNATE] issue loading asset", e);
109 return null;
110 }
111 } 110 }
112 } 111 }
113 112
@@ -116,13 +115,10 @@ namespace OpenSim.Data.NHibernate
116 if (!ExistsAsset(asset.FullID)) 115 if (!ExistsAsset(asset.FullID))
117 { 116 {
118 m_log.InfoFormat("[NHIBERNATE] inserting asset {0}", asset.FullID); 117 m_log.InfoFormat("[NHIBERNATE] inserting asset {0}", asset.FullID);
119 using (ISession session = factory.OpenSession()) 118 using (ITransaction transaction = session.BeginTransaction())
120 { 119 {
121 using (ITransaction transaction = session.BeginTransaction()) 120 session.Save(asset);
122 { 121 transaction.Commit();
123 session.Save(asset);
124 transaction.Commit();
125 }
126 } 122 }
127 } 123 }
128 } 124 }
@@ -131,13 +127,10 @@ namespace OpenSim.Data.NHibernate
131 { 127 {
132 if (ExistsAsset(asset.FullID)) 128 if (ExistsAsset(asset.FullID))
133 { 129 {
134 using (ISession session = factory.OpenSession()) 130 using (ITransaction transaction = session.BeginTransaction())
135 { 131 {
136 using (ITransaction transaction = session.BeginTransaction()) 132 session.Update(asset);
137 { 133 transaction.Commit();
138 session.Update(asset);
139 transaction.Commit();
140 }
141 } 134 }
142 } 135 }
143 } 136 }