Skip to content

Commit c1a2fac

Browse files
author
Tom Barrett
committed
*** empty log message ***
SVN: trunk@75
1 parent 9aa618a commit c1a2fac

File tree

8 files changed

+126
-125
lines changed

8 files changed

+126
-125
lines changed

src/NHibernate/Dialect/GenericDialect.cs

+1-1
Original file line numberDiff line numberDiff line change
@@ -13,7 +13,7 @@ public GenericDialect() : base() {
1313
Register( DbType.Int16, "SMALLINT" );
1414
Register( DbType.Int32, "INTEGER" );
1515
Register( DbType.Int64, "BIGINT" );
16-
Register( DbType.AnsiString, "VARCHAR($1)" );
16+
Register( DbType.String, "VARCHAR($1)" );
1717
Register( DbType.Single, "FLOAT" );
1818
Register( DbType.DateTime, "DATE" );
1919
Register( DbType.Time, "TIMESTAMP" );

src/NHibernate/Mapping/List.cs

+8-8
Original file line numberDiff line numberDiff line change
@@ -6,12 +6,12 @@ namespace NHibernate.Mapping {
66
/// <summary>
77
/// A list has a primary key consisting of the key columns + index column
88
/// </summary>
9-
//public class List : IndexedCollection {
10-
11-
// public List(PersistentClass owner) : base(owner) { }
12-
13-
//public PersistentCollectionType Type {
14-
// get { return TypeFactory.l
15-
16-
//}
9+
// public class List : IndexedCollection {
10+
//
11+
// public List(PersistentClass owner) : base(owner) { }
12+
//
13+
// public PersistentCollectionType Type {
14+
// get { return TypeFactory
15+
//
16+
// }
1717
}

src/NHibernate/NHibernate.cs

+3-3
Original file line numberDiff line numberDiff line change
@@ -190,9 +190,9 @@ public static IType Association(System.Type persistentClass) {
190190
/// </summary>
191191
/// <param name="userTypeClass">a class that implements UserType</param>
192192
/// <returns></returns>
193-
public static IType Custom(System.Type userTypeClass) {
194-
return new CustomType(userTypeClass);
195-
}
193+
//public static IType Custom(System.Type userTypeClass) {
194+
// return new CustomType(userTypeClass);
195+
//}
196196

197197
/* Needs HybernateProxyHelper and PersistentCollection implementation
198198
*

src/NHibernate/Type/ArrayType.cs

+47-10
Original file line numberDiff line numberDiff line change
@@ -1,17 +1,54 @@
11
using System;
22
using System.Data;
3+
using System.Collections;
4+
using NHibernate.Collection;
5+
using NHibernate.Engine;
36

47
namespace NHibernate.Type {
5-
/// <summary>
6-
/// Summary description for ArrayType.
7-
/// </summary>
8-
public class ArrayType
9-
{
10-
public ArrayType()
11-
{
12-
//
13-
// TODO: Add constructor logic here
14-
//
8+
9+
public class ArrayType : PersistentCollectionType {
10+
private System.Type elementClass;
11+
private System.Type arrayClass;
12+
13+
public ArrayType(string role, System.Type elementClass) : base(role) {
14+
this.elementClass = elementClass;
15+
arrayClass = Array.CreateInstance(elementClass,0).GetType();
16+
}
17+
18+
public override System.Type ReturnedClass {
19+
get { return arrayClass; }
20+
}
21+
22+
protected override PersistentCollection Instantiate(ISessionImplementor session, CollectionPersister persister) {
23+
return new ArrayHolder(session, persister);
24+
}
25+
26+
public override void NullSafeSet(IDbCommand st, object value, int index, ISessionImplementor session) {
27+
base.NullSafeSet(st, session.GetArrayHolder(value), index, session);
28+
}
29+
30+
public ICollection ElementsCollection(object collection) {
31+
return ((object[])collection);
32+
}
33+
34+
public override object Disassemble(object value, ISessionImplementor session) {
35+
if (value==null) return null;
36+
return session.GetLoadedCollectionKey( session.GetArrayHolder(value) );
37+
}
38+
39+
public override PersistentCollection Wrap(ISessionImplementor session, object array) {
40+
return new ArrayHolder(session, array);
41+
}
42+
43+
public override bool IsArrayType {
44+
get { return true; }
45+
}
46+
47+
public override PersistentCollection AssembleCachedCollection( ISessionImplementor session,
48+
CollectionPersister persister,
49+
object disassembled,
50+
object owner ) {
51+
return new ArrayHolder(session, persister, disassembled, owner);
1552
}
1653
}
1754
}

src/NHibernate/Type/ListType.cs

+21-3
Original file line numberDiff line numberDiff line change
@@ -1,16 +1,34 @@
11
using System;
2+
using System.Collections;
23
using NHibernate.Collection;
34
using NHibernate.Engine;
45

56
namespace NHibernate.Type {
67

7-
/*public class ListType : PersistentCollectionType {
8+
public class ListType : PersistentCollectionType {
89

910
public ListType(string role) : base(role) {
1011
}
1112

12-
protected PersistentCollection Instantiate(ISessionImplementor session, CollectionPersister persister) {
13+
protected override PersistentCollection Instantiate(ISessionImplementor session, CollectionPersister persister) {
1314
return new List(session);
1415
}
15-
}*/
16+
17+
public override System.Type ReturnedClass {
18+
get { return typeof(IList); }
19+
}
20+
21+
public override PersistentCollection Wrap(ISessionImplementor session, object collection) {
22+
return new List( session, (IList) collection );
23+
}
24+
25+
public override PersistentCollection AssembleCachedCollection(
26+
ISessionImplementor session,
27+
CollectionPersister persister,
28+
object disassembled,
29+
object owner) {
30+
31+
return new List(session, persister, disassembled, owner);
32+
}
33+
}
1634
}

