Skip to content

Commit e1ab8b7

Browse files
author
Xavier Jefferson
committed
Modify upserts to use a transaction
1 parent e9c74e8 commit e1ab8b7

File tree

2 files changed

+14
-11
lines changed

2 files changed

+14
-11
lines changed

Hangfire.FluentNHibernateStorage/FluentNHibernateJobStorageConnection.cs

+12-9
Original file line numberDiff line numberDiff line change
@@ -102,15 +102,18 @@ public override void SetJobParameter(string id, string name, string value)
102102
return;
103103
}
104104

105-
Storage.UseSession(session =>
105+
Storage.UseTransaction(session =>
106106
{
107-
session.UpsertEntity<_JobParameter>(i => i.Id == converter.Value && i.Name == name,
108-
i => i.Value = value, i =>
109-
{
110-
i.Job = new _Job {Id = converter.Value};
111-
i.Name = name;
112-
});
113-
;
107+
108+
session.UpsertEntity<_JobParameter>(i => i.Id == converter.Value && i.Name == name,
109+
i => i.Value = value, i =>
110+
{
111+
i.Job = new _Job {Id = converter.Value};
112+
i.Name = name;
113+
});
114+
;
115+
116+
114117
});
115118
}
116119

@@ -215,7 +218,7 @@ public override void AnnounceServer(string serverId, ServerContext context)
215218
if (serverId == null) throw new ArgumentNullException("serverId");
216219
if (context == null) throw new ArgumentNullException("context");
217220

218-
Storage.UseSession(session =>
221+
Storage.UseTransaction(session =>
219222
{
220223
session.UpsertEntity<_Server>(i => i.Id == serverId,
221224
i =>

nuspecs/Hangfire.FluentNHibernateStorage.nuspec

+2-2
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,7 @@
33
<package>
44
<metadata>
55
<id>Hangfire.FluentNHibernateStorage</id>
6-
<version>1.1.2112</version>
6+
<version>1.1.2114</version>
77
<authors>Xavier Jefferson</authors>
88
<owners>XavierJefferson</owners>
99
<licenseUrl>https://www.gnu.org/licenses/lgpl-3.0.en.html</licenseUrl>
@@ -12,7 +12,7 @@
1212
<requireLicenseAcceptance>false</requireLicenseAcceptance>
1313
<description>A Hangfire storage provider for SQL Server, MySQL, Oracle, DB/2, PostgreSQL, and Firebird</description>
1414
<releaseNotes>
15-
In the JobParameter table, make sure we can't store multiple rows of the same parameter name for a given job id. Added an index and modified the upsert.
15+
In the JobParameter table, make sure we can't store multiple rows of the same parameter name for a given job id. Added an index and modified the upsert to use a transaction.
1616
</releaseNotes>
1717
<copyright>Copyright © 2019 Xavier Jefferson</copyright>
1818
<tags>hangfire storage provider mssql mysql oracle postgresql firebird db2</tags>

0 commit comments

Comments
 (0)