Previous CloneSet | Next CloneSet | Back to Main Report |
Clone Mass | Clones in CloneSet | Parameter Count | Clone Similarity | Syntax Category [Sequence Length] |
---|---|---|---|---|
39 | 2 | 5 | 0.992 | class_member_declaration |
Clone Abstraction | Parameter Bindings |
Clone Instance (Click to see clone) | Line Count | Source Line | Source File |
---|---|---|---|
1 | 39 | 54 | src/NHibernate.Test/NHSpecificTest/NH1490/Fixture.cs |
2 | 39 | 96 | src/NHibernate.Test/NHSpecificTest/NH1490/Fixture.cs |
| ||||
[Test] public void Also_Works_With_Filter() { using (ISession s = OpenSession()) using (ITransaction tx = s.BeginTransaction()) { Customer c = new Customer("Somebody"); c.Category = new Category("User"); s.Save(c.Category); c.IsActive = true; c.Category.IsActive = true; s.Save(c); tx.Commit(); } using (ISession s = OpenSession()) { s.DisableFilter("onlyActive"); IFilter fltr = s.EnableFilter("onlyActive"); if (Dialect is PostgreSQLDialect) fltr.SetParameter("activeFlag", true); else fltr.SetParameter("activeFlag", 1); // Customer is parametrized IQuery query = s.CreateQuery("from Customer c where c.Name = :customerName"); query.SetParameter("customerName", "Somebody"); IList<Customer> customers = query.List<Customer> (); Assert.That(customers.Count, Is.EqualTo(1), "IFilter applied and Customer parametrized on Name also works"); } using (ISession s = OpenSession()) using (ITransaction tx = s.BeginTransaction()) { s.Delete("from Customer"); s.Delete("from Category"); tx.Commit(); } } |
| ||||
[Test] public void Incorrect_SQL_Translated_Params_Bug() { using (ISession s = OpenSession()) using (ITransaction tx = s.BeginTransaction()) { Customer c = new Customer("Somebody"); c.Category = new Category("User"); s.Save(c.Category); c.IsActive = true; c.Category.IsActive = true; s.Save(c); tx.Commit(); } using (ISession s = OpenSession()) { s.DisableFilter("onlyActive"); IFilter fltr = s.EnableFilter("onlyActive"); if (Dialect is PostgreSQLDialect) fltr.SetParameter("activeFlag", true); else fltr.SetParameter("activeFlag", 1); // related entity Customer.Category is parametrized IQuery query = s.CreateQuery("from Customer c where c.Category.Name = :catName"); query.SetParameter("catName", "User"); IList<Customer> customers = query.List<Customer> (); Assert.That(customers.Count, Is.EqualTo(1), "IFIlter applied and Customer parametrized on Category.Name DOES NOT work"); } using (ISession s = OpenSession()) using (ITransaction tx = s.BeginTransaction()) { s.Delete("from Customer"); s.Delete("from Category"); tx.Commit(); } } |
| |||
[Test] public void [[#variable52089b40]]() { using (ISession s = OpenSession()) using (ITransaction tx = s.BeginTransaction()) { Customer c = new Customer("Somebody"); c.Category = new Category("User"); s.Save(c.Category); c.IsActive = true; c.Category.IsActive = true; s.Save(c); tx.Commit(); } using (ISession s = OpenSession()) { s.DisableFilter("onlyActive"); IFilter fltr = s.EnableFilter("onlyActive"); if (Dialect is PostgreSQLDialect) fltr.SetParameter("activeFlag", true); else fltr.SetParameter("activeFlag", 1); // Customer is parametrized // related entity Customer.Category is parametrized IQuery query = s.CreateQuery( [[#variable52089a60]]); query.SetParameter( [[#variable52089a00]], [[#variable520899e0]]); IList<Customer> customers = query.List<Customer> (); Assert.That(customers.Count, Is.EqualTo(1), [[#variable52089960]]); } using (ISession s = OpenSession()) using (ITransaction tx = s.BeginTransaction()) { s.Delete("from Customer"); s.Delete("from Category"); tx.Commit(); } } |
CloneAbstraction |
Parameter Index | Clone Instance | Parameter Name | Value |
---|---|---|---|
1 | 1 | [[#52089b40]] | Also_Works_With_Filter |
1 | 2 | [[#52089b40]] | Incorrect_SQL_Translated_Params_Bug |
2 | 1 | [[#52089a60]] | "from Customer c where c.Name = :customerName" |
2 | 2 | [[#52089a60]] | "from Customer c where c.Category.Name = :catName" |
3 | 1 | [[#52089a00]] | "customerName" |
3 | 2 | [[#52089a00]] | "catName" |
4 | 1 | [[#520899e0]] | "Somebody" |
4 | 2 | [[#520899e0]] | "User" |
5 | 1 | [[#52089960]] | "IFilter applied and Customer parametrized on Name also works" |
5 | 2 | [[#52089960]] | "IFIlter applied and Customer parametrized on Category.Name DOES NOT work" |