Previous CloneSet | Next CloneSet | Back to Main Report |
Clone Mass | Clones in CloneSet | Parameter Count | Clone Similarity | Syntax Category [Sequence Length] |
---|---|---|---|---|
35 | 2 | 6 | 0.974 | class_member_declaration |
Clone Abstraction | Parameter Bindings |
Clone Instance (Click to see clone) | Line Count | Source Line | Source File |
---|---|---|---|
1 | 35 | 92 | src/NHibernate.Test/NHSpecificTest/NH1098/FilterParameterOrderFixture.cs |
2 | 35 | 129 | src/NHibernate.Test/NHSpecificTest/NH1098/FilterParameterOrderFixture.cs |
| ||||
[Test] public void QueryWithNamedParameters() { ISession session = OpenSession(); session.EnableFilter("EnabledObjects").SetParameter("Enabled", true); var sql = new StringBuilder(); sql.Append("from A as a where a.ValueA < :ValA"); sql.Append(" and exists (select b.ValueB from B as b where "); sql.Append(" a.ValueA < b.ValueB and b.ValueB > :ValB)"); IQuery query = session.CreateQuery(sql.ToString()); query.SetParameter("ValA", 6); query.SetParameter("ValB", 5); // // Query: // {select a0_.id as id0_, a0_.val_a as val2_0_, a0_.enabled as enabled0_ // from table_a a0_ // where a0_.enabled = ? and ((a0_.val_a<? )and // (exists(select b1_.val_b // from table_b b1_ // where b1_.enabled = ? and ((a0_.val_a<b1_.val_b )and(b1_.val_b>? )))))} // // Parameter: // 1) "this_.enabled = :EnabledObjects.Enabled" [filter #1] // 2) "this_.val_a < (?)" [named parameter #1] // 3) "this_0_.enabled = :EnabledObjects.Enabled" [filter #2] // 4) "this_0_.val_b > (?)" [named parameter #2] // // => ERROR, parameters are in wrong order: filter #1, filter #2, named #1, named #2 // IList<A> result = query.List<A> (); Assert.AreEqual(1, result.Count); } |
| ||||
[Test] public void QueryWithPositionalParameter() { ISession session = OpenSession(); session.EnableFilter("EnabledObjects").SetParameter("Enabled", true); var sql = new StringBuilder(); sql.Append("from A as a where a.ValueA < ?"); sql.Append(" and exists (select b.ValueB from B as b where "); sql.Append(" a.ValueA < b.ValueB and b.ValueB > ?)"); IQuery query = session.CreateQuery(sql.ToString()); query.SetInt32(0, 6); query.SetInt32(1, 5); // // Query: // {select a0_.id as id0_, a0_.val_a as val2_0_, a0_.enabled as enabled0_ // from table_a a0_ // where a0_.enabled = ? and ((a0_.val_a<? )and // (exists(select b1_.val_b // from table_b b1_ // where b1_.enabled = ? and ((a0_.val_a<b1_.val_b )and(b1_.val_b>? )))))} // // Parameter: // 1) "this_.enabled = :EnabledObjects.Enabled" [filter #1] // 2) "this_.val_a < (?)" [positional parameter #1] // 3) "this_0_.enabled = :EnabledObjects.Enabled" [filter #2] // 4) "this_0_.val_b > (?)" [positional parameter #2] // // => OK, parameters are in correct order: filter #1, pos 12, filter #2, pos #2 // IList<A> result = query.List<A> (); Assert.AreEqual(1, result.Count); } |
| |||
[Test] public void [[#variable6b72b5c0]]() { ISession session = OpenSession(); session.EnableFilter("EnabledObjects").SetParameter("Enabled", true); var sql = new StringBuilder(); sql.Append( [[#variable6b72b560]]); sql.Append(" and exists (select b.ValueB from B as b where "); sql.Append( [[#variable6b72b500]]); IQuery query = session.CreateQuery(sql.ToString()); query. [[#variable6c563e60]]( [[#variable68a20120]], 6); query. [[#variable6c563e60]]( [[#variable6b72b360]], 5); // // Query: // {select a0_.id as id0_, a0_.val_a as val2_0_, a0_.enabled as enabled0_ // from table_a a0_ // where a0_.enabled = ? and ((a0_.val_a<? )and // (exists(select b1_.val_b // from table_b b1_ // where b1_.enabled = ? and ((a0_.val_a<b1_.val_b )and(b1_.val_b>? )))))} // from table_b b1_ // where b1_.enabled = ? and ((a0_.val_a<b1_.val_b )and(b1_.val_b>? )))))} // // Parameter: // 1) "this_.enabled = :EnabledObjects.Enabled" [filter #1] // 2) "this_.val_a < (?)" [positional parameter #1] // 2) "this_.val_a < (?)" [named parameter #1] // 3) "this_0_.enabled = :EnabledObjects.Enabled" [filter #2] // 4) "this_0_.val_b > (?)" [positional parameter #2] // 4) "this_0_.val_b > (?)" [named parameter #2] // // => OK, parameters are in correct order: filter #1, pos 12, filter #2, pos #2 // => ERROR, parameters are in wrong order: filter #1, filter #2, named #1, named #2 // IList<A> result = query.List<A> (); Assert.AreEqual(1, result.Count); } |
CloneAbstraction |
Parameter Index | Clone Instance | Parameter Name | Value |
---|---|---|---|
1 | 1 | [[#6b72b5c0]] | QueryWithPositionalParameter |
1 | 2 | [[#6b72b5c0]] | QueryWithNamedParameters |
2 | 1 | [[#6b72b560]] | "from A as a where a.ValueA < ?" |
2 | 2 | [[#6b72b560]] | "from A as a where a.ValueA < :ValA" |
3 | 1 | [[#6b72b500]] | " a.ValueA < b.ValueB and b.ValueB > ?)" |
3 | 2 | [[#6b72b500]] | " a.ValueA < b.ValueB and b.ValueB > :ValB)" |
4 | 1 | [[#6c563e60]] | SetInt32 |
4 | 2 | [[#6c563e60]] | SetParameter |
5 | 1 | [[#68a20120]] | 0 |
5 | 2 | [[#68a20120]] | "ValA" |
6 | 1 | [[#6b72b360]] | 1 |
6 | 2 | [[#6b72b360]] | "ValB" |