src/NHibernate/Type/MapType.cs

+34-12
Original file line numberDiff line numberDiff line change
@@ -1,17 +1,39 @@
11
using System;
2+
using System.Data;
3+
using System.Collections;
4+
using NHibernate.Collection;
5+
using NHibernate.Engine;
26

3-
namespace NHibernate.Type
4-
{
5-
/// <summary>
6-
/// Summary description for MapType.
7-
/// </summary>
8-
public class MapType
9-
{
10-
public MapType()
11-
{
12-
//
13-
// TODO: Add constructor logic here
14-
//
7+
namespace NHibernate.Type {
8+
9+
public class MapType : PersistentCollectionType {
10+
11+
public MapType(string role) : base(role) {
12+
}
13+
14+
protected override PersistentCollection Instantiate(ISessionImplementor session, CollectionPersister persister) {
15+
return new Map(session);
16+
}
17+
18+
public override System.Type ReturnedClass {
19+
get { return typeof(IDictionary); }
20+
}
21+
22+
public ICollection ElementsCollection(object collection) {
23+
return ((IDictionary) collection).Values;
24+
}
25+
26+
public override PersistentCollection Wrap(ISessionImplementor session, object collection) {
27+
return new Map( session, (IDictionary) collection );
28+
}
29+
30+
public override PersistentCollection AssembleCachedCollection(
31+
ISessionImplementor session,
32+
CollectionPersister persister,
33+
object disassembled,
34+
object owner) {
35+
36+
return new Map(session, persister, disassembled, owner);
1537
}
1638
}
1739
}

src/NHibernate/Type/OneToOneType.cs

-80
Original file line numberDiff line numberDiff line change
@@ -63,83 +63,3 @@ public virtual bool IsNullable {
6363

6464
}
6565
}
66-
67-
/*
68-
//$Id$
69-
package net.sf.hibernate.type;
70-
71-
import java.io.Serializable;
72-
import java.sql.PreparedStatement;
73-
import java.sql.ResultSet;
74-
import java.sql.SQLException;
75-
76-
import net.sf.hibernate.HibernateException;
77-
import net.sf.hibernate.MappingException;
78-
import net.sf.hibernate.engine.Mapping;
79-
import net.sf.hibernate.engine.SessionImplementor;
80-
81-
82-
83-
public class OneToOneType extends EntityType implements AssociationType {
84-
85-
private static final int[] NO_INTS = new int[0];
86-
private final AssociationType.ForeignKeyType foreignKeyType;
87-
88-
public int getColumnSpan(Mapping session) throws MappingException {
89-
return 0;
90-
}
91-
92-
93-
public int[] sqlTypes(Mapping session) throws MappingException {
94-
return NO_INTS;
95-
}
96-
97-
public OneToOneType(Class persistentClass, AssociationType.ForeignKeyType foreignKeyType) {
98-
super(persistentClass);
99-
this.foreignKeyType = foreignKeyType;
100-
}
101-
102-
public void nullSafeSet(PreparedStatement st, Object value, int index, SessionImplementor session) throws HibernateException, SQLException {
103-
//nothing to do
104-
}
105-
106-
public boolean isOneToOne() {
107-
return true;
108-
}
109-
110-
111-
public boolean isDirty(Object old, Object current, SessionImplementor session) throws HibernateException {
112-
return false;
113-
}
114-
115-
public AssociationType.ForeignKeyType getForeignKeyType() {
116-
return foreignKeyType;
117-
}
118-
119-
public Object hydrate(
120-
ResultSet rs,
121-
String[] names,
122-
SessionImplementor session,
123-
Object owner
124-
) throws HibernateException, SQLException {
125-
126-
return session.getEntityIdentifier(owner);
127-
}
128-
129-
public Object resolveIdentifier(Object value, SessionImplementor session, Object owner) throws HibernateException, SQLException {
130-
131-
if (value==null) return null;
132-
133-
Class clazz = getPersistentClass();
134-
Serializable id = (Serializable) value;
135-
136-
return isNullable() ?
137-
session.internalLoadOneToOne(clazz, id) :
138-
session.internalLoad(clazz, id);
139-
}
140-
141-
public boolean isNullable() {
142-
return foreignKeyType==AssociationType.FOREIGN_KEY_TO_PARENT;
143-
}
144-
145-
}*/

src/NHibernate/Type/TypeFactory.cs

+12-8
Original file line numberDiff line numberDiff line change
@@ -124,13 +124,13 @@ public static IType HueristicType(string typeName) {
124124
throw new MappingException("Could not instantiate IType " + typeClass.Name + ": " + e);
125125
}
126126
}
127-
else if ( typeof(IUserType).IsAssignableFrom(typeClass) ) {
128-
type = NHibernate.Custom(typeClass);
129-
}
127+
//else if ( typeof(IUserType).IsAssignableFrom(typeClass) ) {
128+
// type = new CustomType(typeClass);
129+
//}
130130
else if ( typeof(ILifecycle).IsAssignableFrom(typeClass) ) {
131131
type = NHibernate.Association(typeClass);
132132
}
133-
else if ( typeClass.IsEnum ) {
133+
else if ( typeof(IPersistentEnum).IsAssignableFrom(typeClass) ) {
134134
type = NHibernate.Enum(typeClass);
135135
}
136136
else if ( typeClass.IsSerializable ) {
@@ -143,19 +143,23 @@ public static IType HueristicType(string typeName) {
143143

144144
// Collection Types:
145145

146-
/*
147-
public static PersistentCollectionType Array(string role, Class elementClass) {
148-
return new ArrayTyperole, elementClass);
146+
147+
public static PersistentCollectionType Array(string role, System.Type elementClass) {
148+
return new ArrayType(role, elementClass);
149149
}
150+
150151
public static PersistentCollectionType List(string role) {
151152
return new ListType(role);
152153
}
154+
/*
153155
public static PersistentCollectionType Bag(string role) {
154156
return new BagType(role);
155157
}
158+
*/
156159
public static PersistentCollectionType Map(string role) {
157160
return new MapType(role);
158161
}
162+
/*
159163
public static PersistentCollectionType Set(string role) {
160164
return new SetType(role);
161165
}
@@ -205,7 +209,7 @@ public static int[] FindDirty(IType[] types, object[] x, object[] y, bool[] chec
205209
}
206210
else {
207211
int[] trimmed = new int[count];
208-
Array.Copy(results, 0, trimmed, 0, count);
212+
System.Array.Copy(results, 0, trimmed, 0, count);
209213
return trimmed;
210214
}
211215
}

0 commit comments

Comments
 (0)