Skip to content

Commit deebee0

Browse files
author
Mike Doerfler
committed
Renamed NHibernate.NHibernate to NHibernate.NHibernateUtil.
SVN: trunk@1219
1 parent 2575a23 commit deebee0

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

55 files changed

+377
-315
lines changed

src/NHibernate.DomainModel/Baz.cs

+2-1
Original file line numberDiff line numberDiff line change
@@ -556,7 +556,8 @@ public void SetDefaults()
556556
StringDateMap = new SortedList();
557557
StringDateMap.Add( "now", DateTime.Now );
558558
StringDateMap.Add( "never", null );
559-
StringDateMap.Add( "big bang", new DateTime(0) );
559+
StringDateMap.Add( "millenium", new DateTime( 2000, 01, 01 ) );
560+
//StringDateMap.Add( "big bang", new DateTime(0) );
560561
ArrayList list = new ArrayList();
561562
list.AddRange( StringSet );
562563
StringList = list;

src/NHibernate.DomainModel/CustomPersister.cs

+2-2
Original file line numberDiff line numberDiff line change
@@ -21,7 +21,7 @@ public class CustomPersister : IClassPersister
2121
private static readonly Hashtable Instances = new Hashtable();
2222
private static readonly IIdentifierGenerator Generator = new CounterGenerator();
2323

24-
private static readonly IType[] Types = new IType[] { NHibernate.String };
24+
private static readonly IType[] Types = new IType[] { NHibernateUtil.String };
2525
private static readonly string[] Names = new string[] { "name" };
2626
private static readonly bool[] Mutability = new bool[] { true };
2727

@@ -199,7 +199,7 @@ public int VersionProperty
199199

200200
public IType IdentifierType
201201
{
202-
get { return NHibernate.Int64; }
202+
get { return NHibernateUtil.Int64; }
203203
}
204204

205205
public System.Reflection.PropertyInfo ProxyIdentifierProperty

src/NHibernate.DomainModel/DoubleStringType.cs

