|
| 1 | +using System.Linq; |
| 2 | +using NHibernate.Cfg; |
| 3 | +using NHibernate.Cfg.MappingSchema; |
| 4 | +using NHibernate.Dialect; |
| 5 | +using NHibernate.Mapping.ByCode; |
| 6 | +using NUnit.Framework; |
| 7 | + |
| 8 | +namespace NHibernate.Test.NHSpecificTest.GH3113 |
| 9 | +{ |
| 10 | + [TestFixture] |
| 11 | + public class ByCodeFixture : TestCaseMappingByCode |
| 12 | + { |
| 13 | + protected override HbmMapping GetMappings() |
| 14 | + { |
| 15 | + var mapper = new ModelMapper(); |
| 16 | + mapper.Class<Entity>(rc => |
| 17 | + { |
| 18 | + rc.Id(x => x.Id, m => m.Generator(Generators.GuidComb)); |
| 19 | + rc.Property(x => x.Name); |
| 20 | + }); |
| 21 | + |
| 22 | + return mapper.CompileMappingForAllExplicitlyAddedEntities(); |
| 23 | + } |
| 24 | + |
| 25 | + protected override bool AppliesTo(Dialect.Dialect dialect) |
| 26 | + { |
| 27 | + return dialect is Oracle9iDialect; |
| 28 | + } |
| 29 | + |
| 30 | + protected override void Configure(Configuration configuration) |
| 31 | + { |
| 32 | + var dialect = NHibernate.Dialect.Dialect.GetDialect(configuration.Properties); |
| 33 | + if (dialect is Oracle8iDialect) |
| 34 | + configuration.SetProperty(Environment.Dialect, typeof(Oracle9iDialect).FullName); |
| 35 | + |
| 36 | + base.Configure(configuration); |
| 37 | + } |
| 38 | + |
| 39 | + protected override void OnSetUp() |
| 40 | + { |
| 41 | + using (var session = OpenSession()) |
| 42 | + using (var transaction = session.BeginTransaction()) |
| 43 | + { |
| 44 | + var e1 = new Entity { Name = "Bob" }; |
| 45 | + session.Save(e1); |
| 46 | + |
| 47 | + var e2 = new Entity { Name = "Sally" }; |
| 48 | + session.Save(e2); |
| 49 | + |
| 50 | + transaction.Commit(); |
| 51 | + } |
| 52 | + } |
| 53 | + |
| 54 | + protected override void OnTearDown() |
| 55 | + { |
| 56 | + using (var session = OpenSession()) |
| 57 | + using (var transaction = session.BeginTransaction()) |
| 58 | + { |
| 59 | + session.CreateQuery("delete from System.Object").ExecuteUpdate(); |
| 60 | + |
| 61 | + transaction.Commit(); |
| 62 | + } |
| 63 | + } |
| 64 | + |
| 65 | + [Test] |
| 66 | + public void JoinFailsOnOracle9Dialect() |
| 67 | + { |
| 68 | + using (var session = OpenSession()) |
| 69 | + { |
| 70 | + var result = from e in session.Query<Entity>() |
| 71 | + join e2 in session.Query<Entity>() on e.Id equals e2.Id |
| 72 | + where e.Name == "Bob" |
| 73 | + select e.Name; |
| 74 | + |
| 75 | + Assert.That(result.ToList(), Has.Count.EqualTo(1)); |
| 76 | + } |
| 77 | + } |
| 78 | + } |
| 79 | +} |
0 commit comments