-
Notifications
You must be signed in to change notification settings - Fork 931
NH-4026 - Upgrade Firebird driver and use server #639
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Changes from 16 commits
7c8aa5a
4d36a19
fd84733
fe0e8ac
728ede7
704c122
96ac0d3
ab0410c
da88449
d75f7ef
8b832cf
e794efe
d04fafa
3a5395e
d71f510
b42cfb3
907b5cf
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
This file was deleted.
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,34 @@ | ||
|
||
Installation steps for Firebird for NH TeamCity: | ||
|
||
1. Download Firebird (Firebird-3.0.2.32703_0_x64): https://www.firebirdsql.org/en/server-packages/; | ||
2. Run the installer AS ADMINISTRATOR... Use the default firebird password when prompted: masterkey. | ||
3. Leave other settings with their defaults. | ||
4. The setup should install Firebird on the machine; | ||
5. Go into Firebird folder (c:\program files\firebird\) and create a folder named Data; | ||
6. Go in Firebird installation directory and open databases.conf; | ||
7. Add in "Live Databases" section: | ||
nhibernate = D:\SqlData\Firebird\nhibernate.fdb | ||
8. Open firebird.conf; | ||
9. Ensure AuthClient, AuthServer and UserManager are set to Srp only: | ||
AuthServer = Srp | ||
AuthClient = Srp | ||
UserManager = Srp | ||
10. Ensure WireCrypt is set to Enabled. | ||
WireCrypt = Enabled | ||
11. Restart Firebird service. | ||
|
||
The TestDatabaseSetup will create the database on the Teamcity agent. It will create the folder | ||
D:\SqlData\Firebird if it is missing. Firebird is particularly sensitive to disk performances, | ||
and D: is supposed to be local to the host, thus this choice. | ||
For manual testing, take care of not creating it with inadequate acl on the file. This may happen | ||
if you use ISQL with a connection string causing it to create it in embedded mode, without actually | ||
using the server. Prefixing your path with "localhost:" should avoid that. | ||
|
||
For tests performances, and since it is just an expandable test database, better disable forced writes. | ||
Since those tests drop/create schema constantly, they are quite heavy on writes and this single setting | ||
can have a six fold impact on their duration. For changing it, do: | ||
a. Stop Firebird service. | ||
b. From Firebird installation folder, run: | ||
gfix -w async nhibernate -user SYSDBA | ||
c. Restart Firebird service. |
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,6 +1,4 @@ | ||
using System.Linq; | ||
using NHibernate.Cfg.MappingSchema; | ||
using NHibernate.Linq; | ||
using NHibernate.Cfg.MappingSchema; | ||
using NHibernate.Mapping.ByCode; | ||
using NUnit.Framework; | ||
|
||
|
@@ -15,9 +13,11 @@ protected override HbmMapping GetMappings() | |
mapper.Class<Document>(rc => | ||
{ | ||
rc.Id(x => x.Id, idMapper => idMapper.Generator(Generators.Identity)); | ||
rc.ManyToOne(x => x.Blob, m => | ||
rc.ManyToOne(x => x.Blob, | ||
m => | ||
{ | ||
m.Cascade(Mapping.ByCode.Cascade.All); | ||
m.Column("`Blob`"); | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. I think the correct way to do this is to mark "blob" as a keyword for Firebird dialect. There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more.
Maybe a lot more are missing... There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. And does not work anyway. Test failing again. There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Those keywords are seldom used in the code base. Only the There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Why "date"? it's "blob" There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. That is the current only registered word. For my local test I have added "blob". But that has no effect on column quoting. |
||
}); | ||
rc.Property(x => x.Name); | ||
}); | ||
|
@@ -30,21 +30,31 @@ protected override HbmMapping GetMappings() | |
y.Length(int.MaxValue); | ||
y.Lazy(true); | ||
}); | ||
map.Table("`Blob`"); | ||
}); | ||
|
||
return mapper.CompileMappingForAllExplicitlyAddedEntities(); | ||
} | ||
|
||
private int _blobId; | ||
private int _docId; | ||
|
||
protected override void OnSetUp() | ||
{ | ||
using (ISession session = OpenSession()) | ||
using (ITransaction transaction = session.BeginTransaction()) | ||
{ | ||
var e1 = new Document { Name = "Bob" }; | ||
e1.Blob = new Blob { Bytes = new byte[] { 1, 2, 3 } }; | ||
var e1 = new Document | ||
{ | ||
Name = "Bob", | ||
Blob = new Blob {Bytes = new byte[] {1, 2, 3}} | ||
}; | ||
|
||
session.Save(e1); | ||
|
||
session.Flush(); | ||
|
||
_blobId = e1.Blob.Id; | ||
_docId = e1.Id; | ||
transaction.Commit(); | ||
} | ||
} | ||
|
@@ -71,7 +81,7 @@ public void TestNoTargetException() | |
document.Blob = blob; | ||
|
||
using (ISession session = OpenSession()) | ||
using (ITransaction transaction = session.BeginTransaction()) | ||
using (session.BeginTransaction()) | ||
{ | ||
session.Merge(document); | ||
} | ||
|
@@ -82,7 +92,7 @@ private Blob LoadDetachedBlob() | |
using (ISession session = OpenSession()) | ||
using (session.BeginTransaction()) | ||
{ | ||
var blob = session.Get<Blob>(1); | ||
var blob = session.Get<Blob>(_blobId); | ||
NHibernateUtil.Initialize(blob.Bytes); | ||
return blob; | ||
} | ||
|
@@ -93,7 +103,7 @@ private Document LoadDetachedEntity() | |
using (ISession session = OpenSession()) | ||
using (session.BeginTransaction()) | ||
{ | ||
return session.Get<Document>(1); | ||
return session.Get<Document>(_docId); | ||
} | ||
} | ||
} | ||
|
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -102,17 +102,17 @@ private static void SetupSqlServerOdbc(Cfg.Configuration cfg) | |
|
||
private static void SetupFirebird(Cfg.Configuration cfg) | ||
{ | ||
Directory.CreateDirectory(@"D:\SqlData\Firebird"); | ||
|
||
var connStr = cfg.Properties[Cfg.Environment.ConnectionString]; | ||
try | ||
{ | ||
if (File.Exists("NHibernate.fdb")) | ||
File.Delete("NHibernate.fdb"); | ||
FbConnection.DropDatabase(connStr); | ||
} | ||
catch (Exception e) | ||
{ | ||
Console.WriteLine(e); | ||
} | ||
|
||
FbConnection.CreateDatabase("Database=NHibernate.fdb;ServerType=1"); | ||
FbConnection.CreateDatabase(connStr, forcedWrites:false); | ||
} | ||
|
||
private static void SetupSqlServerCe(Cfg.Configuration cfg) | ||
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Why not make it local?
Uh oh!
There was an error while loading. Please reload this page.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Local to the database server? Would be on
C:
, which is not local to the host. Local to the NHibernate test client? The path seems not frozen, only embedded mode can do that, where the client is the server too. I think Firebird mainstream usage is as an actual server, not as embedded mode. So I would rather test it as an actual server. And as showcase by Nathan branch, Firebird v3 embedded mode seems to need a new dialect.When using a database server, does it really make sens to locate the database relatively to the client? That should be the server choice, not the client. Currently this is done with a configured alias in
FireBird_3_0\databases.conf
file, which decides where to put the file for the aliasnhibernate
.