+5-5
Original file line numberDiff line numberDiff line change
@@ -42,8 +42,8 @@ public bool IsMutable
4242
public Object NullSafeGet(IDataReader rs, String[] names, Engine.ISessionImplementor session, Object owner)
4343
{
4444

45-
String first = (String) NHibernate.String.NullSafeGet(rs, names[0], session, owner);
46-
String second = (String) NHibernate.String.NullSafeGet(rs, names[1], session, owner);
45+
String first = (String) NHibernateUtil.String.NullSafeGet(rs, names[0], session, owner);
46+
String second = (String) NHibernateUtil.String.NullSafeGet(rs, names[1], session, owner);
4747

4848
return ( first==null && second==null ) ? null : new String[] { first, second };
4949
}
@@ -53,8 +53,8 @@ public void NullSafeSet(IDbCommand st, Object value, int index, Engine.ISessionI
5353
{
5454
String[] strings = (value==null) ? new String[2] : (String[]) value;
5555

56-
NHibernate.String.NullSafeSet(st, strings[0], index, session);
57-
NHibernate.String.NullSafeSet(st, strings[1], index+1, session);
56+
NHibernateUtil.String.NullSafeSet(st, strings[0], index, session);
57+
NHibernateUtil.String.NullSafeSet(st, strings[1], index+1, session);
5858
}
5959

6060
public String[] PropertyNames
@@ -69,7 +69,7 @@ public Type.IType[] PropertyTypes
6969
{
7070
get
7171
{
72-
return new Type.IType[] { NHibernate.String, NHibernate.String };
72+
return new Type.IType[] { NHibernateUtil.String, NHibernateUtil.String };
7373
}
7474
}
7575

src/NHibernate.DomainModel/MultiplicityType.cs

+5-5
Original file line numberDiff line numberDiff line change
@@ -9,7 +9,7 @@ public class MultiplicityType : ICompositeUserType
99
"count", "glarch"
1010
};
1111
private static readonly Type.IType[] TYPES = new Type.IType[] {
12-
NHibernate.Int32, NHibernate.Entity(typeof(Glarch))
12+
NHibernateUtil.Int32, NHibernateUtil.Entity(typeof(Glarch))
1313
};
1414
public String[] PropertyNames
1515
{
@@ -55,8 +55,8 @@ public System.Type ReturnedClass
5555

5656
public object NullSafeGet(IDataReader rs, String[] names, Engine.ISessionImplementor session, Object owner)
5757
{
58-
int c = (int) NHibernate.Int32.NullSafeGet( rs, names[0], session, owner);
59-
GlarchProxy g = (GlarchProxy) NHibernate.Entity(typeof(Glarch)).NullSafeGet(rs, names[1], session, owner);
58+
int c = (int) NHibernateUtil.Int32.NullSafeGet( rs, names[0], session, owner);
59+
GlarchProxy g = (GlarchProxy) NHibernateUtil.Entity(typeof(Glarch)).NullSafeGet(rs, names[1], session, owner);
6060
Multiplicity m = new Multiplicity();
6161
m.count = ( c==0 ? 0 : c );
6262
m.glarch = g;
@@ -78,8 +78,8 @@ public void NullSafeSet(IDbCommand st, Object value, int index, Engine.ISessionI
7878
g = o.glarch;
7979
c = o.count;
8080
}
81-
NHibernate.Int32.NullSafeSet(st, c, index, session);
82-
NHibernate.Entity(typeof(Glarch)).NullSafeSet(st, g, index+1, session);
81+
NHibernateUtil.Int32.NullSafeSet(st, c, index, session);
82+
NHibernateUtil.Entity(typeof(Glarch)).NullSafeSet(st, g, index+1, session);
8383

8484
}
8585

src/NHibernate.DomainModel/NHSpecific/NullInt32UserType.cs

+1-1
Original file line numberDiff line numberDiff line change
@@ -12,7 +12,7 @@ namespace NHibernate.DomainModel.NHSpecific
1212
/// </summary>
1313
public class NullInt32UserType : IUserType
1414
{
15-
private static NullableType _int32Type = NHibernate.Int32;
15+
private static NullableType _int32Type = NHibernateUtil.Int32;
1616

1717
public NullInt32UserType()
1818
{

src/NHibernate.Test/ABCProxyTest.cs

+1-1
Original file line numberDiff line numberDiff line change
@@ -64,7 +64,7 @@ public void Subclassing()
6464
t = s.BeginTransaction();
6565
// Test won't run after this line because of proxy initalization problems
6666
A c1a = (A) s.Load(typeof(A), c1.Id );
67-
Assert.IsFalse( NHibernate.IsInitialized(c1a) );
67+
Assert.IsFalse( NHibernateUtil.IsInitialized(c1a) );
6868
Assert.IsTrue( c1a.Name.Equals("c1") );
6969
t.Commit();
7070
s.Close();

src/NHibernate.Test/ExpressionTest/JunctionFixture.cs

+2-2
Original file line numberDiff line numberDiff line change
@@ -50,8 +50,8 @@ public void GetTypedValues()
5050
TypedValue[] typedValues = _conjunction.GetTypedValues( factoryImpl, typeof(Simple) );
5151

5252
TypedValue[] expectedTV = new TypedValue[2];
53-
expectedTV[0] = new TypedValue(NHibernate.Int32, 5);
54-
expectedTV[1] = new TypedValue(NHibernate.Int32, 10);
53+
expectedTV[0] = new TypedValue(NHibernateUtil.Int32, 5);
54+
expectedTV[1] = new TypedValue(NHibernateUtil.Int32, 10);
5555

5656
Assert.AreEqual(2, typedValues.Length);
5757

src/NHibernate.Test/ExpressionTest/SQLExpressionFixture.cs

+1-1
Original file line numberDiff line numberDiff line change
@@ -64,7 +64,7 @@ public void WithParameterTest()
6464
builder.Add( "$alias.address = " );
6565
builder.Add( firstAndParam );
6666

67-
NExpression.Expression sqlExpression = NExpression.Expression.Sql(builder.ToSqlString(), "some address", NHibernate.String );
67+
NExpression.Expression sqlExpression = NExpression.Expression.Sql(builder.ToSqlString(), "some address", NHibernateUtil.String );
6868

6969
SqlString sqlString = sqlExpression.ToSqlString(factoryImpl, typeof(Simple), "simple_alias");
7070

src/NHibernate.Test/FooBarTest.cs

+90-30
Original file line numberDiff line numberDiff line change
@@ -56,17 +56,17 @@ public void FetchInitializedCollection()
5656
s.Save(baz);
5757
fooBag = baz.FooBag;
5858
s.Find("from Baz baz left join fetch baz.FooBag");
59-
Assert.IsTrue( NHibernate.IsInitialized(fooBag) );
59+
Assert.IsTrue( NHibernateUtil.IsInitialized(fooBag) );
6060
Assert.IsTrue( fooBag==baz.FooBag );
6161
Assert.IsTrue( baz.FooBag.Count==2 );
6262
s.Close();
6363

6464
s = sessions.OpenSession();
6565
baz = (Baz) s.Load( typeof(Baz), baz.Code );
6666
Object bag = baz.FooBag;
67-
Assert.IsFalse( NHibernate.IsInitialized(bag) );
67+
Assert.IsFalse( NHibernateUtil.IsInitialized(bag) );
6868
s.Find("from Baz baz left join fetch fooBag");
69-
Assert.IsFalse( NHibernate.IsInitialized(bag) );
69+
Assert.IsFalse( NHibernateUtil.IsInitialized(bag) );
7070
Assert.IsTrue( bag==baz.FooBag );
7171
Assert.IsTrue( baz.FooBag.Count==2 );
7272
s.Delete(baz);
@@ -166,7 +166,7 @@ public void FetchList()
166166
}
167167
baz.Fees = list;
168168
list = s.Find("from Foo foo, Baz baz left join fetch baz.Fees");
169-
Assert.IsTrue( NHibernate.IsInitialized( ( (Baz) ( (object[]) list[0] )[1] ).Fees ) );
169+
Assert.IsTrue( NHibernateUtil.IsInitialized( ( (Baz) ( (object[]) list[0] )[1] ).Fees ) );
170170
s.Delete(foo);
171171
s.Delete(foo2);
172172
s.Delete(baz);
@@ -274,10 +274,10 @@ public void ManyToManyBag()
274274

275275
s = sessions.OpenSession();
276276
baz = (Baz)s.Load( typeof(Baz), id );
277-
Assert.IsFalse( NHibernate.IsInitialized( baz.FooBag ) );
277+
Assert.IsFalse( NHibernateUtil.IsInitialized( baz.FooBag ) );
278278
Assert.AreEqual( 1, baz.FooBag.Count );
279279

280-
Assert.IsTrue( NHibernate.IsInitialized( baz.FooBag[0] ) );
280+
Assert.IsTrue( NHibernateUtil.IsInitialized( baz.FooBag[0] ) );
281281
s.Delete(baz);
282282
s.Flush();
283283
s.Close();
@@ -371,9 +371,9 @@ public void ForceOuterJoin()
371371

372372
s = sessions.OpenSession();
373373
f = (FooProxy)s.Load( typeof(Foo), id );
374-
Assert.IsFalse( NHibernate.IsInitialized( f ) );
375-
Assert.IsTrue( NHibernate.IsInitialized( f.Component.Glarch ) ); //outer-join="true"
376-
Assert.IsFalse( NHibernate.IsInitialized( f.TheFoo ) ); //outer-join="auto"
374+
Assert.IsFalse( NHibernateUtil.IsInitialized( f ) );
375+
Assert.IsTrue( NHibernateUtil.IsInitialized( f.Component.Glarch ) ); //outer-join="true"
376+
Assert.IsFalse( NHibernateUtil.IsInitialized( f.TheFoo ) ); //outer-join="auto"
377377
Assert.AreEqual( gid, s.GetIdentifier( f.Component.Glarch ) );
378378
s.Delete( f );
379379
s.Delete( f.TheFoo );
@@ -695,7 +695,7 @@ public void FindByCriteria()
695695
.List();
696696

697697
f = (Foo) list[0];
698-
Assert.IsTrue(NHibernate.IsInitialized(f.TheFoo));
698+
Assert.IsTrue(NHibernateUtil.IsInitialized(f.TheFoo));
699699

700700
//TODO: this is initialized because Proxies are not implemented yet.
701701
//Assert.IsFalse( NHibernate.IsInitialized(f.component.Glarch) );
@@ -846,10 +846,10 @@ public void AssociationId()
846846
object[] values = new object[] {bar, (long)1234, 12, "id" };
847847
Type.IType[] types = new Type.IType[]
848848
{
849-
NHibernate.Entity(typeof(Foo)),
850-
NHibernate.Int64,
851-
NHibernate.Int32,
852-
NHibernate.String
849+
NHibernateUtil.Entity(typeof(Foo)),
850+
NHibernateUtil.Int64,
851+
NHibernateUtil.Int32,
852+
NHibernateUtil.String
853853
};
854854

855855

@@ -860,9 +860,9 @@ public void AssociationId()
860860
values = new object[] {bar, (long)1234, "More Stuff"};
861861
types = new Type.IType[]
862862
{
863-
NHibernate.Entity(typeof(Foo)),
864-
NHibernate.Int64,
865-
NHibernate.String
863+
NHibernateUtil.Entity(typeof(Foo)),
864+
NHibernateUtil.Int64,
865+
NHibernateUtil.String
866866
};
867867

868868
results = s.Find(hqlString, values, types);
@@ -1542,9 +1542,9 @@ public void Load()
15421542
q = (Qux)s.Load( typeof(Qux), q.Key );
15431543
b = (BarProxy)s.Load( typeof(Foo), b.Key );
15441544
string tempKey = b.Key;
1545-
Assert.IsFalse( NHibernate.IsInitialized(b), "b should have been an unitialized Proxy" );
1545+
Assert.IsFalse( NHibernateUtil.IsInitialized(b), "b should have been an unitialized Proxy" );
15461546
string tempString = b.BarString;
1547-
Assert.IsTrue( NHibernate.IsInitialized(b), "b should have been an initialized Proxy" );
1547+
Assert.IsTrue( NHibernateUtil.IsInitialized(b), "b should have been an initialized Proxy" );
15481548
BarProxy b2 = (BarProxy)s.Load( typeof(Bar), tempKey );
15491549
Qux q2 = (Qux)s.Load( typeof(Qux), q.Key );
15501550
Assert.AreSame( q, q2, "loaded same Qux" );
@@ -1740,7 +1740,7 @@ public void Find()
17401740
Assert.AreEqual( 1, s.Find( "from t in class NHibernate.DomainModel.Trivial").Count );
17411741
s.Delete( "from t in class NHibernate.DomainModel.Trivial" );
17421742

1743-
list2 = s.Find( "from foo in class NHibernate.DomainModel.Foo where foo.Date = ?", new DateTime(2123,2,3), NHibernate.Date );
1743+
list2 = s.Find( "from foo in class NHibernate.DomainModel.Foo where foo.Date = ?", new DateTime(1970, 01, 01), NHibernateUtil.Date );
17441744
Assert.AreEqual( 4, list2.Count, "find by date" );
17451745
IEnumerator enumer = list2.GetEnumerator();
17461746
while( enumer.MoveNext() )
@@ -1767,13 +1767,13 @@ public void Query()
17671767

17681768
IList list = s.Find( "from Foo foo inner join fetch foo.TheFoo" );
17691769
Foo foof = (Foo)list[0];
1770-
Assert.IsTrue( NHibernate.IsInitialized( foof.TheFoo ) );
1770+
Assert.IsTrue( NHibernateUtil.IsInitialized( foof.TheFoo ) );
17711771

17721772
list = s.Find( "from Baz baz left outer join fetch baz.FooToGlarch" );
17731773

17741774
list = s.Find( "select foo, bar from Foo foo left outer join foo.TheFoo bar where foo = ?",
17751775
foo,
1776-
NHibernate.Entity( typeof(Foo) )
1776+
NHibernateUtil.Entity( typeof(Foo) )
17771777
);
17781778

17791779
object[] row1 = (object[])list[0];
@@ -1837,7 +1837,7 @@ public void Query()
18371837
if( !(dialect is Dialect.MySQLDialect) )
18381838
{
18391839
// add an !InterbaseDialect wrapper around list and assert
1840-
list = s.Find( "from foo in class NHibernate.DomainModel.Foo where ? = some foo.Component.ImportantDates.elements", new DateTime( DateTime.Now.Year, DateTime.Now.Month, DateTime.Now.Day ), NHibernate.DateTime );
1840+
list = s.Find( "from foo in class NHibernate.DomainModel.Foo where ? = some foo.Component.ImportantDates.elements", new DateTime( DateTime.Now.Year, DateTime.Now.Month, DateTime.Now.Day ), NHibernateUtil.DateTime );
18411841
Assert.AreEqual( 2, list.Count, "componenet query" );
18421842
}
18431843

@@ -2061,7 +2061,7 @@ public void Enumerable()
20612061
s = sessions.OpenSession();
20622062

20632063
Assert.AreEqual(8,
2064-
s.Delete("from q in class NHibernate.DomainModel.Qux where q.Stuff=?", "foo", NHibernate.String),
2064+
s.Delete("from q in class NHibernate.DomainModel.Qux where q.Stuff=?", "foo", NHibernateUtil.String),
20652065
"delete by query");
20662066

20672067
s.Flush();
@@ -2076,6 +2076,66 @@ public void Enumerable()
20762076

20772077
}
20782078

2079+
/// <summary>
2080+
/// Adding a test to verify that a database action can occur in the
2081+
/// middle of an Enumeration. Under certain conditions an open
2082+
/// DataReader can be kept open and cause anyother action to fail.
2083+
/// </summary>
2084+
[Test]
2085+
public void EnumerableDisposable()
2086+
{
2087+
// this test used to be called Iterators()
2088+
2089+
ISession s = sessions.OpenSession();
2090+
for( int i=0; i<10; i++ )
2091+
{
2092+
Simple simple = new Simple();
2093+
simple.Count = i;
2094+
s.Save(simple, i);
2095+
Assert.IsNotNull(simple, "simple is not null");
2096+
}
2097+
s.Flush();
2098+
s.Close();
2099+
2100+
s = sessions.OpenSession();
2101+
ITransaction t = s.BeginTransaction();
2102+
Simple simp = (Simple)s.Load( typeof(Simple), 8 );
2103+
2104+
// the reader under the enum has to still be a SqlDataReader (subst db name here) and
2105+
// can't be a NDataReader - the best way to get this result is to query on just a property
2106+
// of an object. If the query is "from Simple as s" then it will be converted to a NDataReader
2107+
// on the MoveNext so it can get the object from the id - thus needing another open DataReader so
2108+
// it must convert to an NDataReader.
2109+
IEnumerable enumer = s.Enumerable("select s.Count from Simple as s");
2110+
//int count = 0;
2111+
foreach( object obj in enumer )
2112+
{
2113+
if( (int)obj==7 )
2114+
{
2115+
break;
2116+
}
2117+
}
2118+
2119+
// if Enumerable doesn't implement Dispose() then the test fails on this line
2120+
t.Commit();
2121+
s.Close();
2122+
2123+
s = sessions.OpenSession();
2124+
Assert.AreEqual( 10,
2125+
s.Delete( "from Simple" ),
2126+
"delete by query" );
2127+
2128+
s.Flush();
2129+
s.Close();
2130+
2131+
s = sessions.OpenSession();
2132+
enumer = s.Enumerable("from Simple");
2133+
Assert.IsFalse( enumer.GetEnumerator().MoveNext() , "no items in enumerator" );
2134+
s.Flush();
2135+
s.Close();
2136+
2137+
}
2138+
20792139
[Test]
20802140
public void Versioning()
20812141
{
@@ -2095,8 +2155,8 @@ public void Versioning()
20952155
ISession sOld = sessions.OpenSession();
20962156
GlarchProxy gOld = (GlarchProxy)sOld.Load( typeof(Glarch), gid );
20972157
// want gOld to be initialized so later I can change a property
2098-
NHibernate.Initialize( gOld );
2099-
Assert.IsTrue( NHibernate.IsInitialized( gOld ), "should be initialized" );
2158+
NHibernateUtil.Initialize( gOld );
2159+
Assert.IsTrue( NHibernateUtil.IsInitialized( gOld ), "should be initialized" );
21002160
sOld.Close();
21012161

21022162
s = sessions.OpenSession();
@@ -3001,7 +3061,7 @@ public void Cache()
30013061
s = sessions.OpenSession();
30023062
s.Load( im, im.Id);
30033063

3004-
Immutable imFromFind = (Immutable)s.Find("from im in class Immutable where im = ?", im, NHibernate.Entity(typeof(Immutable)))[0];
3064+
Immutable imFromFind = (Immutable)s.Find("from im in class Immutable where im = ?", im, NHibernateUtil.Entity(typeof(Immutable)))[0];
30053065
Immutable imFromLoad = (Immutable)s.Load(typeof(Immutable), im.Id);
30063066

30073067
Assert.IsTrue(im==imFromFind, "cached object identity from Find ");
@@ -3187,7 +3247,7 @@ public void AutoFlushCollections()
31873247
baz.FooArray[0] = null;
31883248
e = s.Enumerable("from baz in class NHibernate.DomainModel.Baz where ? in baz.FooArray.elements",
31893249
foo,
3190-
NHibernate.Entity( typeof(Foo) ) ).GetEnumerator();
3250+
NHibernateUtil.Entity( typeof(Foo) ) ).GetEnumerator();
31913251

31923252
Assert.IsFalse( e.MoveNext() );
31933253
baz.FooArray[0] = foo;
@@ -3340,7 +3400,7 @@ public void Any()
33403400
IList list = s.Find(
33413401
"from Bar bar where bar.Object.id = ? and bar.Object.class = ?",
33423402
new object[] { oid, typeof(One) },
3343-
new Type.IType[] { NHibernate.Int64, NHibernate.Class } );
3403+
new Type.IType[] { NHibernateUtil.Int64, NHibernateUtil.Class } );
33443404
Assert.AreEqual(1, list.Count);
33453405

33463406
// this is a little different from h2.0.3 because the full type is stored, not
@@ -3611,7 +3671,7 @@ public void Formula()
36113671
s.Close();
36123672

36133673
s = sessions.OpenSession();
3614-
foo = (Foo)s.Find( "from Foo as f where f.id = ?", id, NHibernate.String)[0];
3674+
foo = (Foo)s.Find( "from Foo as f where f.id = ?", id, NHibernateUtil.String)[0];
36153675
Assert.AreEqual( 4, foo.Formula, "should be 2x 'Int' property that is defaulted to 2" );
36163676

36173677
s.Delete( foo );

0 commit comments

Comments
 (0)