You can subscribe to this list here.
2004 |
Jan
|
Feb
|
Mar
|
Apr
(248) |
May
(82) |
Jun
(90) |
Jul
(177) |
Aug
(253) |
Sep
(157) |
Oct
(151) |
Nov
(143) |
Dec
(278) |
---|---|---|---|---|---|---|---|---|---|---|---|---|
2005 |
Jan
(152) |
Feb
(107) |
Mar
(177) |
Apr
(133) |
May
(259) |
Jun
(81) |
Jul
(119) |
Aug
(306) |
Sep
(416) |
Oct
(240) |
Nov
(329) |
Dec
(206) |
2006 |
Jan
(466) |
Feb
(382) |
Mar
(153) |
Apr
(162) |
May
(133) |
Jun
(21) |
Jul
(18) |
Aug
(37) |
Sep
(97) |
Oct
(114) |
Nov
(110) |
Dec
(28) |
2007 |
Jan
(74) |
Feb
(65) |
Mar
(49) |
Apr
(76) |
May
(43) |
Jun
(15) |
Jul
(68) |
Aug
(55) |
Sep
(63) |
Oct
(59) |
Nov
(70) |
Dec
(66) |
2008 |
Jan
(71) |
Feb
(60) |
Mar
(120) |
Apr
(31) |
May
(48) |
Jun
(81) |
Jul
(107) |
Aug
(51) |
Sep
(80) |
Oct
(83) |
Nov
(83) |
Dec
(79) |
2009 |
Jan
(83) |
Feb
(110) |
Mar
(97) |
Apr
(91) |
May
(291) |
Jun
(250) |
Jul
(197) |
Aug
(58) |
Sep
(54) |
Oct
(122) |
Nov
(68) |
Dec
(34) |
2010 |
Jan
(50) |
Feb
(17) |
Mar
(63) |
Apr
(61) |
May
(84) |
Jun
(81) |
Jul
(138) |
Aug
(144) |
Sep
(78) |
Oct
(26) |
Nov
(30) |
Dec
(61) |
2011 |
Jan
(33) |
Feb
(35) |
Mar
(166) |
Apr
(221) |
May
(109) |
Jun
(76) |
Jul
(27) |
Aug
(37) |
Sep
(1) |
Oct
(4) |
Nov
(2) |
Dec
(1) |
2012 |
Jan
|
Feb
|
Mar
(2) |
Apr
(2) |
May
|
Jun
|
Jul
(1) |
Aug
|
Sep
(1) |
Oct
|
Nov
(1) |
Dec
|
2013 |
Jan
|
Feb
(1) |
Mar
|
Apr
|
May
|
Jun
|
Jul
(1) |
Aug
(1) |
Sep
(3) |
Oct
(2) |
Nov
|
Dec
(1) |
2014 |
Jan
(1) |
Feb
(1) |
Mar
(3) |
Apr
|
May
|
Jun
|
Jul
|
Aug
|
Sep
|
Oct
|
Nov
|
Dec
|
From: Paul H. <pha...@us...> - 2005-03-06 12:45:01
|
Update of /cvsroot/nhibernate/nhibernate/src/NHibernate/Proxy In directory sc8-pr-cvs1.sourceforge.net:/tmp/cvs-serv21577/nhibernate/src/NHibernate/Proxy Modified Files: LazyInitializer.cs Log Message: Refactored SessionImpl as per 2.1 for Save/Update Index: LazyInitializer.cs =================================================================== RCS file: /cvsroot/nhibernate/nhibernate/src/NHibernate/Proxy/LazyInitializer.cs,v retrieving revision 1.5 retrieving revision 1.6 diff -C2 -d -r1.5 -r1.6 *** LazyInitializer.cs 31 Dec 2004 22:08:25 -0000 1.5 --- LazyInitializer.cs 6 Mar 2005 12:44:46 -0000 1.6 *************** *** 119,122 **** --- 119,123 ---- { get { return _id; } + set { _id = value; } } |
From: Paul H. <pha...@us...> - 2005-03-06 12:44:59
|
Update of /cvsroot/nhibernate/nhibernate/src/NHibernate/Persister In directory sc8-pr-cvs1.sourceforge.net:/tmp/cvs-serv21577/nhibernate/src/NHibernate/Persister Modified Files: AbstractEntityPersister.cs IClassPersister.cs Log Message: Refactored SessionImpl as per 2.1 for Save/Update Index: IClassPersister.cs =================================================================== RCS file: /cvsroot/nhibernate/nhibernate/src/NHibernate/Persister/IClassPersister.cs,v retrieving revision 1.9 retrieving revision 1.10 diff -C2 -d -r1.9 -r1.10 *** IClassPersister.cs 1 Mar 2005 16:24:49 -0000 1.9 --- IClassPersister.cs 6 Mar 2005 12:44:45 -0000 1.10 *************** *** 296,299 **** --- 296,304 ---- /// <summary> + /// Get the nullability of the properties of this class + /// </summary> + bool[ ] PropertyNullability { get; } + + /// <summary> /// Gets if the Property is insertable. /// </summary> *************** *** 335,339 **** IClassMetadata ClassMetadata { get; } ! /* Hibernate 2.1 features - not sure if we need for SQL loading /// <summary> --- 340,349 ---- IClassMetadata ClassMetadata { get; } ! /// <summary> ! /// Is batch loading enabled? ! /// </summary> ! bool IsBatchLoadable { get; } ! ! /* TODO : 2.1 features - not sure if we need for SQL loading /// <summary> Index: AbstractEntityPersister.cs =================================================================== RCS file: /cvsroot/nhibernate/nhibernate/src/NHibernate/Persister/AbstractEntityPersister.cs,v retrieving revision 1.33 retrieving revision 1.34 diff -C2 -d -r1.33 -r1.34 *** AbstractEntityPersister.cs 1 Mar 2005 16:24:49 -0000 1.33 --- AbstractEntityPersister.cs 6 Mar 2005 12:44:45 -0000 1.34 *************** *** 144,147 **** --- 144,155 ---- } + /// <summary> + /// + /// </summary> + public bool IsBatchLoadable + { + get { return batchSize > 1; } + } + /// <summary></summary> public string Name *************** *** 1137,1140 **** --- 1145,1154 ---- /// <summary></summary> + public virtual bool[ ] PropertyNullability + { + get { return propertyNullability; } + } + + /// <summary></summary> protected virtual bool UseDynamicUpdate { *************** *** 1287,1291 **** uniqueKeyType = factory.GetPersister( clazz ).IdentifierType; } ! // TODO: Change EntityLoader to handle this //uniqueKeyLoaders.Add( propertyNames[ i ], new EntityLoader( this, columns, uniqueKeyType, factory ) ); //uniqueKeyLoaders.Add( propertyNames[ i ], new EntityLoader( this, columns, uniqueKeyType, factory ) ); --- 1301,1305 ---- uniqueKeyType = factory.GetPersister( clazz ).IdentifierType; } ! // TODO: 2.1 - Change EntityLoader to handle this //uniqueKeyLoaders.Add( propertyNames[ i ], new EntityLoader( this, columns, uniqueKeyType, factory ) ); //uniqueKeyLoaders.Add( propertyNames[ i ], new EntityLoader( this, columns, uniqueKeyType, factory ) ); |
From: Paul H. <pha...@us...> - 2005-03-06 12:44:59
|
Update of /cvsroot/nhibernate/nhibernate/src/NHibernate/Mapping In directory sc8-pr-cvs1.sourceforge.net:/tmp/cvs-serv21577/nhibernate/src/NHibernate/Mapping Modified Files: NamedSQLQuery.cs PersistentClass.cs Log Message: Refactored SessionImpl as per 2.1 for Save/Update Index: PersistentClass.cs =================================================================== RCS file: /cvsroot/nhibernate/nhibernate/src/NHibernate/Mapping/PersistentClass.cs,v retrieving revision 1.19 retrieving revision 1.20 diff -C2 -d -r1.19 -r1.20 *** PersistentClass.cs 1 Mar 2005 16:24:49 -0000 1.19 --- PersistentClass.cs 6 Mar 2005 12:44:44 -0000 1.20 *************** *** 17,28 **** private static readonly Alias PKAlias = new Alias( 15, "PK" ); ! /// <summary> ! /// ! /// </summary> ! public static readonly string NullDiscriminatorMapping = "null"; ! /// <summary> ! /// ! /// </summary> ! public static readonly string NotNullDiscriminatorMapping = "not null"; private System.Type mappedClass; --- 17,24 ---- private static readonly Alias PKAlias = new Alias( 15, "PK" ); ! /// <summary></summary> ! public const string NullDiscriminatorMapping = "null"; ! /// <summary></summary> ! public const string NotNullDiscriminatorMapping = "not null"; private System.Type mappedClass; *************** *** 37,43 **** private bool dynamicUpdate; private int batchSize = 1; ! //private bool selectBeforeUpdate; ! //private int optimisticLockMode; ! //private IDictionary metaAttributes; /// <summary> --- 33,39 ---- private bool dynamicUpdate; private int batchSize = 1; ! private bool selectBeforeUpdate; ! private int optimisticLockMode; ! private IDictionary metaAttributes; /// <summary> *************** *** 539,542 **** --- 535,573 ---- /// <summary> + /// + /// </summary> + public bool SelectBeforeUpdate + { + get { return selectBeforeUpdate; } + set { selectBeforeUpdate = value; } + } + + /// <summary> + /// + /// </summary> + /// <param name="propertyName"></param> + /// <returns></returns> + public Property GetProperty( string propertyName ) + { + foreach( Property prop in PropertyClosureCollection ) + { + if ( prop.Name == propertyName ) + { + return prop; + } + } + throw new MappingException( string.Format( "property not found: {0}", propertyName ) ); + } + + /// <summary> + /// + /// </summary> + public int OptimisticLockMode + { + get { return optimisticLockMode; } + set { optimisticLockMode = value; } + } + + /// <summary> /// When implemented by a class, gets or sets the sql string that should /// be a part of the where clause. Index: NamedSQLQuery.cs =================================================================== RCS file: /cvsroot/nhibernate/nhibernate/src/NHibernate/Mapping/NamedSQLQuery.cs,v retrieving revision 1.1 retrieving revision 1.2 diff -C2 -d -r1.1 -r1.2 *** NamedSQLQuery.cs 1 Mar 2005 16:24:49 -0000 1.1 --- NamedSQLQuery.cs 6 Mar 2005 12:44:44 -0000 1.2 *************** *** 37,43 **** /// /// </summary> ! public string[] ReturnClasses { ! get { return (string[]) aliasedClasses.ToArray( typeof( string[ ] ) ); } } --- 37,43 ---- /// /// </summary> ! public System.Type[] ReturnClasses { ! get { return (System.Type[]) aliasedClasses.ToArray( typeof( string[ ] ) ); } } *************** *** 72,76 **** /// <param name="alias"></param> /// <param name="clazz"></param> ! public void AddAliasedClass( string alias, object clazz) { aliases.Add( alias ); --- 72,76 ---- /// <param name="alias"></param> /// <param name="clazz"></param> ! public void AddAliasedClass( string alias, System.Type clazz) { aliases.Add( alias ); |
From: Paul H. <pha...@us...> - 2005-03-06 12:44:58
|
Update of /cvsroot/nhibernate/nhibernate/src/NHibernate/Loader In directory sc8-pr-cvs1.sourceforge.net:/tmp/cvs-serv21577/nhibernate/src/NHibernate/Loader Modified Files: AbstractEntityLoader.cs CollectionLoader.cs ICollectionInitializer.cs Loader.cs OneToManyLoader.cs OuterJoinLoader.cs Added Files: BatchingCollectionInitializer.cs Log Message: Refactored SessionImpl as per 2.1 for Save/Update Index: ICollectionInitializer.cs =================================================================== RCS file: /cvsroot/nhibernate/nhibernate/src/NHibernate/Loader/ICollectionInitializer.cs,v retrieving revision 1.3 retrieving revision 1.4 diff -C2 -d -r1.3 -r1.4 *** ICollectionInitializer.cs 31 Dec 2004 20:57:44 -0000 1.3 --- ICollectionInitializer.cs 6 Mar 2005 12:44:43 -0000 1.4 *************** *** 17,20 **** --- 17,27 ---- /// <param name="session"></param> void Initialize( object id, PersistentCollection collection, object owner, ISessionImplementor session ); + + /// <summary> + /// + /// </summary> + /// <param name="id"></param> + /// <param name="session"></param> + void Initialize( object id, ISessionImplementor session); } } \ No newline at end of file Index: CollectionLoader.cs =================================================================== RCS file: /cvsroot/nhibernate/nhibernate/src/NHibernate/Loader/CollectionLoader.cs,v retrieving revision 1.13 retrieving revision 1.14 diff -C2 -d -r1.13 -r1.14 *** CollectionLoader.cs 1 Mar 2005 16:24:48 -0000 1.13 --- CollectionLoader.cs 6 Mar 2005 12:44:43 -0000 1.14 *************** *** 15,20 **** public class CollectionLoader : OuterJoinLoader, ICollectionInitializer { ! private ICollectionPersister collectionPersister; ! private IType idType; /// <summary> --- 15,20 ---- public class CollectionLoader : OuterJoinLoader, ICollectionInitializer { ! private IQueryableCollection collectionPersister; ! private IType keyType; /// <summary> *************** *** 23,29 **** /// <param name="persister"></param> /// <param name="factory"></param> ! public CollectionLoader( IQueryableCollection persister, ISessionFactoryImplementor factory ) : base( factory.Dialect ) { ! idType = persister.KeyType; string alias = ToAlias( persister.TableName, 0 ); --- 23,39 ---- /// <param name="persister"></param> /// <param name="factory"></param> ! public CollectionLoader( IQueryableCollection persister, ISessionFactoryImplementor factory ) : this( persister, 1, factory ) { ! } ! ! /// <summary> ! /// ! /// </summary> ! /// <param name="persister"></param> ! /// <param name="batchSize"></param> ! /// <param name="factory"></param> ! public CollectionLoader( IQueryableCollection persister, int batchSize, ISessionFactoryImplementor factory ) : base( factory.Dialect ) ! { ! keyType = persister.KeyType; string alias = ToAlias( persister.TableName, 0 ); *************** *** 97,101 **** public void Initialize( object id, PersistentCollection collection, object owner, ISessionImplementor session ) { ! LoadCollection( session, id, idType, owner, collection ); } } --- 107,121 ---- public void Initialize( object id, PersistentCollection collection, object owner, ISessionImplementor session ) { ! LoadCollection( session, id, keyType, owner, collection ); ! } ! ! /// <summary> ! /// ! /// </summary> ! /// <param name="id"></param> ! /// <param name="session"></param> ! public void Initialize( object id, ISessionImplementor session ) ! { ! LoadCollection( session, id, keyType ); } } Index: OneToManyLoader.cs =================================================================== RCS file: /cvsroot/nhibernate/nhibernate/src/NHibernate/Loader/OneToManyLoader.cs,v retrieving revision 1.14 retrieving revision 1.15 diff -C2 -d -r1.14 -r1.15 *** OneToManyLoader.cs 1 Mar 2005 16:24:48 -0000 1.14 --- OneToManyLoader.cs 6 Mar 2005 12:44:43 -0000 1.15 *************** *** 142,145 **** --- 142,155 ---- LoadCollection( session, id, idType, owner, collection ); } + + /// <summary> + /// + /// </summary> + /// <param name="id"></param> + /// <param name="session"></param> + public void Initialize( object id, ISessionImplementor session ) + { + LoadCollection( session, id, idType ); + } } } \ No newline at end of file --- NEW FILE: BatchingCollectionInitializer.cs --- using NHibernate.Collection; using NHibernate.Engine; using log4net; namespace NHibernate.Loader { /// <summary> /// "Batch" loads collections, using multiple foreign key values in the SQL Where clause /// </summary> public class BatchingCollectionInitializer : ICollectionInitializer { private static readonly ILog log = LogManager.GetLogger( typeof( BatchingCollectionInitializer ) ); private readonly Loader nonBatchLoader; private readonly Loader batchLoader; private readonly Loader smallBatchLoader; private readonly int batchSize; private readonly int smallBatchSize; private readonly ICollectionPersister collectionPersister; /// <summary> /// /// </summary> /// <param name="collPersister"></param> /// <param name="batchSize"></param> /// <param name="batchLoader"></param> /// <param name="smallBatchSize"></param> /// <param name="smallBatchLoader"></param> /// <param name="nonBatchLoader"></param> public BatchingCollectionInitializer( ICollectionPersister collPersister, int batchSize, Loader batchLoader, int smallBatchSize, Loader smallBatchLoader, Loader nonBatchLoader) { this.batchLoader = batchLoader; this.nonBatchLoader = nonBatchLoader; this.batchSize = batchSize; this.collectionPersister = collPersister; this.smallBatchLoader = smallBatchLoader; this.smallBatchSize = smallBatchSize; } #region ICollectionInitializer Members /// <summary> /// /// </summary> /// <param name="id"></param> /// <param name="collection"></param> /// <param name="owner"></param> /// <param name="session"></param> public void Initialize(object id, PersistentCollection collection, object owner, ISessionImplementor session) { // TODO: Add BatchingCollectionInitializer.Initialize implementation } /// <summary> /// /// </summary> /// <param name="id"></param> /// <param name="session"></param> public void Initialize( object id, ISessionImplementor session ) { object[] batch = session.GetCollectionBatch( collectionPersister, id, batchSize ); if ( smallBatchSize == 1 || batch[ smallBatchSize - 1 ] == null ) { nonBatchLoader.LoadCollection( session, id, collectionPersister.KeyType ); } else if ( batch[ batchSize - 1 ] == null ) { if ( log.IsDebugEnabled ) { log.Debug( string.Format( "batch loading collection role (small batch): {0} ", collectionPersister.Role ) ); } // TODO: (2.1) BatchLoader - Copy the array from batch object[] smallBatch = new object[ smallBatchSize ]; smallBatchLoader.LoadCollectionBatch( session, smallBatch, collectionPersister.KeyType ); log.Debug( "done batch load"); } else { if ( log.IsDebugEnabled ) { log.Debug( string.Format( "batch loading collection role (small batch): {0} ", collectionPersister.Role ) ); } batchLoader.LoadCollectionBatch( session, batch, collectionPersister.KeyType ); log.Debug( "done batch load"); } } #endregion } } Index: OuterJoinLoader.cs =================================================================== RCS file: /cvsroot/nhibernate/nhibernate/src/NHibernate/Loader/OuterJoinLoader.cs,v retrieving revision 1.18 retrieving revision 1.19 diff -C2 -d -r1.18 -r1.19 *** OuterJoinLoader.cs 1 Mar 2005 16:24:48 -0000 1.18 --- OuterJoinLoader.cs 6 Mar 2005 12:44:44 -0000 1.19 *************** *** 119,123 **** IList associations = new ArrayList(); ! if( session.EnableJoinedFetch ) { IType type = persister.ElementType; --- 119,123 ---- IList associations = new ArrayList(); ! if( session.IsOuterJoinedFetchEnabled ) { IType type = persister.ElementType; *************** *** 242,246 **** private void WalkClassTree( ILoadable persister, string alias, IList associations, IList classPersisters, string path, ISessionFactoryImplementor session ) { ! if( !session.EnableJoinedFetch ) { return; --- 242,246 ---- private void WalkClassTree( ILoadable persister, string alias, IList associations, IList classPersisters, string path, ISessionFactoryImplementor session ) { ! if( !session.IsOuterJoinedFetchEnabled ) { return; *************** *** 312,316 **** ISessionFactoryImplementor session ) { ! if( !session.EnableJoinedFetch ) { return; --- 312,316 ---- ISessionFactoryImplementor session ) { ! if( !session.IsOuterJoinedFetchEnabled ) { return; *************** *** 379,383 **** ISessionFactoryImplementor session ) { ! if( !session.EnableJoinedFetch ) { return; --- 379,383 ---- ISessionFactoryImplementor session ) { ! if( !session.IsOuterJoinedFetchEnabled ) { return; Index: Loader.cs =================================================================== RCS file: /cvsroot/nhibernate/nhibernate/src/NHibernate/Loader/Loader.cs,v retrieving revision 1.48 retrieving revision 1.49 diff -C2 -d -r1.48 -r1.49 *** Loader.cs 1 Mar 2005 16:24:48 -0000 1.48 --- Loader.cs 6 Mar 2005 12:44:43 -0000 1.49 *************** *** 909,912 **** --- 909,913 ---- } + /// <summary> /// *************** *** 933,936 **** --- 934,979 ---- /// </summary> /// <param name="session"></param> + /// <param name="id"></param> + /// <param name="type"></param> + internal void LoadCollection( + ISessionImplementor session, + object id, + IType type ) + { + LoadCollection( session, new object[] { id }, new IType[] { type } ); + } + + /// <summary> + /// + /// </summary> + /// <param name="session"></param> + /// <param name="ids"></param> + /// <param name="type"></param> + internal void LoadCollectionBatch( + ISessionImplementor session, + object[] ids, + IType type ) + { + IType[] idTypes = new IType[ ids.Length ]; + for( int i = 0; i < idTypes.Length; i++ ) + { + idTypes[ i ] = type; + } + LoadCollection( session, ids, idTypes ); + } + + private void LoadCollection( + ISessionImplementor session, + object[] ids, + IType[] types ) + { + QueryParameters qp = new QueryParameters( types, ids ); + DoFindAndInitializeNonLazyCollections( session, qp, null, null, null, ids, true ); + } + + /// <summary> + /// + /// </summary> + /// <param name="session"></param> /// <param name="queryParameters"></param> /// <param name="querySpaces"></param> Index: AbstractEntityLoader.cs =================================================================== RCS file: /cvsroot/nhibernate/nhibernate/src/NHibernate/Loader/AbstractEntityLoader.cs,v retrieving revision 1.14 retrieving revision 1.15 diff -C2 -d -r1.14 -r1.15 *** AbstractEntityLoader.cs 1 Mar 2005 16:24:47 -0000 1.14 --- AbstractEntityLoader.cs 6 Mar 2005 12:44:43 -0000 1.15 *************** *** 10,14 **** { /// <summary></summary> ! public class AbstractEntityLoader : OuterJoinLoader { private ILoadable persister; --- 10,14 ---- { /// <summary></summary> ! public abstract class AbstractEntityLoader : OuterJoinLoader { private ILoadable persister; |
From: Sergey K. <jus...@us...> - 2005-03-05 10:44:01
|
Update of /cvsroot/nhibernate/nhibernate/src/NHibernate/Type In directory sc8-pr-cvs1.sourceforge.net:/tmp/cvs-serv15876/src/NHibernate/Type Modified Files: TypeFactory.cs Log Message: Add missing SByte type Index: TypeFactory.cs =================================================================== RCS file: /cvsroot/nhibernate/nhibernate/src/NHibernate/Type/TypeFactory.cs,v retrieving revision 1.44 retrieving revision 1.45 diff -C2 -d -r1.44 -r1.45 *** TypeFactory.cs 1 Mar 2005 16:24:50 -0000 1.44 --- TypeFactory.cs 5 Mar 2005 10:43:51 -0000 1.45 *************** *** 113,116 **** --- 113,117 ---- typeByTypeOfName[ NHibernateUtil.Boolean.Name ] = NHibernateUtil.Boolean; typeByTypeOfName[ NHibernateUtil.Byte.Name ] = NHibernateUtil.Byte; + typeByTypeOfName[ NHibernateUtil.SByte.Name ] = NHibernateUtil.SByte; typeByTypeOfName[ NHibernateUtil.Character.Name ] = NHibernateUtil.Character; typeByTypeOfName[ NHibernateUtil.StringClob.Name ] = NHibernateUtil.StringClob; *************** *** 575,579 **** /// </summary> /// <returns></returns> ! public static NullableType GetCharType() { return NHibernateUtil.Character; --- 576,589 ---- /// </summary> /// <returns></returns> ! public static NullableType GetSByteType() ! { ! return NHibernateUtil.SByte; ! } ! ! /// <summary> ! /// ! /// </summary> ! /// <returns></returns> ! public static NullableType GetCharType() { return NHibernateUtil.Character; |
From: Sergey K. <jus...@us...> - 2005-03-05 10:37:41
|
Update of /cvsroot/nhibernate/nhibernate/src/NHibernate/Type In directory sc8-pr-cvs1.sourceforge.net:/tmp/cvs-serv14798/src/NHibernate/Type Modified Files: NullableType.cs Log Message: Made "Could not cast" error message include the source type Index: NullableType.cs =================================================================== RCS file: /cvsroot/nhibernate/nhibernate/src/NHibernate/Type/NullableType.cs,v retrieving revision 1.13 retrieving revision 1.14 diff -C2 -d -r1.13 -r1.14 *** NullableType.cs 31 Dec 2004 23:54:40 -0000 1.13 --- NullableType.cs 5 Mar 2005 10:37:29 -0000 1.14 *************** *** 230,234 **** { throw new ADOException( ! "Could not cast the value in field " + name + " to the Type " + this.GetType().Name + ". Please check to make sure that the mapping is correct and that your DataProvider supports this Data Type.", ice ); } --- 230,234 ---- { throw new ADOException( ! "Could not cast the value in field " + name + " of type " + rs[index].GetType().Name + " to the Type " + this.GetType().Name + ". Please check to make sure that the mapping is correct and that your DataProvider supports this Data Type.", ice ); } |
From: Michael D. <mik...@us...> - 2005-03-02 22:28:43
|
Update of /cvsroot/nhibernate/CVSROOT In directory sc8-pr-cvs1.sourceforge.net:/tmp/cvs-serv15791 Modified Files: avail Log Message: Configured Michael Third for write access. Index: avail =================================================================== RCS file: /cvsroot/nhibernate/CVSROOT/avail,v retrieving revision 1.5 retrieving revision 1.6 diff -C2 -d -r1.5 -r1.6 *** avail 26 Feb 2005 15:49:37 -0000 1.5 --- avail 2 Mar 2005 22:28:32 -0000 1.6 *************** *** 1,4 **** unavail ! avail|luggage, kevinwilliams, johntmorris, justme84, phatcher|NHibernateContrib ! avail|kevinwilliams, justme84, phatcher|nhibernate avail|mikedoerfler, szoke --- 1,4 ---- unavail ! avail|luggage, kevinwilliams, johntmorris, justme84, phatcher, mthird|NHibernateContrib ! avail|kevinwilliams, justme84, phatcher, mthird|nhibernate avail|mikedoerfler, szoke |
From: Michael D. <mik...@us...> - 2005-03-02 14:38:39
|
Update of /cvsroot/nhibernate/nhibernate/src/NHibernate/Dialect In directory sc8-pr-cvs1.sourceforge.net:/tmp/cvs-serv4514/Dialect Removed Files: QueryFunctionStandard.cs Log Message: removed files that are not in csproj anymore. --- QueryFunctionStandard.cs DELETED --- |
From: Michael D. <mik...@us...> - 2005-03-02 14:38:39
|
Update of /cvsroot/nhibernate/nhibernate/src/NHibernate/Hql In directory sc8-pr-cvs1.sourceforge.net:/tmp/cvs-serv4514/Hql Removed Files: IQueryFunctionInfo.cs Log Message: removed files that are not in csproj anymore. --- IQueryFunctionInfo.cs DELETED --- |
From: Michael D. <mik...@us...> - 2005-03-02 14:38:38
|
Update of /cvsroot/nhibernate/nhibernate/src/NHibernate/Mapping In directory sc8-pr-cvs1.sourceforge.net:/tmp/cvs-serv4514/Mapping Removed Files: Association.cs Value.cs Log Message: removed files that are not in csproj anymore. --- Value.cs DELETED --- --- Association.cs DELETED --- |
Update of /cvsroot/nhibernate/nhibernate/src/NHibernate/Cfg In directory sc8-pr-cvs1.sourceforge.net:/tmp/cvs-serv5548/nhibernate/src/NHibernate/Cfg Modified Files: Binder.cs Configuration.cs Mappings.cs Added Files: DefaultNamingStrategy.cs INamingStrategy.cs ImprovedNamingStrategy.cs Log Message: Various refactorings on the way to 2.1 querying capability Index: Mappings.cs =================================================================== RCS file: /cvsroot/nhibernate/nhibernate/src/NHibernate/Cfg/Mappings.cs,v retrieving revision 1.11 retrieving revision 1.12 diff -C2 -d -r1.11 -r1.12 *** Mappings.cs 31 Dec 2004 15:54:08 -0000 1.11 --- Mappings.cs 1 Mar 2005 16:24:44 -0000 1.12 *************** *** 18,21 **** --- 18,22 ---- private IDictionary tables; private IDictionary queries; + private IDictionary sqlqueries; private IList secondPasses; private IDictionary imports; *************** *** 23,28 **** --- 24,37 ---- private string defaultCascade; private bool autoImport; + private IList propertyReferences; private string defaultAccess; private IDictionary caches; + private INamingStrategy namingStrategy; + + private class UniquePropertyReference + { + public System.Type ReferencedClass; + public string PropertyName; + } /// <summary> *************** *** 33,48 **** /// <param name="tables"></param> /// <param name="queries"></param> /// <param name="imports"></param> /// <param name="caches"></param> /// <param name="secondPasses"></param> ! internal Mappings( IDictionary classes, IDictionary collections, IDictionary tables, IDictionary queries, IDictionary imports, IDictionary caches, IList secondPasses ) { this.classes = classes; this.collections = collections; this.queries = queries; this.tables = tables; this.imports = imports; this.caches = caches; this.secondPasses = secondPasses; } --- 42,63 ---- /// <param name="tables"></param> /// <param name="queries"></param> + /// <param name="sqlqueries"></param> /// <param name="imports"></param> /// <param name="caches"></param> /// <param name="secondPasses"></param> ! /// <param name="propertyReferences"></param> ! /// <param name="namingStrategy"></param> ! internal Mappings( IDictionary classes, IDictionary collections, IDictionary tables, IDictionary queries, IDictionary sqlqueries, IDictionary imports, IDictionary caches, IList secondPasses, IList propertyReferences, INamingStrategy namingStrategy ) { this.classes = classes; this.collections = collections; this.queries = queries; + this.sqlqueries = sqlqueries; this.tables = tables; this.imports = imports; this.caches = caches; this.secondPasses = secondPasses; + this.propertyReferences = propertyReferences; + this.namingStrategy = namingStrategy; } *************** *** 69,78 **** public void AddClass( PersistentClass persistentClass ) { ! object old = classes[ persistentClass.PersistentClazz ]; if( old != null ) { ! log.Warn( "duplicate class mapping: " + persistentClass.PersistentClazz.Name ); } ! classes[ persistentClass.PersistentClazz ] = persistentClass; } --- 84,93 ---- public void AddClass( PersistentClass persistentClass ) { ! object old = classes[ persistentClass.MappedClass ]; if( old != null ) { ! log.Warn( "duplicate class mapping: " + persistentClass.MappedClass.Name ); } ! classes[ persistentClass.MappedClass ] = persistentClass; } *************** *** 94,97 **** --- 109,126 ---- /// /// </summary> + /// <param name="referencedClass"></param> + /// <param name="propertyName"></param> + public void AddUniquePropertyReference( System.Type referencedClass, string propertyName ) + { + UniquePropertyReference upr = new UniquePropertyReference(); + upr.ReferencedClass = referencedClass; + upr.PropertyName = propertyName; + + propertyReferences.Add( upr ); + } + + /// <summary> + /// + /// </summary> /// <param name="type"></param> /// <returns></returns> *************** *** 104,107 **** --- 133,144 ---- /// /// </summary> + public INamingStrategy NamingStrategy + { + get { return namingStrategy; } + } + + /// <summary> + /// + /// </summary> /// <param name="role"></param> /// <returns></returns> *************** *** 185,188 **** --- 222,233 ---- } + private void CheckQueryExists( string name ) + { + if ( queries.Contains( name ) || sqlqueries.Contains( name ) ) + { + throw new MappingException( string.Format( "Duplicate query named: {0}", name ) ); + } + } + /// <summary> /// *************** *** 192,200 **** public void AddQuery( string name, string query ) { ! object old = queries[ name ]; ! if( old != null ) ! { ! log.Warn( "duplicate query name: " + name ); ! } queries[ name ] = query; } --- 237,241 ---- public void AddQuery( string name, string query ) { ! CheckQueryExists( name ); queries[ name ] = query; } *************** *** 204,207 **** --- 245,259 ---- /// </summary> /// <param name="name"></param> + /// <param name="query"></param> + public void AddSQLQuery( string name, NamedSQLQuery query ) + { + CheckQueryExists( name ); + sqlqueries[ name ] = query; + } + + /// <summary> + /// + /// </summary> + /// <param name="name"></param> /// <returns></returns> public string GetQuery( string name ) --- NEW FILE: DefaultNamingStrategy.cs --- using NHibernate.Util; namespace NHibernate.Cfg { /// <summary> /// The default <cref name="INamingStrategy"/> /// </summary> /// <remarks>See <cref name="ImprovedNamingStrategy"/> for a better alternative</remarks> public class DefaultNamingStrategy : INamingStrategy { /// <summary> /// The singleton instance /// </summary> public static readonly INamingStrategy Instance = new DefaultNamingStrategy(); private DefaultNamingStrategy() { } #region INamingStrategy Members /// <summary> /// Return the unqualified class name /// </summary> /// <param name="className"></param> /// <returns></returns> public string ClassToTableName(string className) { return StringHelper.Unqualify( className ); } /// <summary> /// Return the unqualified property name /// </summary> /// <param name="propertyName"></param> /// <returns></returns> public string PropertyToColumnName(string propertyName) { return StringHelper.Unqualify( propertyName ); } /// <summary> /// Return the argument /// </summary> /// <param name="tableName"></param> /// <returns></returns> public string TableName(string tableName) { return tableName; } /// <summary> /// Return the argument /// </summary> /// <param name="columnName"></param> /// <returns></returns> public string ColumnName(string columnName) { return columnName; } /// <summary> /// Return the unqualified property name /// </summary> /// <param name="className"></param> /// <param name="propertyName"></param> /// <returns></returns> public string PropertyToTableName(string className, string propertyName) { return StringHelper.Unqualify( propertyName ); } #endregion } } --- NEW FILE: ImprovedNamingStrategy.cs --- using System; using System.Text; using NHibernate.Util; namespace NHibernate.Cfg { /// <summary> /// Summary description for ImprovedNamingStrategy. /// </summary> public class ImprovedNamingStrategy : INamingStrategy { /// <summary> /// The singleton instance /// </summary> public static readonly INamingStrategy Instance = new ImprovedNamingStrategy(); private ImprovedNamingStrategy() { } #region INamingStrategy Members /// <summary> /// Return the unqualified class name, mixed case converted to underscores /// </summary> /// <param name="className"></param> /// <returns></returns> public string ClassToTableName(string className) { return AddUnderscores( StringHelper.Unqualify( className ) ); } /// <summary> /// Return the full property path with underscore seperators, mixed case converted to underscores /// </summary> /// <param name="propertyName"></param> /// <returns></returns> public string PropertyToColumnName(string propertyName) { return AddUnderscores( StringHelper.Unqualify( propertyName ) ); } /// <summary> /// Convert mixed case to underscores /// </summary> /// <param name="tableName"></param> /// <returns></returns> public string TableName(string tableName) { return AddUnderscores( tableName ); } /// <summary> /// Convert mixed case to underscores /// </summary> /// <param name="columnName"></param> /// <returns></returns> public string ColumnName(string columnName) { return AddUnderscores( columnName ); } /// <summary> /// Return the full property path prefixed by the unqualified class name, with underscore seperators, mixed case converted to underscores /// </summary> /// <param name="className"></param> /// <param name="propertyName"></param> /// <returns></returns> public string PropertyToTableName(string className, string propertyName) { return AddUnderscores( StringHelper.Unqualify( propertyName ) ); } #endregion private string AddUnderscores( string name ) { char[] chars = name.Replace( '.', '_' ).ToCharArray(); StringBuilder buf = new StringBuilder( chars.Length ) ; char prev = 'a'; foreach( char c in chars ) { if ( c != '_' && char.IsUpper(c) && !char.IsUpper(prev) ) { buf.Append( '_' ); } buf.Append( char.ToLower( c ) ); } return buf.ToString(); } } } Index: Binder.cs =================================================================== RCS file: /cvsroot/nhibernate/nhibernate/src/NHibernate/Cfg/Binder.cs,v retrieving revision 1.38 retrieving revision 1.39 diff -C2 -d -r1.38 -r1.39 *** Binder.cs 14 Feb 2005 03:29:05 -0000 1.38 --- Binder.cs 1 Mar 2005 16:24:43 -0000 1.39 *************** *** 24,34 **** public static void BindClass(XmlNode node, PersistentClass model, Mappings mapping) { - string className = node.Attributes["name"] == null ? null : node.Attributes["name"].Value; ! // class try { ! model.PersistentClazz = ReflectHelper.ClassForName(className); } [...1756 lines suppressed...] } *************** *** 1459,1466 **** { public CollectionTypePrimitiveArray(string xmlTag) : base(xmlTag) { } ! public override Mapping.Collection Create(XmlNode node, string prefix, PersistentClass owner, Mappings mappings) { PrimitiveArray array = new PrimitiveArray(owner); ! Binder.BindArray(node, array, prefix, mappings); return array; } --- 1594,1601 ---- { public CollectionTypePrimitiveArray(string xmlTag) : base(xmlTag) { } ! public override Mapping.Collection Create(XmlNode node, string prefix, string path, PersistentClass owner, Mappings mappings) { PrimitiveArray array = new PrimitiveArray(owner); ! Binder.BindArray(node, array, prefix, path, mappings); return array; } Index: Configuration.cs =================================================================== RCS file: /cvsroot/nhibernate/nhibernate/src/NHibernate/Cfg/Configuration.cs,v retrieving revision 1.31 retrieving revision 1.32 diff -C2 -d -r1.31 -r1.32 *** Configuration.cs 21 Feb 2005 19:17:39 -0000 1.31 --- Configuration.cs 1 Mar 2005 16:24:43 -0000 1.32 *************** *** 39,47 **** --- 39,51 ---- private Hashtable tables = new Hashtable(); private Hashtable namedQueries = new Hashtable(); + private Hashtable namedSqlQueries = new Hashtable(); private ArrayList secondPasses = new ArrayList(); + private ArrayList propertyReferences = new ArrayList(); private IInterceptor interceptor = emptyInterceptor; private IDictionary properties = Environment.Properties; private IDictionary caches = new Hashtable(); + private INamingStrategy namingStrategy = DefaultNamingStrategy.Instance; + private XmlSchema mappingSchema; private XmlSchema cfgSchema; *************** *** 70,73 **** --- 74,78 ---- tables = new Hashtable(); namedQueries = new Hashtable(); + namedSqlQueries = new Hashtable(); secondPasses = new ArrayList(); interceptor = emptyInterceptor; *************** *** 141,145 **** public Mappings CreateMappings() { ! return new Mappings( classes, collections, tables, namedQueries, imports, caches, secondPasses ); } --- 146,150 ---- public Mappings CreateMappings() { ! return new Mappings( classes, collections, tables, namedQueries, namedSqlQueries, imports, caches, secondPasses, propertyReferences, namingStrategy ); } *************** *** 692,695 **** --- 697,716 ---- /// <summary> + /// The named SQL queries + /// </summary> + public IDictionary NamedSQLQueries + { + get { return namedSqlQueries; } + } + + /// <summary> + /// Naming strategy for tables and columns + /// </summary> + public INamingStrategy NamingStrategy + { + get { return namingStrategy; } + } + + /// <summary> /// Instantitate a new <c>ISessionFactory</c>, using the properties and mappings in this /// configuration. The <c>ISessionFactory</c> will be immutable, so changes made to the *************** *** 833,837 **** } } ! } --- 854,868 ---- } } ! } ! ! /// <summary> ! /// Set a custom naming strategy ! /// </summary> ! /// <param name="namingStrategy">the NamingStrategy to set</param> ! /// <returns></returns> ! public Configuration SetNamingStrategy( INamingStrategy namingStrategy ) ! { ! this.namingStrategy = namingStrategy; ! return this; } *************** *** 1006,1009 **** --- 1037,1064 ---- get { return imports; } } + + // HACK: SHould really implement IMapping, but simpler than dealing with the cascades + + /// <summary> + /// + /// </summary> + /// <param name="objectClass"></param> + /// <returns></returns> + public string GetIdentifierPropertyName( System.Type objectClass ) + { + return null; + } + + /// <summary> + /// + /// </summary> + /// <param name="persistentClass"></param> + /// <param name="propertyName"></param> + /// <returns></returns> + public IType GetPropertyType( System.Type persistentClass, string propertyName ) + { + return null; + } + } } \ No newline at end of file --- NEW FILE: INamingStrategy.cs --- using System; namespace NHibernate.Cfg { /// <summary> /// A set of rules for determining the physical column and table names given the information in the mapping /// document. May be used to implement project-scoped naming standards for database objects. /// </summary> public interface INamingStrategy { /// <summary> /// Return a table name for an entity class /// </summary> /// <param name="className">the fully-qualified class name</param> /// <returns>a table name</returns> string ClassToTableName( string className ); /// <summary> /// Return a column name for a property path expression /// </summary> /// <param name="propertyName">a property path</param> /// <returns>a column name</returns> string PropertyToColumnName( string propertyName ); /// <summary> /// Alter the table name given in the mapping document /// </summary> /// <param name="tableName">a table name</param> /// <returns>a table name</returns> string TableName( string tableName ); /// <summary> /// Alter the column name given in the mapping document /// </summary> /// <param name="columnName">a column name</param> /// <returns>a column name</returns> string ColumnName( string columnName ); /// <summary> /// Return a table name for a collection /// </summary> /// <param name="className">the fully-qualified name of the owning entity class</param> /// <param name="propertyName">a property path</param> /// <returns>a table name</returns> string PropertyToTableName( string className, string propertyName ); } } |
From: Paul H. <pha...@us...> - 2005-03-01 16:25:39
|
Update of /cvsroot/nhibernate/nhibernate/src/NHibernate.Test/UtilityTest In directory sc8-pr-cvs1.sourceforge.net:/tmp/cvs-serv5548/nhibernate/src/NHibernate.Test/UtilityTest Modified Files: StringHelperFixture.cs Log Message: Various refactorings on the way to 2.1 querying capability Index: StringHelperFixture.cs =================================================================== RCS file: /cvsroot/nhibernate/nhibernate/src/NHibernate.Test/UtilityTest/StringHelperFixture.cs,v retrieving revision 1.1 retrieving revision 1.2 diff -C2 -d -r1.1 -r1.2 *** StringHelperFixture.cs 12 Apr 2004 05:38:20 -0000 1.1 --- StringHelperFixture.cs 1 Mar 2005 16:24:42 -0000 1.2 *************** *** 30,33 **** --- 30,76 ---- Assert.AreEqual(expected, StringHelper.GetClassname(typeName)); } + + [Test] + public void CountUnquotedParams() + { + // Base case, no values + Assert.AreEqual(0, StringHelper.CountUnquoted("abcd eftf", '?')); + + // Simple case + Assert.AreEqual(1, StringHelper.CountUnquoted("abcd ? eftf", '?')); + + // Multiple values + Assert.AreEqual(2, StringHelper.CountUnquoted("abcd ? ef ? tf", '?')); + + // Quoted values + Assert.AreEqual(1, StringHelper.CountUnquoted("abcd ? ef '?' tf", '?')); + } + + [Test, ExpectedException(typeof(ArgumentOutOfRangeException))] + /// <summary> + /// Try to locate single quotes which isn't allowed + /// </summary> + public void CantCountQuotes() + { + Assert.AreEqual(0, StringHelper.CountUnquoted("abcd eftf", StringHelper.SingleQuote)); + } + + [Test] + [Ignore("Test not written yet.")] + /// <summary> + /// Qualify a name with a prefix + /// </summary> + public void Qualify() + { + } + + [Test] + [Ignore("Test not written yet.")] + /// <summary> + /// Qualify an array of names with a prefix + /// </summary> + public void QualifyArray() + { + } } } |
From: Paul H. <pha...@us...> - 2005-03-01 16:25:38
|
Update of /cvsroot/nhibernate/nhibernate/src In directory sc8-pr-cvs1.sourceforge.net:/tmp/cvs-serv5548/nhibernate/src Modified Files: NHibernate-1.1.sln Log Message: Various refactorings on the way to 2.1 querying capability Index: NHibernate-1.1.sln =================================================================== RCS file: /cvsroot/nhibernate/nhibernate/src/NHibernate-1.1.sln,v retrieving revision 1.4 retrieving revision 1.5 diff -C2 -d -r1.4 -r1.5 *** NHibernate-1.1.sln 31 Dec 2004 14:59:17 -0000 1.4 --- NHibernate-1.1.sln 1 Mar 2005 16:24:40 -0000 1.5 *************** *** 4,16 **** EndProjectSection EndProject ! Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "NHibernate.Test-1.1", "NHibernate.Test\NHibernate.Test-1.1.csproj", "{F6CDD71A-FDCA-43F1-A5FF-B2941224A66F}" ProjectSection(ProjectDependencies) = postProject EndProjectSection EndProject ! Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "NHibernate.DomainModel-1.1", "NHibernate.DomainModel\NHibernate.DomainModel-1.1.csproj", "{E3482030-5828-4112-9906-D4C5153DCE3F}" ProjectSection(ProjectDependencies) = postProject EndProjectSection EndProject Global GlobalSection(SolutionConfiguration) = preSolution Debug = Debug --- 4,19 ---- EndProjectSection EndProject ! Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "NHibernate.DomainModel-1.1", "NHibernate.DomainModel\NHibernate.DomainModel-1.1.csproj", "{E3482030-5828-4112-9906-D4C5153DCE3F}" ProjectSection(ProjectDependencies) = postProject EndProjectSection EndProject ! Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "NHibernate.Test-1.1", "NHibernate.Test\NHibernate.Test-1.1.csproj", "{F6CDD71A-FDCA-43F1-A5FF-B2941224A66F}" ProjectSection(ProjectDependencies) = postProject EndProjectSection EndProject Global + GlobalSection(DPCodeReviewSolutionGUID) = preSolution + DPCodeReviewSolutionGUID = {00000000-0000-0000-0000-000000000000} + EndGlobalSection GlobalSection(SolutionConfiguration) = preSolution Debug = Debug *************** *** 22,33 **** {0D8B57B0-1310-4EF0-B50C-DD22F37310C7}.Release.ActiveCfg = Release|.NET {0D8B57B0-1310-4EF0-B50C-DD22F37310C7}.Release.Build.0 = Release|.NET - {F6CDD71A-FDCA-43F1-A5FF-B2941224A66F}.Debug.ActiveCfg = Debug|.NET - {F6CDD71A-FDCA-43F1-A5FF-B2941224A66F}.Debug.Build.0 = Debug|.NET - {F6CDD71A-FDCA-43F1-A5FF-B2941224A66F}.Release.ActiveCfg = Release|.NET - {F6CDD71A-FDCA-43F1-A5FF-B2941224A66F}.Release.Build.0 = Release|.NET {E3482030-5828-4112-9906-D4C5153DCE3F}.Debug.ActiveCfg = Debug|.NET {E3482030-5828-4112-9906-D4C5153DCE3F}.Debug.Build.0 = Debug|.NET {E3482030-5828-4112-9906-D4C5153DCE3F}.Release.ActiveCfg = Release|.NET {E3482030-5828-4112-9906-D4C5153DCE3F}.Release.Build.0 = Release|.NET EndGlobalSection GlobalSection(ExtensibilityGlobals) = postSolution --- 25,36 ---- {0D8B57B0-1310-4EF0-B50C-DD22F37310C7}.Release.ActiveCfg = Release|.NET {0D8B57B0-1310-4EF0-B50C-DD22F37310C7}.Release.Build.0 = Release|.NET {E3482030-5828-4112-9906-D4C5153DCE3F}.Debug.ActiveCfg = Debug|.NET {E3482030-5828-4112-9906-D4C5153DCE3F}.Debug.Build.0 = Debug|.NET {E3482030-5828-4112-9906-D4C5153DCE3F}.Release.ActiveCfg = Release|.NET {E3482030-5828-4112-9906-D4C5153DCE3F}.Release.Build.0 = Release|.NET + {F6CDD71A-FDCA-43F1-A5FF-B2941224A66F}.Debug.ActiveCfg = Debug|.NET + {F6CDD71A-FDCA-43F1-A5FF-B2941224A66F}.Debug.Build.0 = Debug|.NET + {F6CDD71A-FDCA-43F1-A5FF-B2941224A66F}.Release.ActiveCfg = Release|.NET + {F6CDD71A-FDCA-43F1-A5FF-B2941224A66F}.Release.Build.0 = Release|.NET EndGlobalSection GlobalSection(ExtensibilityGlobals) = postSolution |
From: Paul H. <pha...@us...> - 2005-03-01 16:25:38
|
Update of /cvsroot/nhibernate/NHibernateContrib/src/Nullables In directory sc8-pr-cvs1.sourceforge.net:/tmp/cvs-serv5548/NHibernateContrib/src/Nullables Modified Files: AssemblyInfo.cs Log Message: Various refactorings on the way to 2.1 querying capability Index: AssemblyInfo.cs =================================================================== RCS file: /cvsroot/nhibernate/NHibernateContrib/src/Nullables/AssemblyInfo.cs,v retrieving revision 1.7 retrieving revision 1.8 diff -C2 -d -r1.7 -r1.8 *** AssemblyInfo.cs 26 Feb 2005 15:26:25 -0000 1.7 --- AssemblyInfo.cs 1 Mar 2005 16:24:39 -0000 1.8 *************** *** 17,23 **** [assembly: AssemblyProductAttribute("Nullables")] [assembly: AssemblyCopyrightAttribute("Licensed under LGPL.")] ! [assembly: AssemblyVersionAttribute("0.7.0.0")] ! [assembly: AssemblyInformationalVersionAttribute("0.7")] ! [assembly: AssemblyFileVersionAttribute("0.7.0.0")] //[assembly: AssemblyKeyFileAttribute("..\\NHibernate.snk")] --- 17,23 ---- [assembly: AssemblyProductAttribute("Nullables")] [assembly: AssemblyCopyrightAttribute("Licensed under LGPL.")] ! [assembly: AssemblyVersionAttribute("0.6.0.0")] ! [assembly: AssemblyInformationalVersionAttribute("0.6")] ! [assembly: AssemblyFileVersionAttribute("0.6.0.0")] //[assembly: AssemblyKeyFileAttribute("..\\NHibernate.snk")] |
From: Paul H. <pha...@us...> - 2005-03-01 16:25:38
|
Update of /cvsroot/nhibernate/nhibernate/src/NHibernate.DomainModel In directory sc8-pr-cvs1.sourceforge.net:/tmp/cvs-serv5548/nhibernate/src/NHibernate.DomainModel Modified Files: AssemblyInfo.cs CustomPersister.cs Log Message: Various refactorings on the way to 2.1 querying capability Index: CustomPersister.cs =================================================================== RCS file: /cvsroot/nhibernate/nhibernate/src/NHibernate.DomainModel/CustomPersister.cs,v retrieving revision 1.3 retrieving revision 1.4 diff -C2 -d -r1.3 -r1.4 *** CustomPersister.cs 17 Jan 2005 03:40:49 -0000 1.3 --- CustomPersister.cs 1 Mar 2005 16:24:41 -0000 1.4 *************** *** 238,241 **** --- 238,247 ---- } + public IType GetPropertyType( string propertyName ) + { + // TODO: Implement this + return null; + } + public object Load(object id, object optionalObject, LockMode lockMode, ISessionImplementor session) { Index: AssemblyInfo.cs =================================================================== RCS file: /cvsroot/nhibernate/nhibernate/src/NHibernate.DomainModel/AssemblyInfo.cs,v retrieving revision 1.11 retrieving revision 1.12 diff -C2 -d -r1.11 -r1.12 *** AssemblyInfo.cs 5 Jan 2005 22:14:12 -0000 1.11 --- AssemblyInfo.cs 1 Mar 2005 16:24:40 -0000 1.12 *************** *** 5,9 **** // <autogenerated> // This code was generated by a tool. ! // Runtime Version: 1.1.4322.573 // // Changes to this file may cause incorrect behavior and will be lost if --- 5,9 ---- // <autogenerated> // This code was generated by a tool. ! // Runtime Version: 1.1.4322.2032 // // Changes to this file may cause incorrect behavior and will be lost if *************** *** 17,23 **** [assembly: AssemblyProductAttribute("NHibernate.DomainModel")] [assembly: AssemblyCopyrightAttribute("Licensed under LGPL.")] ! [assembly: AssemblyVersionAttribute("0.6.0.0")] ! [assembly: AssemblyInformationalVersionAttribute("0.6")] ! [assembly: AssemblyFileVersionAttribute("0.6.0.0")] [assembly: AssemblyDelaySignAttribute(false)] --- 17,23 ---- [assembly: AssemblyProductAttribute("NHibernate.DomainModel")] [assembly: AssemblyCopyrightAttribute("Licensed under LGPL.")] ! [assembly: AssemblyVersionAttribute("0.8.0.0")] ! [assembly: AssemblyInformationalVersionAttribute("0.8")] ! [assembly: AssemblyFileVersionAttribute("0.8.0.0")] [assembly: AssemblyDelaySignAttribute(false)] |
From: Paul H. <pha...@us...> - 2005-03-01 16:25:35
|
Update of /cvsroot/nhibernate/nhibernate/src/NHibernate/Hql In directory sc8-pr-cvs1.sourceforge.net:/tmp/cvs-serv5548/nhibernate/src/NHibernate/Hql Modified Files: FilterTranslator.cs FromParser.cs FromPathExpressionParser.cs OrderByParser.cs PathExpressionParser.cs QueryTranslator.cs SelectParser.cs SelectPathExpressionParser.cs WhereParser.cs Log Message: Various refactorings on the way to 2.1 querying capability Index: PathExpressionParser.cs =================================================================== RCS file: /cvsroot/nhibernate/nhibernate/src/NHibernate/Hql/PathExpressionParser.cs,v retrieving revision 1.20 retrieving revision 1.21 diff -C2 -d -r1.20 -r1.21 *** PathExpressionParser.cs 17 Jan 2005 03:40:56 -0000 1.20 --- PathExpressionParser.cs 1 Mar 2005 16:24:46 -0000 1.21 *************** *** 45,77 **** private int dotcount; ! ! /// <summary></summary> ! protected string currentName; ! ! /// <summary></summary> ! protected string currentProperty; ! ! /// <summary></summary> ! protected QueryJoinFragment join; ! ! /// <summary></summary> ! protected string[ ] columns; ! ! /// <summary></summary> ! protected string[ ] collectionElementColumns; ! ! private string collectionName; //protected private string collectionOwnerName; private string collectionRole; ! private string collectionTable; ! ! /// <summary></summary> ! protected IType collectionElementType; ! private string componentPath; - /// <summary></summary> ! protected IType type; ! private string path; private bool ignoreInitialJoin; --- 45,60 ---- private int dotcount; ! private string currentName; ! private string currentProperty; ! private string oneToOneOwnerName; ! private QueryJoinFragment join; ! private string[ ] columns; ! private string collectionName; private string collectionOwnerName; private string collectionRole; ! //private StringBuilder componentPath = new StringBuilder(); private string componentPath; /// <summary></summary> ! private IType type; private string path; private bool ignoreInitialJoin; *************** *** 79,82 **** --- 62,66 ---- private JoinType joinType = JoinType.InnerJoin; //default mode private bool useThetaStyleJoin = true; + private IPropertyMapping currentPropertyMapping; /// <summary></summary> *************** *** 94,100 **** } ! private void AddJoin( string table, string name, string[ ] rhsCols, QueryTranslator q ) { ! string[ ] lhsCols = CurrentColumns( q ); join.AddJoin( table, name, lhsCols, rhsCols, joinType ); } --- 78,89 ---- } ! private IPropertyMapping PropertyMapping { ! get { return currentPropertyMapping; } ! } ! ! private void AddJoin( string table, string name, string[] rhsCols ) ! { ! string[] lhsCols = CurrentColumns( ); join.AddJoin( table, name, lhsCols, rhsCols, joinType ); } *************** *** 113,118 **** currentName = q.CreateNameFor( clazz ); q.AddType( currentName, clazz ); ! ILoadable p = q.GetPersister( clazz ); ! join.AddJoin( p.TableName, currentName, joinColumns, p.IdentifierColumnNames, joinType ); return currentName; } --- 102,108 ---- currentName = q.CreateNameFor( clazz ); q.AddType( currentName, clazz ); ! IQueryable classPersister = q.GetPersister( clazz ); ! join.AddJoin( classPersister.TableName, currentName, joinColumns, classPersister.IdentifierColumnNames, joinType ); ! currentPropertyMapping = classPersister; return currentName; } *************** *** 141,144 **** --- 131,135 ---- Reset( q ); //reset the dotcount (but not the path) currentName = alias; //after reset! + currentPropertyMapping = q.GetPropertyMapping( currentName ); if( !ignoreInitialJoin ) { *************** *** 165,168 **** --- 156,160 ---- } currentName = token; + currentPropertyMapping = q.GetPropertyMapping( currentName ); } } *************** *** 175,180 **** else if( collectionName != null ) { ! CollectionPersister p = q.GetCollectionPersister( collectionRole ); ! DoCollectionProperty( token, p, collectionName ); continuation = false; } --- 167,172 ---- else if( collectionName != null ) { ! //IQueryableCollection p = q.GetCollectionPersister( collectionRole ); ! //DoCollectionProperty( token, p, collectionName ); continuation = false; } *************** *** 188,192 **** // Do the corresponding RHS ! IType propertyType = GetPropertyType( q ); if( propertyType == null ) --- 180,184 ---- // Do the corresponding RHS ! IType propertyType = PropertyType; if( propertyType == null ) *************** *** 195,279 **** } ! if( propertyType.IsComponentType || propertyType.IsObjectType ) { ! if( componentPath == null ) ! { ! componentPath = token; ! } ! else ! { ! if( token != null ) ! { ! componentPath += StringHelper.Dot + token; ! } ! } } ! else { ! if( propertyType.IsEntityType ) ! { ! System.Type memberClass = ( ( EntityType ) propertyType ).PersistentClass; ! IQueryable memberPersister = q.GetPersister( memberClass ); ! if( ! // if its "id" ! EntityID.Equals( token ) || ( ! //or its the id property name ! memberPersister.HasIdentifierProperty && ! memberPersister.IdentifierPropertyName.Equals( token ) ) ) ! { ! // special shortcut for id properties, skip the join! ! // this must only occur at the _end_ of a path expression ! if( componentPath == null ) ! { ! componentPath = "id"; ! } ! else ! { ! componentPath += ".id"; ! } ! } ! else ! { ! string name = q.CreateNameFor( memberClass ); ! q.AddType( name, memberClass ); ! string[ ] keyColNames = memberPersister.IdentifierColumnNames; ! AddJoin( memberPersister.TableName, name, keyColNames, q ); ! currentName = name; ! currentProperty = token; ! q.AddPathAliasAndJoin( path.Substring( 0, ( path.LastIndexOf( StringHelper.Dot ) ) - ( 0 ) ), name, join ); ! componentPath = null; ! } ! } ! else if( propertyType.IsPersistentCollectionType ) ! { ! collectionRole = ( ( PersistentCollectionType ) propertyType ).Role; ! CollectionPersister collPersister = q.GetCollectionPersister( collectionRole ); ! string[ ] colNames = collPersister.KeyColumnNames; ! ! string name = q.CreateNameForCollection( collectionRole ); ! string tableName = collPersister.QualifiedTableName; ! AddJoin( tableName, name, colNames, q ); ! if( collPersister.HasWhere ) ! { ! join.AddCondition( collPersister.GetSQLWhereString( name ) ); ! } ! DoCollectionProperty( token, collPersister, name ); ! collectionName = name; ! collectionOwnerName = currentName; ! collectionTable = collPersister.QualifiedTableName; ! currentName = null; ! currentProperty = null; ! componentPath = null; ! } ! else ! { ! if( token != null ) ! { ! throw new QueryException( "dereferenced: " + currentProperty ); ! } ! } } } } } --- 187,308 ---- } ! if( propertyType.IsComponentType ) { ! DereferenceComponent( token ); } ! else if( propertyType.IsEntityType ) { ! DereferenceEntity( token, (EntityType) propertyType, q ); } + else if( propertyType.IsPersistentCollectionType ) + { + DereferenceCollection( token, ( (PersistentCollectionType) propertyType).Role, q ); + } + else if( token != null ) + { + throw new QueryException( "dereferenced: " + currentProperty ); + } + } + } + } + + /// <summary> + /// + /// </summary> + /// <param name="propertyName"></param> + /// <param name="propertyType"></param> + /// <param name="q"></param> + /// <remarks>NOTE: we avoid joining to the next table if the named property is just the foreign key value</remarks> + private void DereferenceEntity( string propertyName, EntityType propertyType, QueryTranslator q ) + { + //if its "id" + bool isIdShortcut = EntityID.Equals(propertyName) && !propertyType.IsUniqueKeyReference; + + //or its the id property name + string idPropertyName; + try + { + idPropertyName = propertyType.GetIdentifierOrUniqueKeyPropertyName( q.GetFactory() ); + } + catch (MappingException me) + { + throw new QueryException(me); + } + bool isNamedIdPropertyShortcut = idPropertyName != null && idPropertyName.Equals( propertyName ); + + if ( isIdShortcut || isNamedIdPropertyShortcut ) + { + // special shortcut for id properties, skip the join! + // this must only occur at the _end_ of a path expression + DereferenceProperty( propertyName ); + } + else + { + System.Type entityClass = propertyType.AssociatedClass; + String name = q.CreateNameFor( entityClass ); + q.AddType( name, entityClass ); + IQueryable memberPersister = q.GetPersister( entityClass ); + //String[] keyColNames = memberPersister.getIdentifierColumnNames(); + string[] keyColNames; + try + { + keyColNames = propertyType.GetReferencedColumns( q.GetFactory() ); + } + catch (MappingException me) + { + throw new QueryException(me); + } + AddJoin( memberPersister.TableName, name, keyColNames ); + if ( propertyType.IsOneToOne ) + { + oneToOneOwnerName = currentName; + } + currentName = name; + currentProperty = propertyName; + q.AddPathAliasAndJoin( path.Substring( 0, path.LastIndexOf( StringHelper.Dot ) ), name, join ); + componentPath = null; + //componentPath = new StringBuilder( ); + currentPropertyMapping = memberPersister; + } + } + + private void DereferenceProperty( string propertyName ) + { + if ( propertyName != null ) + { + if ( componentPath != null && componentPath.Length > 0 ) + { + componentPath += StringHelper.Dot; + //componentPath.Append( StringHelper.Dot ); } + componentPath += propertyName; + //componentPath.Append( propertyName ); + } + } + + private void DereferenceComponent( string propertyName ) + { + DereferenceProperty( propertyName ); + } + + private void DereferenceCollection(String propertyName, String role, QueryTranslator q) + { + collectionRole = role; + IQueryableCollection collPersister = q.GetCollectionPersister( role ); + string[] colNames = collPersister.KeyColumnNames; + string name = q.CreateNameForCollection(role); + AddJoin( collPersister.TableName, name, colNames ); + + if ( collPersister.HasWhere ) + { + join.AddCondition( collPersister.GetSQLWhereString( name ) ); } + collectionName = name; + collectionOwnerName = currentName; + currentName = name; + currentProperty = propertyName; + componentPath = null; + //componentPath = new StringBuilder(); + currentPropertyMapping = new CollectionPropertyMapping( collPersister ); } *************** *** 286,293 **** return EntityID; } else { ! return currentProperty + ! ( ( componentPath == null ) ? String.Empty : StringHelper.Dot + componentPath ); } } --- 315,325 ---- return EntityID; } + else if ( componentPath != null && componentPath.Length > 0 ) + { + return currentProperty + StringHelper.Dot + componentPath; + } else { ! return currentProperty; } } *************** *** 298,307 **** if( currentProperty == null ) { ! IClassPersister p = q.GetPersisterForName( currentName ); ! type = NHibernateUtil.Entity( p.MappedClass ); } else { ! type = GetPropertyType( q ); } } --- 330,338 ---- if( currentProperty == null ) { ! type = PropertyMapping.Type; } else { ! type = PropertyType; } } *************** *** 310,326 **** /// /// </summary> - /// <param name="q"></param> /// <returns></returns> ! protected IType GetPropertyType( QueryTranslator q ) { ! string path = PropertyPath; ! IType type = q.GetPersisterForName( currentName ).GetPropertyType( path ); ! ! if( type == null ) { ! throw new QueryException( "could not resolve property type: " + path ); ! } ! return type; } --- 341,359 ---- /// /// </summary> /// <returns></returns> ! protected IType PropertyType { ! get { ! string path = PropertyPath; ! IType type = PropertyMapping.ToType( PropertyPath ); ! if( type == null ) ! { ! throw new QueryException( "could not resolve property type: " + path ); ! } ! ! return type; ! } } *************** *** 328,342 **** /// /// </summary> - /// <param name="q"></param> /// <returns></returns> ! protected string[ ] CurrentColumns( QueryTranslator q ) { string path = PropertyPath; ! string[ ] columns = q.GetPersisterForName( currentName ).ToColumns( currentName, path ); ! if( columns == null ) { throw new QueryException( "could not resolve property columns: " + path ); } ! return columns; } --- 361,374 ---- /// /// </summary> /// <returns></returns> ! protected string[ ] CurrentColumns( ) { string path = PropertyPath; ! string[ ] propertyColumns = PropertyMapping.ToColumns( currentName, path ); ! if( propertyColumns == null ) { throw new QueryException( "could not resolve property columns: " + path ); } ! return propertyColumns; } *************** *** 349,355 **** collectionName = null; collectionRole = null; - collectionTable = null; - collectionElementColumns = null; - collectionElementType = null; componentPath = null; type = null; --- 381,384 ---- *************** *** 358,361 **** --- 387,391 ---- expectingCollectionIndex = false; continuation = false; + currentPropertyMapping = null; } *************** *** 369,373 **** { Reset( q ); ! path = String.Empty; } } --- 399,403 ---- { Reset( q ); ! path = null; } } *************** *** 380,458 **** { ignoreInitialJoin = false; ! if( IsCollectionValued ) { ! columns = collectionElementColumns; ! type = collectionElementType; } else { ! if( !continuation ) ! { ! IType propertyType = GetPropertyType( q ); ! if( propertyType != null && propertyType.IsPersistentCollectionType ) ! { ! collectionRole = ( ( PersistentCollectionType ) propertyType ).Role; ! collectionName = q.CreateNameForCollection( collectionRole ); ! } ! } ! if( collectionRole != null ) ! { ! //special case; expecting: [index] ! CollectionPersister memberPersister = q.GetCollectionPersister( collectionRole ); ! ! if( !memberPersister.HasIndex ) ! { ! throw new QueryException( "unindexed collection before []" ); ! } ! string[ ] indexCols = memberPersister.IndexColumnNames; ! if( indexCols.Length != 1 ) ! { ! throw new QueryException( "composite-index appears in []: " + path ); ! } ! string[ ] keyCols = memberPersister.KeyColumnNames; ! ! JoinFragment ojf = q.CreateJoinFragment( useThetaStyleJoin ); ! ojf.AddCrossJoin( memberPersister.QualifiedTableName, collectionName ); ! if( memberPersister.IsOneToMany ) ! { ! IQueryable persister = q.GetPersister( ( ( EntityType ) memberPersister.ElementType ).PersistentClass ); ! ojf.AddJoins( ! persister.FromJoinFragment( collectionName, true, false ), ! persister.WhereJoinFragment( collectionName, true, false ) ! ); ! } ! if( !continuation ) ! { ! AddJoin( memberPersister.QualifiedTableName, collectionName, keyCols, q ); ! } ! join.AddCondition( collectionName, indexCols, " = " ); ! string[ ] eltCols = memberPersister.ElementColumnNames; ! //if ( eltCols.Length!=1 ) throw new QueryException("composite-id collection element []"); ! CollectionElement elem = new CollectionElement(); ! elem.ElementColumns = StringHelper.Prefix( eltCols, collectionName + StringHelper.Dot ); ! elem.Type = memberPersister.ElementType; ! elem.IsOneToMany = memberPersister.IsOneToMany; ! elem.Alias = collectionName; ! elem.Join = join; ! collectionElements.Add( elem ); //addlast ! SetExpectingCollectionIndex(); ! q.AddCollection( collectionName, collectionRole ); ! q.AddJoin( collectionName, ojf ); ! } ! else ! { ! columns = CurrentColumns( q ); ! SetType( q ); ! } } ! //important!! ! continuation = false; } --- 410,477 ---- { ignoreInitialJoin = false; ! ! IType propertyType = PropertyType; ! if( propertyType != null && propertyType.IsPersistentCollectionType ) { ! collectionRole = ( ( PersistentCollectionType ) propertyType ).Role; ! collectionName = q.CreateNameForCollection( collectionRole ); ! PrepareForIndex( q ); } else { ! columns = CurrentColumns( ); ! SetType( q ); ! } ! //important!! ! continuation = false; ! } ! private void PrepareForIndex( QueryTranslator q ) ! { ! IQueryableCollection collPersister = q.GetCollectionPersister( collectionRole ); ! if( !collPersister.HasIndex ) ! { ! throw new QueryException( "unindexed collection before []" ); ! } ! string[ ] indexCols = collPersister.IndexColumnNames; ! if( indexCols.Length != 1 ) ! { ! throw new QueryException( "composite-index appears in []: " + path ); ! } ! string[ ] keyCols = collPersister.KeyColumnNames; ! JoinFragment ojf = q.CreateJoinFragment( useThetaStyleJoin ); ! ojf.AddCrossJoin( collPersister.TableName, collectionName ); ! ojf.AddFromFragmentString( join.ToFromFragmentString ); ! if( collPersister.IsOneToMany ) ! { ! IQueryable persister = (IQueryable) collPersister.ElementPersister; ! ojf.AddJoins( ! ( (IJoinable) persister).FromJoinFragment( collectionName, true, false ), ! ( (IJoinable) persister).WhereJoinFragment( collectionName, true, false ) ! ); ! } + if( !continuation ) + { + AddJoin( collPersister.TableName, collectionName, keyCols ); } + join.AddCondition( collectionName, indexCols, " = " ); ! string[ ] eltCols = collPersister.ElementColumnNames; ! ! CollectionElement elem = new CollectionElement(); ! elem.ElementColumns = StringHelper.Qualify( collectionName, eltCols ); ! elem.Type = collPersister.ElementType; ! elem.IsOneToMany = collPersister.IsOneToMany; ! elem.Alias = collectionName; ! elem.Join = join; ! collectionElements.Add( elem ); //addlast ! SetExpectingCollectionIndex(); + q.AddCollection( collectionName, collectionRole ); + q.AddJoin( collectionName, ojf ); } *************** *** 554,558 **** //TODO: refactor to .sql package return new StringBuilder( "SELECT " ) ! .Append( String.Join( ", ", collectionElementColumns ) ) .Append( " FROM " ) /*.Append(collectionTable) --- 573,577 ---- //TODO: refactor to .sql package return new StringBuilder( "SELECT " ) ! .Append( String.Join( ", ", CurrentColumns() ) ) .Append( " FROM " ) /*.Append(collectionTable) *************** *** 568,574 **** public bool IsCollectionValued { ! get { return collectionElementColumns != null; } } /// <summary> /// --- 587,595 ---- public bool IsCollectionValued { ! // TODO: Is there a better way ! get { return collectionName != null && !PropertyType.IsPersistentCollectionType; } } + /// <summary> /// *************** *** 587,592 **** public string AddFromAssociation( QueryTranslator q ) { ! q.AddFrom( currentName, join ); ! return currentName; } --- 608,620 ---- public string AddFromAssociation( QueryTranslator q ) { ! if ( IsCollectionValued ) ! { ! return AddFromCollection( q ); ! } ! else ! { ! q.AddFrom( currentName, join ); ! return currentName; ! } } *************** *** 598,633 **** public string AddFromCollection( QueryTranslator q ) { if( collectionElementType == null ) { ! throw new QueryException( ! "must specify 'elements' for collection valued property in from clause: " + path ! ); } ! if( !collectionElementType.IsEntityType ) { ! throw new QueryException( ! "collection of values in from clause: " + path ! ); ! } ! EntityType elemType = ( EntityType ) collectionElementType; ! System.Type clazz = elemType.PersistentClass; ! CollectionPersister persister = q.GetCollectionPersister( collectionRole ); ! string elementName; ! if( persister.IsOneToMany ) ! { ! elementName = collectionName; } else { ! q.AddCollection( collectionName, collectionRole ); ! IQueryable p = q.GetPersister( clazz ); ! elementName = q.CreateNameFor( clazz ); ! string[ ] keyColumnNames = p.IdentifierColumnNames; ! join.AddJoin( p.TableName, elementName, collectionElementColumns, keyColumnNames, joinType ); } - q.AddFrom( elementName, clazz, join ); - - return elementName; } --- 626,669 ---- public string AddFromCollection( QueryTranslator q ) { + IType collectionElementType = PropertyType; + if( collectionElementType == null ) { ! throw new QueryException( string.Format( "must specify 'elements' for collection valued property in from clause: {0}", path ) ); } ! if( collectionElementType.IsEntityType ) { ! // an association ! IQueryableCollection collectionPersister = q.GetCollectionPersister( collectionRole ); ! IQueryable entityPersister = (IQueryable) collectionPersister.ElementPersister; ! System.Type clazz = entityPersister.MappedClass; ! string[] collectionElementColumns = CurrentColumns(); ! ! string elementName; ! if ( collectionPersister.IsOneToMany ) ! { ! elementName = collectionName; ! // allow index() function ! q.DecoratePropertyMapping( elementName, collectionPersister ); ! } ! else ! { ! // many to many ! q.AddCollection( collectionName, collectionRole ); ! elementName = q.CreateNameFor( clazz ); ! string[] keyColumnNames = entityPersister.IdentifierColumnNames; ! join.AddJoin( entityPersister.TableName, elementName, collectionElementColumns, keyColumnNames, joinType ); ! } ! q.AddFrom( elementName, clazz, join ); ! currentPropertyMapping = new CollectionPropertyMapping( collectionPersister ); ! return elementName; } else { ! // collection of values ! q.AddFromCollection( collectionName, collectionRole, join ); ! return collectionName; } } *************** *** 645,735 **** /// <summary></summary> ! public string CollectionTable { ! get { return collectionTable; } } ! private void DoCollectionProperty( string token, CollectionPersister memberPersister, string name ) { ! if( token.Equals( CollectionElements ) ) ! { ! string[ ] cols = memberPersister.ElementColumnNames; ! collectionElementColumns = StringHelper.Prefix( cols, name + StringHelper.Dot ); ! collectionElementType = memberPersister.ElementType; ! } ! else if( token.Equals( CollectionIndices ) ) ! { ! if( !memberPersister.HasIndex ) ! { ! throw new QueryException( "unindexed collection before .indices" ); ! } ! string[ ] cols = memberPersister.IndexColumnNames; ! collectionElementColumns = StringHelper.Prefix( cols, name + StringHelper.Dot ); ! collectionElementType = memberPersister.IndexType; ! } ! else if( token.Equals( CollectionSize ) ) ! { ! collectionElementColumns = new string[ ] {"count(*)"}; ! collectionElementType = NHibernateUtil.Int32; ! } ! else if( token.Equals( CollectionMaxIndex ) ) ! { ! if( !memberPersister.HasIndex ) ! { ! throw new QueryException( "unindexed collection before .maxIndex" ); ! } ! string[ ] cols = memberPersister.IndexColumnNames; ! if( cols.Length != 1 ) ! { ! throw new QueryException( "composite collection index in maxIndex" ); ! } ! collectionElementColumns = new string[ ] {"max(" + cols[ 0 ] + StringHelper.ClosedParen}; ! collectionElementType = memberPersister.IndexType; ! } ! else if( token.Equals( CollectionMinIndex ) ) ! { ! if( !memberPersister.HasIndex ) ! { ! throw new QueryException( "unindexed collection before .minIndex" ); ! } ! string[ ] cols = memberPersister.IndexColumnNames; ! if( cols.Length != 1 ) ! { ! throw new QueryException( "composite collection index in minIndex" ); ! } ! collectionElementColumns = new string[ ] {"min(" + cols[ 0 ] + StringHelper.ClosedParen}; ! collectionElementType = memberPersister.IndexType; ! } ! else if( token.Equals( CollectionMaxElement ) ) ! { ! string[ ] cols = memberPersister.ElementColumnNames; ! if( cols.Length != 1 ) ! { ! throw new QueryException( "composite collection element in maxElement" ); ! } ! collectionElementColumns = new string[ ] {"max(" + cols[ 0 ] + StringHelper.ClosedParen}; ! collectionElementType = memberPersister.ElementType; ! } ! else if( token.Equals( CollectionMinElement ) ) { ! string[ ] cols = memberPersister.ElementColumnNames; ! if( cols.Length != 1 ) ! { ! throw new QueryException( "composite collection element in minElement" ); ! } ! collectionElementColumns = new string[ ] {"min(" + cols[ 0 ] + StringHelper.ClosedParen}; ! collectionElementType = memberPersister.ElementType; } else { ! throw new QueryException( "expecting 'elements' or 'indices' after " + path ); } } - - /// <summary></summary> - public String CollectionOwnerName - { - get { return collectionOwnerName; } - } } } \ No newline at end of file --- 681,717 ---- /// <summary></summary> ! public String CollectionOwnerName { ! get { return collectionOwnerName; } } ! /// <summary></summary> ! public string CurrentName { ! get { return currentName; } ! } ! ! /// <summary></summary> ! public string CurrentProperty ! { ! get { return currentProperty; } ! } ! ! /// <summary> ! /// ! /// </summary> ! /// <param name="q"></param> ! /// <param name="entityName"></param> ! public void Fetch( QueryTranslator q, string entityName ) ! { ! if ( IsCollectionValued ) { ! q.SetCollectionToFetch( CollectionRole, CollectionName, CollectionOwnerName, entityName ); } else { ! q.AddEntityToFetch( entityName, oneToOneOwnerName ); } } } } \ No newline at end of file Index: FromParser.cs =================================================================== RCS file: /cvsroot/nhibernate/nhibernate/src/NHibernate/Hql/FromParser.cs,v retrieving revision 1.12 retrieving revision 1.13 diff -C2 -d -r1.12 -r1.13 *** FromParser.cs 31 Dec 2004 18:23:05 -0000 1.12 --- FromParser.cs 1 Mar 2005 16:24:46 -0000 1.13 *************** *** 262,273 **** ParserHelper.Parse( peParser, q.Unalias( token ), ParserHelper.PathSeparators, q ); ! if( peParser.IsCollectionValued ) ! { ! entityName = peParser.AddFromCollection( q ); ! } ! else ! { ! entityName = peParser.AddFromAssociation( q ); ! } joinType = JoinType.None; peParser.JoinType = JoinType.InnerJoin; --- 262,267 ---- ParserHelper.Parse( peParser, q.Unalias( token ), ParserHelper.PathSeparators, q ); ! entityName = peParser.AddFromAssociation( q ); ! joinType = JoinType.None; peParser.JoinType = JoinType.InnerJoin; *************** *** 275,284 **** if( afterFetch ) { ! if( peParser.IsCollectionValued ) ! { ! q.SetCollectionToFetch( peParser.CollectionRole, peParser.CollectionName, peParser.CollectionOwnerName ); ! } ! q.AddEntityToFetch( entityName ); ! afterFetch = false; } --- 269,273 ---- if( afterFetch ) { ! peParser.Fetch( q, entityName ); afterFetch = false; } Index: SelectPathExpressionParser.cs =================================================================== RCS file: /cvsroot/nhibernate/nhibernate/src/NHibernate/Hql/SelectPathExpressionParser.cs,v retrieving revision 1.5 retrieving revision 1.6 diff -C2 -d -r1.5 -r1.6 *** SelectPathExpressionParser.cs 31 Dec 2004 18:22:14 -0000 1.5 --- SelectPathExpressionParser.cs 1 Mar 2005 16:24:46 -0000 1.6 *************** *** 10,14 **** public override void End( QueryTranslator q ) { ! if( currentProperty != null && !q.IsShallowQuery ) { // "finish off" the join --- 10,14 ---- public override void End( QueryTranslator q ) { ! if( CurrentProperty != null && !q.IsShallowQuery ) { // "finish off" the join *************** *** 28,32 **** public string SelectName { ! get { return currentName; } } } --- 28,32 ---- public string SelectName { ! get { return CurrentName; } } } Index: SelectParser.cs =================================================================== RCS file: /cvsroot/nhibernate/nhibernate/src/NHibernate/Hql/SelectParser.cs,v retrieving revision 1.11 retrieving revision 1.12 diff -C2 -d -r1.11 -r1.12 *** SelectParser.cs 17 Jan 2005 03:40:57 -0000 1.11 --- SelectParser.cs 1 Mar 2005 16:24:46 -0000 1.12 *************** *** 2,5 **** --- 2,6 ---- using System.Collections; using Iesi.Collections; + using NHibernate.Dialect; using NHibernate.Type; using NHibernate.Util; *************** *** 39,42 **** --- 40,44 ---- private bool afterNew; private bool insideNew; + private bool aggregateAddSelectScalar; private System.Type holderClass; *************** *** 145,150 **** } //special case } ! else if( aggregateFunctions.Contains( lctoken ) ) { if( !ready ) { --- 147,153 ---- } //special case } ! else if ( GetFunction( lctoken, q ) != null && token == q.Unalias( token ) ) { + // the name of an SQL function if( !ready ) { *************** *** 152,155 **** --- 155,159 ---- } aggregate = true; + aggregateAddSelectScalar = true; aggregateFuncTokenList.Insert( 0, lctoken ); ready = false; *************** *** 172,194 **** } } - } else if( aggregate ) { if( !ready ) { throw new QueryException( "( expected after aggregate function in SELECT" ); } ! ParserHelper.Parse( aggregatePathExpressionParser, q.Unalias( token ), ParserHelper.PathSeparators, q ); ! if( aggregatePathExpressionParser.IsCollectionValued ) { ! q.AddCollection( ! aggregatePathExpressionParser.CollectionName, ! aggregatePathExpressionParser.CollectionRole ); } - q.AppendScalarSelectToken( aggregatePathExpressionParser.WhereColumn ); - q.AddSelectScalar( AggregateType( aggregateFuncTokenList, aggregatePathExpressionParser.WhereColumnType, q ) ); - aggregatePathExpressionParser.AddAssociation( q ); } else --- 176,216 ---- } } } else if( aggregate ) { + bool constantToken = false; if( !ready ) { throw new QueryException( "( expected after aggregate function in SELECT" ); } ! try ! { ! ParserHelper.Parse( aggregatePathExpressionParser, q.Unalias( token ), ParserHelper.PathSeparators, q ); ! } ! catch (QueryException) ! { ! constantToken = true; ! } ! if( constantToken ) { ! q.AppendScalarSelectToken( token ); ! } ! else ! { ! if( aggregatePathExpressionParser.IsCollectionValued ) ! { ! q.AddCollection( ! aggregatePathExpressionParser.CollectionName, ! aggregatePathExpressionParser.CollectionRole ); ! } ! q.AppendScalarSelectToken( aggregatePathExpressionParser.WhereColumn ); ! if( aggregateAddSelectScalar ) ! { ! q.AddSelectScalar( AggregateType( aggregateFuncTokenList, aggregatePathExpressionParser.WhereColumnType, q ) ); ! aggregateAddSelectScalar = false; ! } ! aggregatePathExpressionParser.AddAssociation( q ); } } else *************** *** 226,232 **** public bool AggregateHasArgs( String funcToken, QueryTranslator q ) { ! IDictionary funcMap = q.AggregateFunctions; ! IQueryFunctionInfo funcInfo = ( IQueryFunctionInfo ) funcMap[ funcToken ]; ! return funcInfo.IsFunctionArgs; } --- 248,252 ---- public bool AggregateHasArgs( String funcToken, QueryTranslator q ) { ! return GetFunction( funcToken, q ).HasArguments; } *************** *** 237,245 **** /// <param name="q"></param> /// <returns></returns> ! public bool AggregateFuncNoArgsHasParenthesis( String funcToken, QueryTranslator q ) { ! IDictionary funcMap = q.AggregateFunctions; ! IQueryFunctionInfo funcInfo = ( IQueryFunctionInfo ) funcMap[ funcToken ]; ! return funcInfo.IsFunctionNoArgsUseParanthesis; } --- 257,263 ---- /// <param name="q"></param> /// <returns></returns> ! public bool AggregateFuncNoArgsHasParenthesis( string funcToken, QueryTranslator q ) { ! return GetFunction( funcToken, q ).HasParenthesesIfNoArguments; } *************** *** 253,257 **** public IType AggregateType( ArrayList funcTokenList, IType type, QueryTranslator q ) { - IDictionary funcMap = q.AggregateFunctions; IType argType = type; IType retType = type; --- 271,274 ---- *************** *** 259,269 **** { argType = retType; ! String funcToken = ( String ) funcTokenList[ i ]; ! IQueryFunctionInfo funcInfo = ( IQueryFunctionInfo ) funcMap[ funcToken ]; ! retType = funcInfo.QueryFunctionType( argType, q.factory ); } return retType; } /// <summary> /// --- 276,290 ---- { argType = retType; ! string funcToken = ( string ) funcTokenList[ i ]; ! retType = GetFunction( funcToken, q ).ReturnType( argType, q.factory ) ; } return retType; } + private ISQLFunction GetFunction( string name, QueryTranslator q ) + { + return (ISQLFunction) q.Functions[ name ]; + } + /// <summary> /// *************** *** 278,282 **** holderClass = null; aggregateFuncTokenList.Clear(); - aggregateFunctions = q.AggregateFunctions; } --- 299,302 ---- Index: WhereParser.cs =================================================================== RCS file: /cvsroot/nhibernate/nhibernate/src/NHibernate/Hql/WhereParser.cs,v retrieving revision 1.28 retrieving revision 1.29 diff -C2 -d -r1.28 -r1.29 *** WhereParser.cs 30 Jan 2005 19:39:12 -0000 1.28 --- WhereParser.cs 1 Mar 2005 16:24:46 -0000 1.29 *************** *** 25,29 **** private PathExpressionParser pathExpressionParser = new PathExpressionParser(); - private static ISet expressionTerminators = new HashedSet(); //tokens that close a sub expression private static ISet expressionOpeners = new HashedSet(); //tokens that open a sub expression --- 25,28 ---- *************** *** 177,181 **** { //ie. a many-to-many ! clazz = ( ( EntityType ) type ).PersistentClass; name = pathExpressionParser.ContinueFromManyToMany( clazz, element.ElementColumns, q ); } --- 176,180 ---- { //ie. a many-to-many ! clazz = ( ( EntityType ) type ).AssociatedClass; name = pathExpressionParser.ContinueFromManyToMany( clazz, element.ElementColumns, q ); } *************** *** 218,255 **** if( expectingPathContinuation ) { ! expectingPathContinuation = false; ! ! PathExpressionParser.CollectionElement element = pathExpressionParser.LastCollectionElement(); ! ! if( token.StartsWith( "." ) ) ! { // the path expression continues after a ] ! ! DoPathExpression( GetElementName( element, q ) + token, q ); // careful with this! ! ! AddToCurrentJoin( element ); ! return; //NOTE: EARLY EXIT! ! ! } ! else if( token.Equals( "[" ) ) ! { ! DoPathExpression( GetElementName( element, q ), q ); ! AddToCurrentJoin( element ); ! return; //NOTE: EARLY EXIT! ! } ! else ! { ! // the path expression ends at the ] ! if( element.ElementColumns.Length != 1 ) ! { ! throw new QueryException( "path expression ended in composite collection element" ); ! } ! AppendToken( q, element.ElementColumns[ 0 ] ); ! AddToCurrentJoin( element ); ! } ! } //Cope with a subselect - if( !inSubselect && ( lcToken.Equals( "select" ) || lcToken.Equals( "from" ) ) ) { --- 217,224 ---- if( expectingPathContinuation ) { ! if ( ContinuePathExpression( token, q ) ) return; } //Cope with a subselect if( !inSubselect && ( lcToken.Equals( "select" ) || lcToken.Equals( "from" ) ) ) { *************** *** 261,265 **** bracketsSinceSelect--; ! if( bracketsSinceSelect == - 1 ) { QueryTranslator subq = new QueryTranslator( d ); --- 230,234 ---- bracketsSinceSelect--; ! if( bracketsSinceSelect == -1 ) { QueryTranslator subq = new QueryTranslator( d ); *************** *** 313,317 **** //process a token, mapping OO path expressions to SQL expressions - DoToken( token, q ); --- 282,285 ---- *************** *** 324,330 **** //Cope with special cases of AND, NOT, ) - SpecialCasesAfter( lcToken ); - } --- 292,296 ---- *************** *** 375,380 **** joins.RemoveAt( joins.Count - 1 ); AppendToken( q, lastJoin.ToString() ); - - } else --- 341,344 ---- *************** *** 430,434 **** } - private void DoPathExpression( string token, QueryTranslator q ) { --- 394,397 ---- *************** *** 442,451 **** } pathExpressionParser.End( q ); if( pathExpressionParser.IsCollectionValued ) { ! OpenExpression( q, String.Empty ); AppendToken( q, pathExpressionParser.GetCollectionSubquery() ); ! q.AddIdentifierSpace( pathExpressionParser.CollectionTable ); ! CloseExpression( q, String.Empty ); } else --- 405,416 ---- } pathExpressionParser.End( q ); + if( pathExpressionParser.IsCollectionValued ) { ! OpenExpression( q, string.Empty ); AppendToken( q, pathExpressionParser.GetCollectionSubquery() ); ! CloseExpression( q, string.Empty ); ! // this is ugly here, but needed because its a subquery ! q.AddQuerySpace( q.GetCollectionPersister( pathExpressionParser.CollectionRole ).CollectionSpace ); } else *************** *** 494,501 **** else { ! IQueryable p = q.GetPersisterUsingImports( token ); ! if( p != null ) // the name of a class { ! AppendToken( q, p.DiscriminatorSQLString ); } else --- 459,466 ---- else { ! IQueryable persister = q.GetPersisterUsingImports( token ); ! if( persister != null ) // the name of a class { ! AppendToken( q, persister.DiscriminatorSQLString ); } else *************** *** 509,512 **** --- 474,479 ---- // don't even bother to do the lookups if the indexOfDot is not // greater than -1. This will save all the string modifications. + + // This allows us to resolve to the full type before obtaining the value e.g. FooStatus.OFF -> NHibernate.Model.FooStatus.OFF if( indexOfDot > -1 ) { *************** *** 531,534 **** --- 498,506 ---- } + if ( type == null ) + { + throw new QueryException( string.Format( "Could not determin the type of: {0}", token ) ); + } + try { *************** *** 623,626 **** --- 595,626 ---- } } + + private bool ContinuePathExpression( string token, QueryTranslator q ) + { + expectingPathContinuation = false; + + PathExpressionParser.CollectionElement element = pathExpressionParser.LastCollectionElement(); + + if( token.StartsWith( "." ) ) + { // the path expression continues after a ] + + DoPathExpression( GetElementName( element, q ) + token, q ); // careful with this! + + AddToCurrentJoin( element ); + return true; //NOTE: EARLY EXIT! + + } + else + { + // the path expression ends at the ] + if( element.ElementColumns.Length != 1 ) + { + throw new QueryException( "path expression ended in composite collection element" ); + } + AppendToken( q, element.ElementColumns[ 0 ] ); + AddToCurrentJoin( element ); + return false; + } + } } } \ No newline at end of file Index: FromPathExpressionParser.cs =================================================================== RCS file: /cvsroot/nhibernate/nhibernate/src/NHibernate/Hql/FromPathExpressionParser.cs,v retrieving revision 1.6 retrieving revision 1.7 diff -C2 -d -r1.6 -r1.7 *** FromPathExpressionParser.cs 31 Dec 2004 18:23:05 -0000 1.6 --- FromPathExpressionParser.cs 1 Mar 2005 16:24:46 -0000 1.7 *************** *** 16,20 **** if( !IsCollectionValued ) { ! IType type = GetPropertyType( q ); if( type.IsEntityType ) { --- 16,20 ---- if( !IsCollectionValued ) { ! IType type = PropertyType; if( type.IsEntityType ) { Index: QueryTranslator.cs =================================================================== RCS file: /cvsroot/nhibernate/nhibernate/src/NHibernate/Hql/QueryTranslator.cs,v retrieving revision 1.54 retrieving revision 1.55 diff -C2 -d -r1.54 -r1.55 *** QueryTranslator.cs 14 Feb 2005 03:27:39 -0000 1.54 --- QueryTranslator.cs 1 Mar 2005 16:24:46 -0000 1.55 *************** *** 22,81 **** public class QueryTranslator : Loader.Loader { ! private static readonly ILog log = LogManager.GetLogger( typeof( QueryTranslator ) ); private IDictionary typeMap = new SequencedHashMap(); private IDictionary collections = new SequencedHashMap(); ! private IList returnTypes = new ArrayList(); private IList fromTypes = new ArrayList(); private IList scalarTypes = new ArrayList(); private IDictionary namedParameters = new Hashtable(); [...994 lines suppressed...] + /// <summary></summary> protected bool Compiled *************** *** 1537,1543 **** /// <summary></summary> ! public IDictionary AggregateFunctions { ! get { return factory.Dialect.AggregateFunctions; } } --- 1625,1631 ---- /// <summary></summary> ! public IDictionary Functions { ! get { return factory.Dialect.Functions; } } Index: OrderByParser.cs =================================================================== RCS file: /cvsroot/nhibernate/nhibernate/src/NHibernate/Hql/OrderByParser.cs,v retrieving revision 1.6 retrieving revision 1.7 diff -C2 -d -r1.6 -r1.7 *** OrderByParser.cs 31 Dec 2004 18:22:33 -0000 1.6 --- OrderByParser.cs 1 Mar 2005 16:24:46 -0000 1.7 *************** *** 31,34 **** --- 31,42 ---- pathExpressionParser.AddAssociation( q ); } + else if ( token.StartsWith( ParserHelper.HqlVariablePrefix ) ) + { + q.AddNamedParameter( token.Substring( 1 ) ); + // this is only a temporary parameter to help with the parsing of hql - + // when the type becomes known then this will be converted to its real + // parameter type. + //AppendToken( q, new SqlString( new object[ ] {new Parameter( StringHelper.SqlParameter )} ) ); + } else { Index: FilterTranslator.cs =================================================================== RCS file: /cvsroot/nhibernate/nhibernate/src/NHibernate/Hql/FilterTranslator.cs,v retrieving revision 1.9 retrieving revision 1.10 diff -C2 -d -r1.9 -r1.10 *** FilterTranslator.cs 31 Dec 2004 18:23:33 -0000 1.9 --- FilterTranslator.cs 1 Mar 2005 16:24:46 -0000 1.10 *************** *** 26,30 **** { this.factory = factory; // yick! ! AddFromCollection( "this", collectionRole ); base.Compile( factory, queryString, replacements, scalar ); } --- 26,30 ---- { this.factory = factory; // yick! ! AddFromAssociation( "this", collectionRole ); base.Compile( factory, queryString, replacements, scalar ); } |
From: Paul H. <pha...@us...> - 2005-03-01 16:25:35
|
Update of /cvsroot/nhibernate/nhibernate/src/NHibernate/Loader In directory sc8-pr-cvs1.sourceforge.net:/tmp/cvs-serv5548/nhibernate/src/NHibernate/Loader Modified Files: AbstractEntityLoader.cs CollectionLoader.cs EntityLoader.cs Loader.cs OneToManyLoader.cs OuterJoinLoader.cs SimpleEntityLoader.cs Added Files: SqlLoader.cs Log Message: Various refactorings on the way to 2.1 querying capability Index: AbstractEntityLoader.cs =================================================================== RCS file: /cvsroot/nhibernate/nhibernate/src/NHibernate/Loader/AbstractEntityLoader.cs,v retrieving revision 1.13 retrieving revision 1.14 diff -C2 -d -r1.13 -r1.14 *** AbstractEntityLoader.cs 31 Dec 2004 20:57:25 -0000 1.13 --- AbstractEntityLoader.cs 1 Mar 2005 16:24:47 -0000 1.14 *************** *** 1,4 **** --- 1,5 ---- using System; using System.Collections; + using NHibernate.Collection; using NHibernate.Engine; using NHibernate.Persister; *************** *** 12,16 **** --- 13,20 ---- { private ILoadable persister; + private ICollectionPersister collectionPersister; + private int collectionOwner; private string alias; + private string[] aliases; /// <summary> *************** *** 174,177 **** --- 178,261 ---- } + /// <summary> + /// + /// </summary> + /// <param name="associations"></param> + protected void InitClassPersisters( IList associations ) + { + int joins = CountClassPersisters( associations ); + + collectionOwner = -1; // if no collection found + classPersisters = new ILoadable[ joins + 1 ]; + owners = new int[ joins + 1 ]; + aliases = new string[ joins + 1 ]; + LockModeArray = CreateLockModeArray( joins + 1, LockMode.None ); + int i = 0; + foreach( OuterJoinableAssociation oj in associations ) + { + object subpersister = oj.Joinable; + if ( subpersister is ILoadable ) + { + classPersisters[ i ] = (ILoadable) subpersister; + owners[ i ] = ToOwner( oj, joins, oj.IsOneToOne ); + aliases[ i ] = oj.Subalias; + if ( oj.JoinType == JoinType.InnerJoin ) + { + AddAllToPropertySpaces( classPersisters[ i ].PropertySpaces ); + } + i++; + } + else + { + IQueryableCollection collPersister = (IQueryableCollection) subpersister; + // TODO: ?? suppress initialization of collections with a where condition + if ( oj.JoinType == JoinType.LeftOuterJoin ) + { + collectionPersister = collPersister; + collectionOwner = ToOwner( oj, joins, true ); + } + else + { + AddToPropertySpaces( collPersister.CollectionSpace ) ; + } + + if ( collPersister.IsOneToMany ) + { + classPersisters[ i ] = (ILoadable) collPersister.ElementPersister; + aliases[ i ] = oj.Subalias; + i++; + } + } + } + classPersisters[ joins ] = persister; + owners[ joins ] = -1; + aliases[ joins ] = alias; + + if ( ArrayHelper.IsAllNegative( owners ) ) + { + owners = null; + } + } + + /// <summary> + /// + /// </summary> + /// <param name="spaces"></param> + protected void AddAllToPropertySpaces( object[] spaces ) + { + for ( int i = 0; i < spaces.Length; i++ ) + { + AddToPropertySpaces( spaces[ i ] ); + } + } + + /// <summary> + /// + /// </summary> + /// <param name="space"></param> + protected void AddToPropertySpaces( object space ) + { + throw new NotSupportedException( "only criteria queries need to autoflush" ); + } } } \ No newline at end of file Index: OneToManyLoader.cs =================================================================== RCS file: /cvsroot/nhibernate/nhibernate/src/NHibernate/Loader/OneToManyLoader.cs,v retrieving revision 1.13 retrieving revision 1.14 diff -C2 -d -r1.13 -r1.14 *** OneToManyLoader.cs 31 Dec 2004 20:57:56 -0000 1.13 --- OneToManyLoader.cs 1 Mar 2005 16:24:48 -0000 1.14 *************** *** 15,19 **** public class OneToManyLoader : OuterJoinLoader, ICollectionInitializer { ! private CollectionPersister collectionPersister; private IType idType; --- 15,19 ---- public class OneToManyLoader : OuterJoinLoader, ICollectionInitializer { ! private IQueryableCollection collectionPersister; private IType idType; *************** *** 21,35 **** /// /// </summary> ! /// <param name="mappingDefault"></param> ! /// <param name="path"></param> ! /// <param name="table"></param> ! /// <param name="foreignKeyColumns"></param> ! /// <returns></returns> ! protected override bool EnableJoinedFetch( bool mappingDefault, string path, string table, string[ ] foreignKeyColumns ) { - return mappingDefault && ( - !table.Equals( collectionPersister.QualifiedTableName ) || - !ArrayHelper.Equals( foreignKeyColumns, collectionPersister.KeyColumnNames ) - ); } --- 21,28 ---- /// /// </summary> ! /// <param name="collPersister"></param> ! /// <param name="factory"></param> ! public OneToManyLoader( IQueryableCollection collPersister, ISessionFactoryImplementor factory ) : this( collPersister, 1, factory ) { } *************** *** 38,51 **** /// </summary> /// <param name="collPersister"></param> /// <param name="factory"></param> ! public OneToManyLoader( CollectionPersister collPersister, ISessionFactoryImplementor factory ) : base( factory.Dialect ) { collectionPersister = collPersister; idType = collectionPersister.KeyType; ! ILoadable persister = ( ILoadable ) factory.GetPersister( ! ( ( EntityType ) collPersister.ElementType ).PersistentClass ); ! string alias = ToAlias( collectionPersister.QualifiedTableName, 0 ); SqlString whereSqlString = null; --- 31,45 ---- /// </summary> /// <param name="collPersister"></param> + /// <param name="batchSize"></param> /// <param name="factory"></param> ! public OneToManyLoader( IQueryableCollection collPersister, int batchSize, ISessionFactoryImplementor factory ) : base( factory.Dialect ) { collectionPersister = collPersister; idType = collectionPersister.KeyType; ! //ILoadable persister = ( ILoadable ) factory.GetPersister( ( ( EntityType ) collPersister.ElementType ).AssociatedClass ); ! ILoadable persister = ( ILoadable ) collPersister.ElementPersister; ! string alias = ToAlias( collectionPersister.TableName, 0 ); SqlString whereSqlString = null; *************** *** 65,69 **** } - JoinFragment ojf = OuterJoins( associations ); --- 59,62 ---- *************** *** 71,75 **** selectBuilder.SetSelectClause( ! collectionPersister.SelectClauseFragment( alias ) + ( joins == 0 ? String.Empty : "," + SelectString( associations ) ) + ", " + --- 64,68 ---- selectBuilder.SetSelectClause( ! collectionPersister.SelectFragment( alias ).ToString() + ( joins == 0 ? String.Empty : "," + SelectString( associations ) ) + ", " + *************** *** 116,121 **** } /// <summary></summary> ! protected override CollectionPersister CollectionPersister { get { return collectionPersister; } --- 109,130 ---- } + /// <summary> + /// + /// </summary> + /// <param name="mappingDefault"></param> + /// <param name="path"></param> + /// <param name="table"></param> + /// <param name="foreignKeyColumns"></param> + /// <returns></returns> + protected override bool EnableJoinedFetch( bool mappingDefault, string path, string table, string[ ] foreignKeyColumns ) + { + return mappingDefault && ( + !table.Equals( collectionPersister.TableName ) || + !ArrayHelper.Equals( foreignKeyColumns, collectionPersister.KeyColumnNames ) + ); + } + /// <summary></summary> ! protected override ICollectionPersister CollectionPersister { get { return collectionPersister; } Index: CollectionLoader.cs =================================================================== RCS file: /cvsroot/nhibernate/nhibernate/src/NHibernate/Loader/CollectionLoader.cs,v retrieving revision 1.12 retrieving revision 1.13 diff -C2 -d -r1.12 -r1.13 *** CollectionLoader.cs 31 Dec 2004 20:57:25 -0000 1.12 --- CollectionLoader.cs 1 Mar 2005 16:24:48 -0000 1.13 *************** *** 15,19 **** public class CollectionLoader : OuterJoinLoader, ICollectionInitializer { ! private CollectionPersister collectionPersister; private IType idType; --- 15,19 ---- public class CollectionLoader : OuterJoinLoader, ICollectionInitializer { ! private ICollectionPersister collectionPersister; private IType idType; *************** *** 23,31 **** /// <param name="persister"></param> /// <param name="factory"></param> ! public CollectionLoader( CollectionPersister persister, ISessionFactoryImplementor factory ) : base( factory.Dialect ) { idType = persister.KeyType; ! string alias = ToAlias( persister.QualifiedTableName, 0 ); //TODO: H2.0.3 the whereString is appended with the " and " - I don't think --- 23,31 ---- /// <param name="persister"></param> /// <param name="factory"></param> ! public CollectionLoader( IQueryableCollection persister, ISessionFactoryImplementor factory ) : base( factory.Dialect ) { idType = persister.KeyType; ! string alias = ToAlias( persister.TableName, 0 ); //TODO: H2.0.3 the whereString is appended with the " and " - I don't think *************** *** 51,58 **** SqlSelectBuilder selectBuilder = new SqlSelectBuilder( factory ); selectBuilder.SetSelectClause( ! persister.SelectClauseFragment( alias ) + ( joins == 0 ? String.Empty : ", " + SelectString( associations ) ) ) ! .SetFromClause( persister.QualifiedTableName, alias ) .SetWhereClause( alias, persister.KeyColumnNames, persister.KeyType ) .SetOuterJoins( ojf.ToFromFragmentString, ojf.ToWhereFragmentString ); --- 51,58 ---- SqlSelectBuilder selectBuilder = new SqlSelectBuilder( factory ); selectBuilder.SetSelectClause( ! persister.SelectFragment( alias ).ToString() + ( joins == 0 ? String.Empty : ", " + SelectString( associations ) ) ) ! .SetFromClause( persister.TableName, alias ) .SetWhereClause( alias, persister.KeyColumnNames, persister.KeyType ) .SetOuterJoins( ojf.ToFromFragmentString, ojf.ToWhereFragmentString ); *************** *** 83,87 **** /// <summary></summary> ! protected override CollectionPersister CollectionPersister { get { return collectionPersister; } --- 83,87 ---- /// <summary></summary> ! protected override ICollectionPersister CollectionPersister { get { return collectionPersister; } --- NEW FILE: SqlLoader.cs --- using System; using System.Data; using System.Collections; using System.Text; using Iesi.Collections; using NHibernate.Engine; using NHibernate.Persister; using NHibernate.SqlCommand; using NHibernate.Hql; using NHibernate.Type; using NHibernate.Util; namespace NHibernate.Loader { /// <summary> /// Summary description for SqlLoader. /// </summary> public class SqlLoader : OuterJoinLoader { private int parameterCount = 0; private IDictionary namedParameters = new Hashtable(4); private string sqlQuery; private IDictionary alias2Persister; private string[] aliases; private ISet querySpaces = new HashedSet(); //private IType[] resultTypes; #region Constructors /// <summary> /// /// </summary> /// <param name="aliases"></param> /// <param name="persisters"></param> /// <param name="factory"></param> /// <param name="sqlQuery"></param> /// <param name="additionalQuerySpaces"></param> public SqlLoader( string[] aliases, ISqlLoadable[] persisters, ISessionFactoryImplementor factory, string sqlQuery, ICollection additionalQuerySpaces) : base( factory.Dialect ) { this.sqlQuery = sqlQuery; this.aliases = aliases; alias2Persister = new Hashtable(); IList resultTypeList = new ArrayList(); for (int i = 0; i < persisters.Length; i++ ) { ISqlLoadable persister = persisters[i]; alias2Persister.Add( aliases[i], persister ); // TODO: Does not consider any other tables referenced in the query querySpaces.AddAll( persister.PropertySpaces ) ; resultTypeList.Add( persister.Type ); } if ( additionalQuerySpaces != null ) querySpaces.AddAll( additionalQuerySpaces ); //resultTypes = (IType[]) resultTypeList.ToArray() ; RenderStatement( persisters ) ; PostInstantiate(); } #endregion #region Property methods /// <summary> /// /// </summary> public ISet QuerySpaces { get { return querySpaces; } } #endregion #region Private methods private void RenderStatement( ILoadable[] persisters ) { int loadables = persisters.Length; Persisters = persisters; Suffixes = GenerateSuffixes( loadables ) ; LockModeArray = CreateLockModeArray( loadables, LockMode.None ); sqlQuery = SubstituteParams( SubstituteBrackets( sqlQuery ) ); } private string SubstituteParams(string sqlQuery) { string sqlString = sqlQuery; StringBuilder result = new StringBuilder(); int left, right; for ( int curr = 0; curr < sqlString.Length; curr = right + 1 ) { if ( ( left = sqlString.IndexOf( ParserHelper.HqlVariablePrefix, curr ) ) < 0 ) { result.Append( sqlString.Substring( curr ) ); break; } result.Append( sqlString.Substring( curr, left ) ); // Find the first place of a HqlSeparator character right = sqlString.IndexOfAny( ParserHelper.HqlSeparators.ToCharArray(), left + 1 ); // Did we find one? bool foundSeparator = right > 0; int chopLocation = -1; if ( right < 0 ) { chopLocation = sqlString.Length; } else { chopLocation = right; } string param = sqlString.Substring( left + 1, chopLocation ); AddNamedParameter( param ); result.Append( "?" ); if ( foundSeparator ) { result.Append( sqlString.Substring( right, 1 ) ); } else { break; } } return result.ToString(); } private int PersisterIndex( string aliasName ) { for ( int i = 0; i < aliases.Length; i++ ) { if ( aliasName == aliases[i] ) { return i; } } return -1; } private ISqlLoadable GetPersisterByResultAlias( string aliasName ) { // NB This return the dictionary object I think not the value. return (ISqlLoadable) alias2Persister[ aliasName ]; } #endregion #region Protected methods /// <summary> /// Bind named parameters to the <c>IDbCommand</c> /// </summary> /// <param name="st">The <see cref="IDbCommand"/> that contains the parameters.</param> /// <param name="namedParams">The named parameters (key) and the values to set.</param> /// <param name="session">The <see cref="ISession"/> this Loader is using.</param> /// <param name="start"></param> /// <remarks> /// Assumes that all types are of span 1 /// </remarks> protected override int BindNamedParameters( IDbCommand st, IDictionary namedParams, int start, ISessionImplementor session ) { if ( namedParameters != null ) { int result = 0; // Assumes that types are all of span 1 foreach( DictionaryEntry de in namedParams ) { string name = (string) de.Key; TypedValue typedval = (TypedValue) de.Value; IType type = typedval.Type; int[] locs = GetNamedParameterLocs( name ); for ( int i = 0; i < locs.Length; i++ ) { type.NullSafeSet( st, typedval.Value, locs[i] + start, session ); } result += locs.Length; } return result; } else return 0; } /// <summary> /// /// </summary> /// <param name="row"></param> /// <param name="rs"></param> /// <param name="session"></param> /// <returns></returns> protected override object GetResultColumnOrRow( object[ ] row, IDataReader rs, ISessionImplementor session ) { if ( Persisters.Length == 1 ) return row[ row.Length - 1 ]; else return row; } /// <summary> /// /// </summary> /// <param name="name"></param> /// <returns></returns> protected int[] GetNamedParameterLocs( string name ) { object o = namedParameters[ name ]; if ( o == null ) { throw new QueryException( String.Format( "Named parameter does not appear in query: {0} ", name ) ); } if ( o is int) { return new int[] { (int) o }; } else { return ArrayHelper.ToIntArray( (IList) o ); } } #endregion #region Public methods /// <summary> /// /// </summary> /// <param name="session"></param> /// <param name="queryParameters"></param> /// <returns></returns> public IList List( ISessionImplementor session, QueryParameters queryParameters ) { // TODO: Uncomment once //return List( session, queryParameters, querySpaces, resultTypes ) ; return null ; } // Inspired by the parsing done in TJDO // TODO: Should record how many properties we have referred to - and throw exception if we don't get them all aka AbstractQueryImpl /// <summary> /// /// </summary> /// <param name="sqlQuery"></param> /// <returns></returns> public string SubstituteBrackets( string sqlQuery ) { string sqlString = sqlQuery; StringBuilder result = new StringBuilder(); int left, right; // replace {....} with corresponding column aliases for (int curr = 0; curr < sqlString.Length; curr = right + 1) { if ( (left = sqlString.IndexOf( '{', curr ) ) < 0 ) { result.Append( sqlString.Substring( curr ) ) ; break; } result.Append( sqlString.Substring( curr, left ) ); if ( ( right = sqlString.IndexOf( '}', left + 1 ) ) < 0 ) { throw new QueryException( "Unmatched braces for alias path" ); } string aliasPath = sqlString.Substring( left + 1, right ); int firstDot = aliasPath.IndexOf( '.' ); string aliasName = firstDot == 1 ? aliasPath : aliasPath.Substring( 0, firstDot ) ; ISqlLoadable currentPersister = GetPersisterByResultAlias( aliasName ) ; if ( currentPersister == null ) { // TODO: Do we throw this or pass through as per Hibernate to allow for escape sequences as per HB-898 throw new QueryException( string.Format( "Alias [{0}] does not correspond to any of the supplied return aliases = {1}", aliasName, aliases ) ); //result.Append( "{" + aliasPath + "}" ); //continue; } int currentPersisterIndex = PersisterIndex( aliasName ); if ( firstDot == -1 ) { result.Append( aliasPath ) ; } else { if ( aliasName != aliases[ currentPersisterIndex ] ) { throw new QueryException( string.Format( "Alias [{0}] does not correspond to return alias {1}.", aliasName, aliases[ currentPersisterIndex ] ) ); } string propertyName = aliasPath.Substring( firstDot + 1 ); if ( "*".Equals( propertyName ) ) { result.Append( currentPersister.SelectFragment( aliasName, Suffixes[ currentPersisterIndex ] ) ); } else { // Here it would be nice just to be able to do result.Append( getAliasFor( currentPersister, propertyName )) // but that requires more exposure of the internal maps of the persister... // but it should be possible as propertyname should be unique for all persisters string[] columnAliases; /* if ( AbstractEntityPersister.ENTITY_CLASS.Equals( propertyName ) { columnAliases = new string[1]; columnAliases[0] = currentPersister.GetDiscriminatorAlias( suffixes[ currentPersisterIndex ] ) ; } else */ columnAliases = currentPersister.GetSubclassPropertyColumnAliases( propertyName, Suffixes[ currentPersisterIndex ] ); if ( columnAliases == null || columnAliases.Length == 0 ) { throw new QueryException( string.Format( "No column name found for property [{0}]", propertyName ) ); } if ( columnAliases.Length != 1 ) { throw new QueryException( string.Format( "SQL queries only support properties mapped to a single column. Property [{0}] is mapped to {1} columns.", propertyName, columnAliases.Length ) ); } result.Append( columnAliases[ 0 ] ) ; } } } // Possibly handle :something parameters for the query? return result.ToString(); } // NAMED PARAMETER SUPPORT, copy/pasted from QueryTranslator internal void AddNamedParameter( string name ) { // want the param index to start at 0 instead of 1 //int loc = ++parameterCount; int loc = parameterCount++; object o = namedParameters[ name ]; if( o == null ) { namedParameters.Add( name, loc ); } else if( o is int ) { ArrayList list = new ArrayList( 4 ); list.Add( o ); list.Add( loc ); namedParameters[ name ] = list; } else { ( ( ArrayList ) o ).Add( loc ); } } #endregion } } Index: OuterJoinLoader.cs =================================================================== RCS file: /cvsroot/nhibernate/nhibernate/src/NHibernate/Loader/OuterJoinLoader.cs,v retrieving revision 1.17 retrieving revision 1.18 diff -C2 -d -r1.17 -r1.18 *** OuterJoinLoader.cs 31 Dec 2004 20:57:56 -0000 1.17 --- OuterJoinLoader.cs 1 Mar 2005 16:24:48 -0000 1.18 *************** *** 3,6 **** --- 3,7 ---- using System.Text; using NHibernate.Collection; + using NHibernate.Dialect; using NHibernate.Engine; using NHibernate.Persister; *************** *** 12,16 **** { /// <summary></summary> ! public enum OuterJoinLoaderType { /// <summary></summary> --- 13,17 ---- { /// <summary></summary> ! public enum OuterJoinFetchStrategy { /// <summary></summary> *************** *** 37,45 **** protected static readonly ILoadable[ ] NoPersisters = new ILoadable[0]; ! private ILoadable[ ] classPersisters; private LockMode[ ] lockModeArray; private SqlString sqlString; private string[ ] suffixes; /// <summary> --- 38,52 ---- protected static readonly ILoadable[ ] NoPersisters = new ILoadable[0]; ! /// <summary></summary> ! protected ILoadable[ ] classPersisters; ! private LockMode[ ] lockModeArray; + /// <summary></summary> + protected int[] owners; + private SqlString sqlString; private string[ ] suffixes; + private Dialect.Dialect dialect; /// <summary> *************** *** 68,76 **** { /// <summary></summary> ! public ILoadable Subpersister; /// <summary></summary> public string[ ] ForeignKeyColumns; /// <summary></summary> public string Subalias; } --- 75,95 ---- { /// <summary></summary> ! public IJoinable Joinable; ! /// <summary></summary> ! public IQueryable Subpersister; /// <summary></summary> public string[ ] ForeignKeyColumns; /// <summary></summary> public string Subalias; + /// <summary></summary> + public string[] PrimaryKeyColumns; + /// <summary></summary> + public string TableName; + /// <summary></summary> + public int Owner; + /// <summary></summary> + public JoinType JoinType; + /// <summary></summary> + public bool IsOneToOne; } *************** *** 96,100 **** /// <param name="session"></param> /// <returns></returns> ! protected IList WalkCollectionTree( CollectionPersister persister, string alias, ISessionFactoryImplementor session ) { IList associations = new ArrayList(); --- 115,119 ---- /// <param name="session"></param> /// <returns></returns> ! protected IList WalkCollectionTree( IQueryableCollection persister, string alias, ISessionFactoryImplementor session ) { IList associations = new ArrayList(); *************** *** 107,111 **** EntityType etype = ( EntityType ) type; // we do NOT need to call this.EnableJoinedFetch() here ! if( AutoEager( persister.EnableJoinFetch, etype, session ) ) { string[ ] columns = StringHelper.Prefix( persister.ElementColumnNames, alias + StringHelper.Dot ); --- 126,130 ---- EntityType etype = ( EntityType ) type; // we do NOT need to call this.EnableJoinedFetch() here ! if( AutoEager( persister.EnableJoinedFetch, etype, session ) ) { string[ ] columns = StringHelper.Prefix( persister.ElementColumnNames, alias + StringHelper.Dot ); *************** *** 143,147 **** ISessionFactoryImplementor session ) { ! ILoadable subpersister = ( ILoadable ) session.GetPersister( type.PersistentClass ); // to avoid navigating back up bidirectional associations (and circularities) --- 162,166 ---- ISessionFactoryImplementor session ) { ! IQueryable subpersister = ( IQueryable ) session.GetPersister( type.AssociatedClass ); // to avoid navigating back up bidirectional associations (and circularities) *************** *** 353,357 **** IAbstractComponentType act, string[ ] cols, ! CollectionPersister persister, string alias, IList associations, --- 372,376 ---- IAbstractComponentType act, string[ ] cols, ! IQueryableCollection persister, string alias, IList associations, *************** *** 379,383 **** string subpath = SubPath( path, propertyNames[ i ] ); bool autoEager = AutoEager( act.EnableJoinedFetch( i ), etype, session ); ! bool enable = EnableJoinedFetch( autoEager, subpath, persister.QualifiedTableName, range ); if( enable ) --- 398,402 ---- string subpath = SubPath( path, propertyNames[ i ] ); bool autoEager = AutoEager( act.EnableJoinedFetch( i ), etype, session ); ! bool enable = EnableJoinedFetch( autoEager, subpath, persister.TableName, range ); if( enable ) *************** *** 414,428 **** /// <param name="session"></param> /// <returns></returns> ! protected bool AutoEager( OuterJoinLoaderType config, EntityType type, ISessionFactoryImplementor session ) { ! if( config == OuterJoinLoaderType.Eager ) { return true; } ! if( config == OuterJoinLoaderType.Lazy ) { return false; } ! IClassPersister persister = session.GetPersister( type.PersistentClass ); return !persister.HasProxy || ( type.IsOneToOne && ( ( OneToOneType ) type ).IsNullable ); } --- 433,447 ---- /// <param name="session"></param> /// <returns></returns> ! protected bool AutoEager( OuterJoinFetchStrategy config, EntityType type, ISessionFactoryImplementor session ) { ! if( config == OuterJoinFetchStrategy.Eager ) { return true; } ! if( config == OuterJoinFetchStrategy.Lazy ) { return false; } ! IClassPersister persister = session.GetPersister( type.AssociatedClass ); return !persister.HasProxy || ( type.IsOneToOne && ( ( OneToOneType ) type ).IsNullable ); } *************** *** 524,528 **** /// <summary></summary> ! protected override CollectionPersister CollectionPersister { get { return null; } --- 543,547 ---- /// <summary></summary> ! protected override ICollectionPersister CollectionPersister { get { return null; } *************** *** 548,553 **** outerjoin.AddJoins( ! oj.Subpersister.FromJoinFragment( oj.Subalias, false, true ), ! oj.Subpersister.WhereJoinFragment( oj.Subalias, false, true ) ); } --- 567,572 ---- outerjoin.AddJoins( ! ( (IJoinable) oj.Subpersister).FromJoinFragment( oj.Subalias, false, true ), ! ( (IJoinable) oj.Subpersister).WhereJoinFragment( oj.Subalias, false, true ) ); } *************** *** 593,596 **** --- 612,652 ---- } + /// <summary> + /// + /// </summary> + /// <param name="associations"></param> + /// <returns></returns> + protected static int CountClassPersisters( IList associations ) + { + int result = 0; + foreach ( OuterJoinableAssociation oj in associations ) + { + if ( oj.Joinable.ConsumesAlias() ) + { + result++; + } + } + + return result; + } + + /// <summary> + /// + /// </summary> + /// <param name="oj"></param> + /// <param name="joins"></param> + /// <param name="dontIgnore"></param> + /// <returns></returns> + protected int ToOwner( OuterJoinableAssociation oj, int joins, bool dontIgnore ) + { + if ( dontIgnore ) + { + return oj.Owner == -1 ? joins : oj.Owner; //TODO: UGLY AS SIN! + } + else + { + return -1; + } + } } } \ No newline at end of file Index: SimpleEntityLoader.cs =================================================================== RCS file: /cvsroot/nhibernate/nhibernate/src/NHibernate/Loader/SimpleEntityLoader.cs,v retrieving revision 1.10 retrieving revision 1.11 diff -C2 -d -r1.10 -r1.11 *** SimpleEntityLoader.cs 31 Dec 2004 20:57:56 -0000 1.10 --- SimpleEntityLoader.cs 1 Mar 2005 16:24:48 -0000 1.11 *************** *** 20,25 **** private LockMode[ ] lockMode; - private string[ ] NoSuffix = new string[ ] {String.Empty}; - /// <summary> /// --- 20,23 ---- *************** *** 53,57 **** /// <summary></summary> ! protected override CollectionPersister CollectionPersister { get { return null; } --- 51,55 ---- /// <summary></summary> ! protected override ICollectionPersister CollectionPersister { get { return null; } Index: Loader.cs =================================================================== RCS file: /cvsroot/nhibernate/nhibernate/src/NHibernate/Loader/Loader.cs,v retrieving revision 1.47 retrieving revision 1.48 diff -C2 -d -r1.47 -r1.48 *** Loader.cs 16 Feb 2005 20:14:38 -0000 1.47 --- Loader.cs 1 Mar 2005 16:24:48 -0000 1.48 *************** *** 3,6 **** --- 3,7 ---- using System.Data; using log4net; + using Iesi.Collections; using NHibernate.Collection; using NHibernate.Engine; *************** *** 25,28 **** --- 26,32 ---- private Dialect.Dialect dialect; + /// <summary></summary> + protected static readonly string[] NoSuffix = { string.Empty }; + /// <summary> /// *************** *** 82,86 **** /// return a non-null value /// </summary> ! protected abstract CollectionPersister CollectionPersister { get; } /// <summary> --- 86,90 ---- /// return a non-null value /// </summary> ! protected abstract ICollectionPersister CollectionPersister { get; } /// <summary> *************** *** 123,126 **** --- 127,142 ---- } + /// <summary> + /// + /// </summary> + /// <param name="session"></param> + /// <param name="queryParameters"></param> + /// <returns></returns> + protected IList DoList( ISessionImplementor session, QueryParameters queryParameters ) + { + // HACK Call DoFind as DoQuery is 2.1 + return DoFindAndInitializeNonLazyCollections( session, queryParameters, null, null, null, null, true ); + } + // This method is called DoQueryAndInitializeNonLazyCollections in H2.1, // since DoFind is called DoQuery and is split into several smaller methods. *************** *** 154,157 **** --- 170,204 ---- /// <summary> + /// + /// </summary> + /// <param name="resultSet"></param> + /// <param name="session"></param> + /// <param name="queryParameters"></param> + /// <param name="returnProxies"></param> + /// <returns></returns> + protected object LoadSingleRow( IDataReader resultSet, ISessionImplementor session, QueryParameters queryParameters, bool returnProxies ) + { + int cols = Persisters.Length; + IList hydratedObjects = cols == 0 ? null : new ArrayList(); + object result = GetRowFromResultSet( resultSet, session, queryParameters, hydratedObjects, null, null, new Key[cols], returnProxies ); + + InitializeEntitiesAndCollections( hydratedObjects, resultSet, session ); + session.InitializeNonLazyCollections( ); + return result; + } + + private object GetRowFromResultSet( IDataReader resultSet, ISessionImplementor session, QueryParameters queryParameters, IList hydratedObjects, object optionalObject, object optionalId, Key[] keys, bool returnProxies ) + { + ILoadable[] persisters = Persisters; + int cols = persisters.Length; + ICollectionPersister collectionPersister = CollectionPersister; + int collectionOwner = CollectionOwner; + string[] suffixes = Suffixes; + LockMode[] lockModeArray = GetLockModes( queryParameters.LockModes ); + + return null; + } + + /// <summary> /// Execute an SQL query and attempt to instantiate instances of the class mapped by the given /// persister from each row of the <c>IDataReader</c>. *************** *** 183,187 **** ILoadable[ ] persisters = Persisters; int cols = persisters.Length; ! CollectionPersister collectionPersister = this.CollectionPersister; int collectionOwner = this.CollectionOwner; bool returnsEntities = cols > 0; --- 230,234 ---- ILoadable[ ] persisters = Persisters; int cols = persisters.Length; ! ICollectionPersister collectionPersister = this.CollectionPersister; int collectionOwner = this.CollectionOwner; bool returnsEntities = cols > 0; *************** *** 321,325 **** --- 368,403 ---- } + return results; + } + + private void InitializeEntitiesAndCollections( IList hydratedObjects, object resultSetId, ISessionImplementor session ) + { + if ( Persisters.Length > 0 ) + { + int hydratedObjectsSize = hydratedObjects.Count; + if ( log.IsInfoEnabled ) + { + log.Info( string.Format( "total objects hydrated: ", hydratedObjectsSize ) ); + } + for ( int i = 0; i < hydratedObjectsSize; i++ ) + { + session.InitializeEntity( hydratedObjects[ i ] ); + } + } + ICollectionPersister collectionPersister = CollectionPersister; + if ( collectionPersister != null ) + { + // this is a query and we are loading multiple instances of the same collection role + //session.EndLoadingCollections( collectionPersister, resultSetId ); + } + } + /// <summary> + /// + /// </summary> + /// <param name="results"></param> + /// <returns></returns> + protected IList ResultList( IList results ) + { return results; } *************** *** 852,855 **** --- 930,976 ---- /// <summary> + /// + /// </summary> + /// <param name="session"></param> + /// <param name="queryParameters"></param> + /// <param name="querySpaces"></param> + /// <param name="resultTypes"></param> + /// <returns></returns> + protected IList List( + ISessionImplementor session, + QueryParameters queryParameters, + ISet querySpaces, + IType[] resultTypes ) + { + ISessionFactoryImplementor factory = session.Factory; + // TODO: Uncomment when QueryCache implemented + /* + bool cacheable = factory.IsQueryCacheable && queryParameters.IsCacheable; + + if ( cacheable ) + { + QueryCache queryCache = factory.GetQueryCache( queryParameters.CacheRegion ) ; + QueryKey key = new QueryKey( SqlString, queryParameters ); + IList result = null; + if ( !queryParameters.IsForceCacheRefresh ) + { + result = queryCache.Get( key, resultTypes, querySpaces, session ); + } + if ( result == null ) + { + result = DoList( session, queryParameters ); + queryCache.Add( key, resultTypes, result, session ); + } + } + else + { + return DoList( session, queryParameters ); + } + */ + + return Find( session, queryParameters, true ); + } + + /// <summary> /// Called by subclasses that implement queries. /// </summary> *************** *** 915,919 **** --- 1036,1076 ---- } + /// <summary> + /// Generate a nice alias for the given class name or collection role + /// name and unique integer. Subclasses do <em>not</em> have to use + /// aliases of this form. + /// </summary> + /// <param name="length"></param> + /// <returns>an alias of the form <c>foo1_</c></returns> + protected static string[] GenerateSuffixes(int length) + { + if (length==0) return NoSuffix; + + string[] suffixes = new string[ length ]; + for ( int i = 0; i< length; i++ ) + { + suffixes[ i ] = i.ToString( ) + StringHelper.Underscore; + } + return suffixes; + } + /// <summary> + /// Generate a nice alias for the given class name or collection role + /// name and unique integer. Subclasses do <em>not</em> have to use + /// aliases of this form. + /// </summary> + /// <param name="description"></param> + /// <param name="unique"></param> + /// <returns>an alias of the form <c>foo1_</c></returns> + protected static string GenerateAlias( string description, int unique ) + { + //return new Alias( 10, unique.ToString() + StringHelper.Underscore ) + // .ToAliasString( StringHelper.Unqualify( description ).ToLower(), Dialect ); + + string alias = StringHelper.Unqualify( description ).ToLower().Replace( "$", "_" ); + int len = Math.Min( 10, alias.Length ); + + return alias.Substring( 0, len ) + unique.ToString() + StringHelper.Underscore; + } } } \ No newline at end of file Index: EntityLoader.cs =================================================================== RCS file: /cvsroot/nhibernate/nhibernate/src/NHibernate/Loader/EntityLoader.cs,v retrieving revision 1.8 retrieving revision 1.9 diff -C2 -d -r1.8 -r1.9 *** EntityLoader.cs 31 Dec 2004 20:57:44 -0000 1.8 --- EntityLoader.cs 1 Mar 2005 16:24:48 -0000 1.9 *************** *** 19,24 **** /// </summary> /// <param name="persister"></param> /// <param name="factory"></param> ! public EntityLoader( ILoadable persister, ISessionFactoryImplementor factory ) : base( persister, factory ) { idType = new IType[ ] {persister.IdentifierType}; --- 19,37 ---- /// </summary> /// <param name="persister"></param> + /// <param name="batchSize"></param> /// <param name="factory"></param> ! public EntityLoader( ILoadable persister, int batchSize, ISessionFactoryImplementor factory ) : this( persister, persister.IdentifierColumnNames, persister.IdentifierType, batchSize, factory ) ! { ! } ! ! /// <summary> ! /// ! /// </summary> ! /// <param name="persister"></param> ! /// <param name="uniqueKey"></param> ! /// <param name="uniqueKeyType"></param> ! /// <param name="batchSize"></param> ! /// <param name="factory"></param> ! public EntityLoader( ILoadable persister, string[] uniqueKey, IType uniqueKeyType, int batchSize, ISessionFactoryImplementor factory ) : base( persister, factory ) { idType = new IType[ ] {persister.IdentifierType}; *************** *** 38,46 **** /// <param name="session"></param> /// <param name="id"></param> /// <param name="obj"></param> /// <returns></returns> public object Load( ISessionImplementor session, object id, object obj ) { ! IList list = LoadEntity( session, new object[ ] {id}, idType, obj, id, false ); if( list.Count == 1 ) { --- 51,83 ---- /// <param name="session"></param> /// <param name="id"></param> + /// <returns></returns> + public object LoadByUniqueKey( ISessionImplementor session, object id ) + { + return Load( session, id, null, null ); + } + + /// <summary> + /// + /// </summary> + /// <param name="session"></param> + /// <param name="id"></param> /// <param name="obj"></param> /// <returns></returns> public object Load( ISessionImplementor session, object id, object obj ) { ! return Load( session, id, obj, id ); ! } ! ! /// <summary> ! /// ! /// </summary> ! /// <param name="session"></param> ! /// <param name="id"></param> ! /// <param name="obj"></param> ! /// <param name="optionalId"></param> ! /// <returns></returns> ! public object Load( ISessionImplementor session, object id, object obj, object optionalId ) ! { ! IList list = LoadEntity( session, new object[ ] {id}, idType, obj, optionalId, false ); if( list.Count == 1 ) { *************** *** 53,61 **** else { ! throw new HibernateException( ! "More than one row with the given identifier was found: " + id + ", for class: " + Persister.ClassName ); } } --- 90,105 ---- else { ! if ( CollectionOwner > -1 ) ! { ! return list[ 0 ]; ! } ! else ! { ! throw new HibernateException( ! "More than one row with the given identifier was found: " + id + ", for class: " + Persister.ClassName ); + } } } |
Update of /cvsroot/nhibernate/nhibernate/src/NHibernate/Mapping In directory sc8-pr-cvs1.sourceforge.net:/tmp/cvs-serv5548/nhibernate/src/NHibernate/Mapping Modified Files: Any.cs Array.cs Association.cs Bag.cs Collection.cs Component.cs IdentifierBag.cs IdentifierCollection.cs IndexedCollection.cs IntegerValue.cs List.cs ManyToOne.cs Map.cs OneToMany.cs OneToOne.cs PersistentClass.cs Property.cs RootClass.cs Set.cs Subclass.cs Table.cs Value.cs Added Files: IFetchable.cs IValue.cs MetaAttribute.cs NamedSQLQuery.cs SimpleValue.cs ToOne.cs Log Message: Various refactorings on the way to 2.1 querying capability Index: PersistentClass.cs =================================================================== RCS file: /cvsroot/nhibernate/nhibernate/src/NHibernate/Mapping/PersistentClass.cs,v retrieving revision 1.18 retrieving revision 1.19 diff -C2 -d -r1.18 -r1.19 *** PersistentClass.cs 6 Jan 2005 14:19:59 -0000 1.18 --- PersistentClass.cs 1 Mar 2005 16:24:49 -0000 1.19 *************** *** 2,6 **** --- 2,8 ---- using System.Collections; using NHibernate.Cache; + using NHibernate.Engine; using NHibernate.SqlCommand; + using NHibernate.Util; namespace NHibernate.Mapping *************** *** 15,21 **** private static readonly Alias PKAlias = new Alias( 15, "PK" ); ! private System.Type persistentClass; private string discriminatorValue; ! private ArrayList properties = new ArrayList(); private Table table; private System.Type proxyInterface; --- 17,32 ---- private static readonly Alias PKAlias = new Alias( 15, "PK" ); ! /// <summary> ! /// ! /// </summary> ! public static readonly string NullDiscriminatorMapping = "null"; ! /// <summary> ! /// ! /// </summary> ! public static readonly string NotNullDiscriminatorMapping = "not null"; ! ! private System.Type mappedClass; private string discriminatorValue; ! private Hashtable properties = new Hashtable(); private Table table; private System.Type proxyInterface; *************** *** 25,28 **** --- 36,43 ---- private bool dynamicInsert; private bool dynamicUpdate; + private int batchSize = 1; + //private bool selectBeforeUpdate; + //private int optimisticLockMode; + //private IDictionary metaAttributes; /// <summary> *************** *** 75,78 **** --- 90,103 ---- public virtual void AddSubclass( Subclass subclass ) { + // Inheritable cycle detection (paranoid check) + PersistentClass superclass = Superclass; + while ( superclass != null ) + { + if ( subclass.Name == superclass.Name ) + { + throw new MappingException( string.Format( "Circular inheritance mapping detected {0} will have itself as superclass when extending {1}", subclass.Name, Name ) ); + } + superclass = superclass.Superclass; + } subclasses.Add( subclass ); } *************** *** 146,149 **** --- 171,190 ---- /// <summary> + /// + /// </summary> + /// <param name="p"></param> + public void AddNewProperty( Property p ) + { + if ( properties.Contains( p.Name ) ) + { + throw new MappingException( string.Format( "Duplication mapping for property: {0}", StringHelper.Qualify( Name, p.Name ) ) ); + } + else + { + AddProperty( p ); + } + } + + /// <summary> /// Add the <see cref="Property"/> to this PersistentClass. /// </summary> *************** *** 151,155 **** public virtual void AddProperty( Property p ) { ! properties.Add( p ); } --- 192,196 ---- public virtual void AddProperty( Property p ) { ! properties.Add( p.Name, p ); } *************** *** 175,179 **** public virtual ICollection PropertyCollection { ! get { return properties; } } --- 216,220 ---- public virtual ICollection PropertyCollection { ! get { return properties.Values; } } *************** *** 186,193 **** /// element. /// </remarks> ! public virtual System.Type PersistentClazz { ! get { return persistentClass; } ! set { persistentClass = value; } } --- 227,234 ---- /// element. /// </remarks> ! public virtual System.Type MappedClass { ! get { return mappedClass; } ! set { mappedClass = value; } } *************** *** 198,202 **** public virtual string Name { ! get { return persistentClass.FullName; } } --- 239,243 ---- public virtual string Name { ! get { return mappedClass.FullName; } } *************** *** 228,236 **** /// <summary> ! /// When implemented by a class, gets or sets the <see cref="Value"/> /// that contains information about the identifier. /// </summary> ! /// <value>The <see cref="Value"/> that contains information about the identifier.</value> ! public abstract Value Identifier { get; set; } /// <summary> --- 269,277 ---- /// <summary> ! /// When implemented by a class, gets or sets the <see cref="SimpleValue"/> /// that contains information about the identifier. /// </summary> ! /// <value>The <see cref="SimpleValue"/> that contains information about the identifier.</value> ! public abstract SimpleValue Identifier { get; set; } /// <summary> *************** *** 242,250 **** /// <summary> ! /// When implemented by a class, gets or sets the <see cref="Value"/> /// that contains information about the discriminator. /// </summary> ! /// <value>The <see cref="Value"/> that contains information about the discriminator.</value> ! public abstract Value Discriminator { get; set; } /// <summary> --- 283,291 ---- /// <summary> ! /// When implemented by a class, gets or sets the <see cref="SimpleValue"/> /// that contains information about the discriminator. /// </summary> ! /// <value>The <see cref="SimpleValue"/> that contains information about the discriminator.</value> ! public abstract SimpleValue Discriminator { get; set; } /// <summary> *************** *** 413,416 **** --- 454,473 ---- /// <summary> + /// + /// </summary> + public bool IsDiscriminatorValueNotNull + { + get { return NotNullDiscriminatorMapping.Equals( DiscriminatorValue ); } + } + + /// <summary> + /// + /// </summary> + public bool IsDiscriminatorValueNull + { + get { return NullDiscriminatorMapping.Equals( DiscriminatorValue ); } + } + + /// <summary> /// When implemented by a class, gets or sets a boolean indicating if the identifier is /// embedded in the class. *************** *** 425,434 **** /// <summary> ! /// When implemented by a class, gets or sets the <see cref="System.Type"/> of ! /// the Persister. /// </summary> ! /// <value>The <see cref="System.Type"/> of the Persister.</value> ! /// <remarks>The value of this is set by the <c>persister</c> attribute.</remarks> ! public abstract System.Type Persister { get; set; } /// <summary> --- 482,488 ---- /// <summary> ! /// When implemented by a class, gets or sets the <see cref="System.Type"/> of the Persister. /// </summary> ! public abstract System.Type ClassPersisterClass { get; set; } /// <summary> *************** *** 451,459 **** /// <summary> ! /// When implemented by a class, gets or sets the <see cref="Value"/> /// that contains information about the Key. /// </summary> ! /// <value>The <see cref="Value"/> that contains information about the Key.</value> ! public abstract Value Key { get; set; } /// <summary> --- 505,513 ---- /// <summary> ! /// When implemented by a class, gets or sets the <see cref="SimpleValue"/> /// that contains information about the Key. /// </summary> ! /// <value>The <see cref="SimpleValue"/> that contains information about the Key.</value> ! public abstract SimpleValue Key { get; set; } /// <summary> *************** *** 476,479 **** --- 530,542 ---- /// <summary> + /// + /// </summary> + public int BatchSize + { + get { return batchSize; } + set { batchSize = value; } + } + + /// <summary> /// When implemented by a class, gets or sets the sql string that should /// be a part of the where clause. *************** *** 487,490 **** --- 550,577 ---- public abstract string Where { get; set; } + /// <summary> + /// + /// </summary> + public abstract bool IsJoinedSubclass { get; } + + /// <summary> + /// + /// </summary> + public abstract bool IsDiscriminatorInsertable { get; set; } + + /// <summary> + /// + /// </summary> + /// <param name="mapping"></param> + public virtual void Validate( IMapping mapping ) + { + foreach( Mapping.Property prop in PropertyCollection ) + { + if ( !prop.IsValid( mapping ) ) + { + throw new MappingException( string.Format( "property mapping has wrong number of columns: {0} type: {1}", StringHelper.Qualify( MappedClass.Name, Name ), prop.Type.Name ) ) ; + } + } + } } } \ No newline at end of file Index: ManyToOne.cs =================================================================== RCS file: /cvsroot/nhibernate/nhibernate/src/NHibernate/Mapping/ManyToOne.cs,v retrieving revision 1.4 retrieving revision 1.5 diff -C2 -d -r1.4 -r1.5 *** ManyToOne.cs 31 Dec 2004 21:27:30 -0000 1.4 --- ManyToOne.cs 1 Mar 2005 16:24:49 -0000 1.5 *************** *** 5,9 **** { /// <summary></summary> ! public class ManyToOne : Association { /// <summary> --- 5,9 ---- { /// <summary></summary> ! public class ManyToOne : ToOne { /// <summary> *************** *** 38,42 **** public override void CreateForeignKey() { ! CreateForeignKeyOfClass( ( ( EntityType ) Type ).PersistentClass ); } } --- 38,46 ---- public override void CreateForeignKey() { ! // TODO: Handle the case of a foreign key to something other than the pk ! if ( ReferencedPropertyName == null ) ! { ! CreateForeignKeyOfClass( ( ( EntityType ) Type ).AssociatedClass ); ! } } } Index: Map.cs =================================================================== RCS file: /cvsroot/nhibernate/nhibernate/src/NHibernate/Mapping/Map.cs,v retrieving revision 1.7 retrieving revision 1.8 diff -C2 -d -r1.7 -r1.8 *** Map.cs 14 Feb 2005 03:37:27 -0000 1.7 --- Map.cs 1 Mar 2005 16:24:49 -0000 1.8 *************** *** 15,19 **** /// <summary></summary> ! public override PersistentCollectionType Type { get --- 15,19 ---- /// <summary></summary> ! public override PersistentCollectionType CollectionType { get --- NEW FILE: IFetchable.cs --- using NHibernate.Loader; namespace NHibernate.Mapping { /// <summary> /// Any mapping with an outer-join attribute /// </summary> public interface IFetchable { /// <summary> /// /// </summary> OuterJoinFetchStrategy OuterJoinFetchSetting { get; set; } } } Index: Property.cs =================================================================== RCS file: /cvsroot/nhibernate/nhibernate/src/NHibernate/Mapping/Property.cs,v retrieving revision 1.10 retrieving revision 1.11 diff -C2 -d -r1.10 -r1.11 *** Property.cs 31 Dec 2004 21:27:54 -0000 1.10 --- Property.cs 1 Mar 2005 16:24:49 -0000 1.11 *************** *** 10,18 **** { private string name; ! private Value propertyValue; private string cascade; ! private bool updateable; ! private bool insertable; private string propertyAccessorName; /// <summary> --- 10,26 ---- { private string name; ! private IValue propertyValue; private string cascade; ! private bool updateable = true; ! private bool insertable = true; private string propertyAccessorName; + private IDictionary metaAttributes; + + /// <summary> + /// + /// </summary> + public Property( ) + { + } /// <summary> *************** *** 20,24 **** /// </summary> /// <param name="propertyValue"></param> ! public Property( Value propertyValue ) { this.propertyValue = propertyValue; --- 28,32 ---- /// </summary> /// <param name="propertyValue"></param> ! public Property( IValue propertyValue ) { this.propertyValue = propertyValue; *************** *** 70,74 **** /// <summary></summary> ! public Value Value { get { return propertyValue; } --- 78,82 ---- /// <summary></summary> ! public IValue Value { get { return propertyValue; } *************** *** 153,156 **** --- 161,171 ---- /// <summary></summary> + public bool IsNullable + { + // Approximate + get { return propertyValue != null && propertyValue.IsNullable; } + } + + /// <summary></summary> public string PropertyAccessorName { *************** *** 190,193 **** --- 205,234 ---- get { return propertyAccessorName == null || propertyAccessorName.Equals( "property" ); } } + + /// <summary> + /// + /// </summary> + /// <param name="mapping"></param> + /// <returns></returns> + public bool IsValid( IMapping mapping ) + { + return IsFormula ? ColumnSpan == 0 : Value.IsValid( mapping ); + } + + /// <summary> + /// + /// </summary> + public string NullValue + { + get + { + if ( propertyValue is SimpleValue ) + { + return ( (SimpleValue) propertyValue).NullValue; + } + else + return null; + } + } } } \ No newline at end of file Index: Value.cs =================================================================== RCS file: /cvsroot/nhibernate/nhibernate/src/NHibernate/Mapping/Value.cs,v retrieving revision 1.10 retrieving revision 1.11 diff -C2 -d -r1.10 -r1.11 *** Value.cs 31 Dec 2004 21:28:13 -0000 1.10 --- Value.cs 1 Mar 2005 16:24:49 -0000 1.11 *************** *** 145,151 **** /// <summary></summary> ! public virtual OuterJoinLoaderType OuterJoinFetchSetting { ! get { return OuterJoinLoaderType.Lazy; } set { throw new NotSupportedException(); } } --- 145,151 ---- /// <summary></summary> ! public virtual OuterJoinFetchStrategy OuterJoinFetchSetting { ! get { return OuterJoinFetchStrategy.Lazy; } set { throw new NotSupportedException(); } } Index: OneToMany.cs =================================================================== RCS file: /cvsroot/nhibernate/nhibernate/src/NHibernate/Mapping/OneToMany.cs,v retrieving revision 1.4 retrieving revision 1.5 diff -C2 -d -r1.4 -r1.5 *** OneToMany.cs 31 Dec 2004 21:27:30 -0000 1.4 --- OneToMany.cs 1 Mar 2005 16:24:49 -0000 1.5 *************** *** 1,2 **** --- 1,5 ---- + using System.Collections; + using NHibernate.Engine; + using NHibernate.Loader; using NHibernate.Type; *************** *** 4,14 **** { /// <summary></summary> ! public class OneToMany { private EntityType type; private Table referencingTable; /// <summary></summary> ! public EntityType Type { get { return type; } --- 7,18 ---- { /// <summary></summary> ! public class OneToMany : IValue { private EntityType type; private Table referencingTable; + private PersistentClass associatedClass; /// <summary></summary> ! public EntityType EntityType { get { return type; } *************** *** 26,33 **** --- 30,113 ---- /// <summary></summary> + public ICollection ColumnCollection + { + get { return associatedClass.Key.ColumnCollection; } + } + + /// <summary></summary> + public int ColumnSpan + { + get { return associatedClass.Key.ColumnSpan; } + } + + /// <summary></summary> public Table ReferencingTable { get { return referencingTable; } } + + /// <summary></summary> + public IType Type + { + get { return type; } + set { type = (EntityType) value; } + } + + /// <summary></summary> + public PersistentClass AssociatedClass + { + get { return associatedClass; } + set { associatedClass = value; } + } + + /// <summary></summary> + public Formula Formula + { + get { return null; } + } + + /// <summary></summary> + public Table Table + { + get { return referencingTable; } + } + + /// <summary></summary> + public bool IsNullable + { + get { return false; } + } + + /// <summary></summary> + public bool IsSimpleValue + { + get { return false; } + } + + /// <summary></summary> + public bool IsUnique + { + get { return false; } + } + + /// <summary></summary> + public bool IsValid( IMapping mapping ) + { + return true; + } + + /// <summary></summary> + public OuterJoinFetchStrategy OuterJoinFetchSetting + { + get { return OuterJoinFetchStrategy.Eager; } + } + + /// <summary> + /// + /// </summary> + /// <remarks>No foreign key element for a one-to-many</remarks> + public void CreateForeignKey( ) + { + } } } \ No newline at end of file --- NEW FILE: MetaAttribute.cs --- using System; using System.Collections; namespace NHibernate.Mapping { /// <summary> /// A meta attribute is a named value or values. /// </summary> public class MetaAttribute { private string name; private IList values; /// <summary> /// /// </summary> public MetaAttribute() { values = new ArrayList(); } /// <summary> /// /// </summary> public string Name { get { return name; } set { name = value; } } /// <summary> /// /// </summary> public IList Values { get { return values; } } /// <summary> /// /// </summary> public string Value { get { if ( values.Count != 1 ) { throw new ArgumentException( "No unique value" ); } return (string) values[0]; } } /// <summary> /// /// </summary> public bool IsMultiValued { get { return values.Count > 1; } } /// <summary> /// /// </summary> /// <param name="value"></param> public void AddValue( string value ) { values.Add( value ); } } } Index: RootClass.cs =================================================================== RCS file: /cvsroot/nhibernate/nhibernate/src/NHibernate/Mapping/RootClass.cs,v retrieving revision 1.12 retrieving revision 1.13 diff -C2 -d -r1.12 -r1.13 *** RootClass.cs 3 Jan 2005 03:46:48 -0000 1.12 --- RootClass.cs 1 Mar 2005 16:24:49 -0000 1.13 *************** *** 27,41 **** private Property identifierProperty; ! private Value identifier; private Property version; private bool polymorphic; private ICacheConcurrencyStrategy cache; ! private Value discriminator; private bool mutable; private bool embeddedIdentifier = false; private bool explicitPolymorphism; ! private System.Type persister; private bool forceDiscriminator; private string where; /// <summary> --- 27,42 ---- private Property identifierProperty; ! private SimpleValue identifier; private Property version; private bool polymorphic; private ICacheConcurrencyStrategy cache; ! private SimpleValue discriminator; private bool mutable; private bool embeddedIdentifier = false; private bool explicitPolymorphism; ! private System.Type classPersisterClass; private bool forceDiscriminator; private string where; + private bool discriminatorInsertable; /// <summary> *************** *** 52,59 **** /// <summary> ! /// Gets or sets the <see cref="Value"/> that contains information about the identifier. /// </summary> ! /// <value>The <see cref="Value"/> that contains information about the identifier.</value> ! public override Value Identifier { get { return identifier; } --- 53,60 ---- /// <summary> ! /// Gets or sets the <see cref="SimpleValue"/> that contains information about the identifier. /// </summary> ! /// <value>The <see cref="SimpleValue"/> that contains information about the identifier.</value> ! public override SimpleValue Identifier { get { return identifier; } *************** *** 71,78 **** /// <summary> ! /// Gets or sets the <see cref="Value"/> that contains information about the discriminator. /// </summary> ! /// <value>The <see cref="Value"/> that contains information about the discriminator.</value> ! public override Value Discriminator { get { return discriminator; } --- 72,79 ---- /// <summary> ! /// Gets or sets the <see cref="SimpleValue"/> that contains information about the discriminator. /// </summary> ! /// <value>The <see cref="SimpleValue"/> that contains information about the discriminator.</value> ! public override SimpleValue Discriminator { get { return discriminator; } *************** *** 235,242 **** /// </summary> /// <value>The <see cref="System.Type"/> of the Persister.</value> ! public override System.Type Persister { ! get { return persister; } ! set { persister = value; } } --- 236,243 ---- /// </summary> /// <value>The <see cref="System.Type"/> of the Persister.</value> ! public override System.Type ClassPersisterClass { ! get { return classPersisterClass; } ! set { classPersisterClass = value; } } *************** *** 270,277 **** /// <summary> ! /// Gets or sets the <see cref="Value"/> that contains information about the Key. /// </summary> ! /// <value>The <see cref="Value"/> that contains information about the Key.</value> ! public override Value Key { get { return Identifier; } --- 271,278 ---- /// <summary> ! /// Gets or sets the <see cref="SimpleValue"/> that contains information about the Key. /// </summary> ! /// <value>The <see cref="SimpleValue"/> that contains information about the Key.</value> ! public override SimpleValue Key { get { return Identifier; } *************** *** 302,305 **** --- 303,322 ---- } + /// <summary> + /// + /// </summary> + public override bool IsJoinedSubclass + { + get { return false; } + } + + /// <summary> + /// + /// </summary> + public override bool IsDiscriminatorInsertable + { + get { return discriminatorInsertable; } + set { discriminatorInsertable = value; } + } } } \ No newline at end of file --- NEW FILE: NamedSQLQuery.cs --- using System; using System.Collections; namespace NHibernate.Mapping { /// <summary> /// Simple holder for named sql queries /// </summary> public class NamedSQLQuery { private string query; private ArrayList aliasedClasses; private ArrayList synchronizedTables; private ArrayList aliases; /// <summary> /// /// </summary> /// <param name="query"></param> public NamedSQLQuery( string query ) { this.aliases = new ArrayList(); this.aliasedClasses = new ArrayList(); this.query = query; this.synchronizedTables = new ArrayList(); } /// <summary> /// /// </summary> public string[] ReturnAliases { get { return (string[]) aliases.ToArray( typeof( string[ ] ) ); } } /// <summary> /// /// </summary> public string[] ReturnClasses { get { return (string[]) aliasedClasses.ToArray( typeof( string[ ] ) ); } } /// <summary> /// /// </summary> public IList SynchronizedTables { get { return synchronizedTables; } } /// <summary> /// /// </summary> public string QueryString { get { return query; } } /// <summary> /// /// </summary> /// <param name="table"></param> public void AddSynchronizedTable( string table ) { synchronizedTables.Add( table ); } /// <summary> /// /// </summary> /// <param name="alias"></param> /// <param name="clazz"></param> public void AddAliasedClass( string alias, object clazz) { aliases.Add( alias ); aliasedClasses.Add( clazz ); } } } --- NEW FILE: ToOne.cs --- using System; using NHibernate.Loader; namespace NHibernate.Mapping { /// <summary> /// A simple-point association (ie. a reference to another entity). /// </summary> public abstract class ToOne : SimpleValue, IFetchable { private OuterJoinFetchStrategy joinedFetch; private string referencedPropertyName; /// <summary> /// /// </summary> public ToOne( Table table ) : base( table ) { } /// <summary></summary> public override OuterJoinFetchStrategy OuterJoinFetchSetting { get { return joinedFetch; } set { joinedFetch = value; } } /// <summary></summary> public string ReferencedPropertyName { get { return referencedPropertyName; } set { referencedPropertyName = value; } } /// <summary> /// /// </summary> public abstract override void CreateForeignKey( ); /// <summary> /// /// </summary> /// <param name="propertyClass"></param> /// <param name="propertyName"></param> public abstract override void SetTypeByReflection( System.Type propertyClass, string propertyName ); } } Index: IdentifierBag.cs =================================================================== RCS file: /cvsroot/nhibernate/nhibernate/src/NHibernate/Mapping/IdentifierBag.cs,v retrieving revision 1.4 retrieving revision 1.5 diff -C2 -d -r1.4 -r1.5 *** IdentifierBag.cs 14 Feb 2005 03:37:27 -0000 1.4 --- IdentifierBag.cs 1 Mar 2005 16:24:49 -0000 1.5 *************** *** 18,22 **** /// <summary></summary> ! public override PersistentCollectionType Type { get { return TypeFactory.IdBag( Role ); } --- 18,22 ---- /// <summary></summary> ! public override PersistentCollectionType CollectionType { get { return TypeFactory.IdBag( Role ); } Index: IntegerValue.cs =================================================================== RCS file: /cvsroot/nhibernate/nhibernate/src/NHibernate/Mapping/IntegerValue.cs,v retrieving revision 1.6 retrieving revision 1.7 diff -C2 -d -r1.6 -r1.7 *** IntegerValue.cs 17 Jan 2005 03:40:58 -0000 1.6 --- IntegerValue.cs 1 Mar 2005 16:24:49 -0000 1.7 *************** *** 4,8 **** { /// <summary></summary> ! public class IntegerValue : Value { /// <summary> --- 4,8 ---- { /// <summary></summary> ! public class IntegerValue : SimpleValue { /// <summary> Index: IdentifierCollection.cs =================================================================== RCS file: /cvsroot/nhibernate/nhibernate/src/NHibernate/Mapping/IdentifierCollection.cs,v retrieving revision 1.3 retrieving revision 1.4 diff -C2 -d -r1.3 -r1.4 *** IdentifierCollection.cs 31 Dec 2004 21:26:49 -0000 1.3 --- IdentifierCollection.cs 1 Mar 2005 16:24:49 -0000 1.4 *************** *** 8,12 **** /// <summary></summary> public static readonly string DefaultIdentifierColumnName = "id"; ! private Value identifier; /// <summary> --- 8,12 ---- /// <summary></summary> public static readonly string DefaultIdentifierColumnName = "id"; ! private SimpleValue identifier; /// <summary> *************** *** 19,23 **** /// <summary></summary> ! public Value Identifier { get { return identifier; } --- 19,23 ---- /// <summary></summary> ! public SimpleValue Identifier { get { return identifier; } *************** *** 32,44 **** /// <summary></summary> ! public void CreatePrimaryKey() { ! PrimaryKey pk = new PrimaryKey(); ! foreach( Column col in Identifier.ColumnCollection ) { ! pk.AddColumn( col ); } - Table.PrimaryKey = pk; } --- 32,48 ---- /// <summary></summary> ! public override void CreatePrimaryKey() { ! if ( !IsOneToMany ) { ! PrimaryKey pk = new PrimaryKey(); ! foreach( Column col in Identifier.ColumnCollection ) ! { ! pk.AddColumn( col ); ! } ! CollectionTable.PrimaryKey = pk; } + //else // Create an index on the key columns? } Index: Collection.cs =================================================================== RCS file: /cvsroot/nhibernate/nhibernate/src/NHibernate/Mapping/Collection.cs,v retrieving revision 1.7 retrieving revision 1.8 diff -C2 -d -r1.7 -r1.8 *** Collection.cs 31 Dec 2004 21:26:38 -0000 1.7 --- Collection.cs 1 Mar 2005 16:24:49 -0000 1.8 *************** *** 1,4 **** --- 1,6 ---- using System.Collections; using NHibernate.Cache; + using NHibernate.Engine; + using NHibernate.Loader; using NHibernate.Type; *************** *** 6,11 **** { /// <summary></summary> ! public abstract class Collection { /// <summary></summary> public const string DefaultElementColumnName = "elt"; --- 8,15 ---- { /// <summary></summary> ! public abstract class Collection : IFetchable, IValue { + private static readonly ICollection EmptyColumns = new ArrayList(); + /// <summary></summary> public const string DefaultElementColumnName = "elt"; *************** *** 14,25 **** public const string DefaultKeyColumnName = "id"; ! private Value key; ! private Value element; ! private Table table; private string role; private bool lazy; ! private bool isOneToMany; private bool inverse; ! private OneToMany oneToMany; private ICacheConcurrencyStrategy cache; private string orderBy; --- 18,29 ---- public const string DefaultKeyColumnName = "id"; ! private SimpleValue key; ! private IValue element; ! private Table collectionTable; private string role; private bool lazy; ! //private bool isOneToMany; private bool inverse; ! //private OneToMany oneToMany; private ICacheConcurrencyStrategy cache; private string orderBy; *************** *** 29,32 **** --- 33,39 ---- private IComparer comparer; private bool orphanDelete; + private int batchSize = 1; + private OuterJoinFetchStrategy joinedFetch; + private System.Type collectionPersisterClass; /// <summary> *************** *** 40,43 **** --- 47,56 ---- /// <summary></summary> + public int ColumnSpan + { + get { return 0; } + } + + /// <summary></summary> public virtual bool IsSet { *************** *** 46,50 **** /// <summary></summary> ! public Value Key { get { return key; } --- 59,63 ---- /// <summary></summary> ! public SimpleValue Key { get { return key; } *************** *** 53,57 **** /// <summary></summary> ! public Value Element { get { return element; } --- 66,70 ---- /// <summary></summary> ! public IValue Element { get { return element; } *************** *** 66,73 **** /// <summary></summary> public Table Table { ! get { return table; } ! set { table = value; } } --- 79,92 ---- /// <summary></summary> + public Table CollectionTable + { + get { return collectionTable; } + set { collectionTable = value; } + } + + /// <summary></summary> public Table Table { ! get { return Owner.Table; } } *************** *** 80,83 **** --- 99,116 ---- /// <summary></summary> + public PersistentClass Owner + { + get { return owner; } + set { owner = value; } + } + + /// <summary></summary> + public System.Type CollectionPersisterClass + { + get { return collectionPersisterClass; } + set { collectionPersisterClass = value; } + } + + /// <summary></summary> public IComparer Comparer { *************** *** 101,107 **** /// <summary></summary> ! public abstract PersistentCollectionType Type { get; } /// <summary></summary> public abstract System.Type WrapperClass { get; } --- 134,170 ---- /// <summary></summary> ! public ICollection ColumnCollection ! { ! get { return EmptyColumns; } ! } ! ! /// <summary></summary> ! public Formula Formula ! { ! get { return null; } ! } ! ! /// <summary></summary> ! public bool IsNullable ! { ! get { return true; } ! } ! ! /// <summary></summary> ! public bool IsUnique ! { ! get { return false; } ! } ! ! /// <summary></summary> ! public abstract PersistentCollectionType CollectionType { get; } /// <summary></summary> + public IType Type + { + get { return CollectionType; } + } + + /// <summary></summary> public abstract System.Type WrapperClass { get; } *************** *** 127,134 **** public bool IsOneToMany { ! get { return isOneToMany; } ! set { isOneToMany = value; } } /// <summary></summary> public OneToMany OneToMany --- 190,198 ---- public bool IsOneToMany { ! get { return element is OneToMany; } ! //set { isOneToMany = value; } } + /* /// <summary></summary> public OneToMany OneToMany *************** *** 137,140 **** --- 201,205 ---- set { oneToMany = value; } } + */ /// <summary></summary> *************** *** 155,166 **** public System.Type OwnerClass { ! get { return owner.PersistentClazz; } ! } ! ! /// <summary></summary> ! public PersistentClass Owner ! { ! get { return owner; } ! set { owner = value; } } --- 220,224 ---- public System.Type OwnerClass { ! get { return owner.MappedClass; } } *************** *** 186,189 **** --- 244,326 ---- } + /// <summary></summary> + public int BatchSize + { + get { return batchSize; } + set { batchSize = value; } + } + + /// <summary></summary> + public OuterJoinFetchStrategy OuterJoinFetchSetting + { + get { return joinedFetch; } + set { joinedFetch = value; } + } + + /// <summary> + /// + /// </summary> + public void CreateForeignKey( ) + { + } + + private void CreateForeignKeys( ) + { + if ( !IsInverse ) + { + Element.CreateForeignKey(); + Key.CreateForeignKeyOfClass( Owner.MappedClass ); + } + } + + /// <summary> + /// + /// </summary> + public abstract void CreatePrimaryKey( ); + + /// <summary> + /// + /// </summary> + public void CreateAllKeys() + { + CreateForeignKeys(); + if ( !IsInverse ) + { + CreatePrimaryKey( ); + } + } + + /// <summary></summary> + public bool IsSimpleValue + { + get { return false; } + } + + /// <summary> + /// + /// </summary> + /// <param name="mapping"></param> + /// <returns></returns> + public bool IsValid( IMapping mapping ) + { + return true; + } + + /// <summary> + /// + /// </summary> + /// <param name="mapping"></param> + public virtual void Validate( IMapping mapping ) + { + if ( !Key.IsValid( mapping ) ) + { + throw new MappingException( string.Format( "collection foreign key mapping has wrong number of columns: {0} type: {1}", Role, Key.Type.Name ) ); + } + + if ( !Element.IsValid( mapping ) ) + { + throw new MappingException( string.Format( "collection element key mapping has wrong number of columns: {0} type: {1}", Role, Element.Type.Name ) ); + } + } } } \ No newline at end of file Index: Any.cs =================================================================== RCS file: /cvsroot/nhibernate/nhibernate/src/NHibernate/Mapping/Any.cs,v retrieving revision 1.5 retrieving revision 1.6 diff -C2 -d -r1.5 -r1.6 *** Any.cs 31 Dec 2004 21:26:25 -0000 1.5 --- Any.cs 1 Mar 2005 16:24:48 -0000 1.6 *************** *** 5,9 **** { /// <summary></summary> ! public class Any : Value { private IType identifierType; --- 5,9 ---- { /// <summary></summary> ! public class Any : SimpleValue { private IType identifierType; Index: Association.cs =================================================================== RCS file: /cvsroot/nhibernate/nhibernate/src/NHibernate/Mapping/Association.cs,v retrieving revision 1.4 retrieving revision 1.5 diff -C2 -d -r1.4 -r1.5 *** Association.cs 31 Dec 2004 21:26:26 -0000 1.4 --- Association.cs 1 Mar 2005 16:24:49 -0000 1.5 *************** *** 6,10 **** public abstract class Association : Value { ! private OuterJoinLoaderType joinedFetch; /// <summary> --- 6,10 ---- public abstract class Association : Value { ! private OuterJoinFetchStrategy joinedFetch; /// <summary> *************** *** 17,21 **** /// <summary></summary> ! public override OuterJoinLoaderType OuterJoinFetchSetting { get { return joinedFetch; } --- 17,21 ---- /// <summary></summary> ! public override OuterJoinFetchStrategy OuterJoinFetchSetting { get { return joinedFetch; } Index: Set.cs =================================================================== RCS file: /cvsroot/nhibernate/nhibernate/src/NHibernate/Mapping/Set.cs,v retrieving revision 1.7 retrieving revision 1.8 diff -C2 -d -r1.7 -r1.8 *** Set.cs 14 Feb 2005 03:37:27 -0000 1.7 --- Set.cs 1 Mar 2005 16:24:49 -0000 1.8 *************** *** 29,33 **** /// <see cref="Collection.Type"/> /// </summary> ! public override PersistentCollectionType Type { get --- 29,33 ---- /// <see cref="Collection.Type"/> /// </summary> ! public override PersistentCollectionType CollectionType { get *************** *** 53,79 **** /// <summary></summary> ! public void CreatePrimaryKey() { ! PrimaryKey pk = new PrimaryKey(); ! foreach( Column col in Key.ColumnCollection ) { ! pk.AddColumn( col ); ! } ! bool nullable = false; ! foreach( Column col in Element.ColumnCollection ) ! { ! if( col.IsNullable ) { ! nullable = true; } - pk.AddColumn( col ); - } ! // some databases (Postgres) will tolerate nullable ! // column in a primary key - others (DB2) won't ! if( !nullable ) { ! Table.PrimaryKey = pk; } } --- 53,86 ---- /// <summary></summary> ! public override void CreatePrimaryKey() { ! if ( !IsOneToMany ) { ! PrimaryKey pk = new PrimaryKey(); ! foreach( Column col in Key.ColumnCollection ) ! { ! pk.AddColumn( col ); ! } ! bool nullable = false; ! foreach( Column col in Element.ColumnCollection ) { ! if( col.IsNullable ) ! { ! nullable = true; ! } ! pk.AddColumn( col ); } ! // some databases (Postgres) will tolerate nullable ! // column in a primary key - others (DB2) won't ! if( !nullable ) ! { ! CollectionTable.PrimaryKey = pk; ! } ! } ! else { ! // Create an index on the key columns? } } Index: OneToOne.cs =================================================================== RCS file: /cvsroot/nhibernate/nhibernate/src/NHibernate/Mapping/OneToOne.cs,v retrieving revision 1.4 retrieving revision 1.5 diff -C2 -d -r1.4 -r1.5 *** OneToOne.cs 31 Dec 2004 21:27:42 -0000 1.4 --- OneToOne.cs 1 Mar 2005 16:24:49 -0000 1.5 *************** *** 6,14 **** { /// <summary></summary> ! public class OneToOne : Association { private bool constrained; private ForeignKeyType foreignKeyType; ! private Value identifier; /// <summary> --- 6,14 ---- { /// <summary></summary> ! public class OneToOne : ToOne { private bool constrained; private ForeignKeyType foreignKeyType; ! private SimpleValue identifier; /// <summary> *************** *** 17,21 **** /// <param name="table"></param> /// <param name="identifier"></param> ! public OneToOne( Table table, Value identifier ) : base( table ) { this.identifier = identifier; --- 17,21 ---- /// <param name="table"></param> /// <param name="identifier"></param> ! public OneToOne( Table table, SimpleValue identifier ) : base( table ) { this.identifier = identifier; *************** *** 45,51 **** public override void CreateForeignKey() { if( constrained ) { ! CreateForeignKeyOfClass( ( ( EntityType ) Type ).PersistentClass ); } } --- 45,52 ---- public override void CreateForeignKey() { + //if( constrained && ReferencedPropertyName == null ) if( constrained ) { ! CreateForeignKeyOfClass( ( ( EntityType ) Type ).AssociatedClass ); } } *************** *** 80,90 **** /// <summary></summary> ! public Value Identifier { get { return identifier; } ! set { identifier = value; } } ! } } \ No newline at end of file --- 81,95 ---- /// <summary></summary> ! public IValue Identifier { get { return identifier; } ! set { identifier = (SimpleValue) value; } } ! /// <summary></summary> ! public override bool IsNullable ! { ! get { return !IsConstrained; } ! } } } \ No newline at end of file --- NEW FILE: SimpleValue.cs --- using System; using System.Collections; using NHibernate.Engine; using NHibernate.Id; using NHibernate.Loader; using NHibernate.Type; using NHibernate.Util; namespace NHibernate.Mapping { /// <summary> /// Any value that maps to columns. /// </summary> public class SimpleValue : IValue { private ArrayList columns = new ArrayList(); private IType type; private IDictionary identifierGeneratorProperties; private string identifierGeneratorStrategy = "assigned"; private string nullValue; private Table table; private Formula formula; private string foreignKeyName; private bool unique; private IIdentifierGenerator uniqueIdentifierGenerator; /// <summary> /// /// </summary> public SimpleValue( ) { } /// <summary> /// /// </summary> /// <param name="table"></param> public SimpleValue( Table table ) { this.table = table; } /// <summary> /// /// </summary> /// <param name="column"></param> public virtual void AddColumn( Column column ) { if( !columns.Contains( column ) ) { columns.Add( column ); } } /// <summary></summary> public virtual int ColumnSpan { get { return columns.Count; } } /// <summary></summary> public virtual ICollection ColumnCollection { get { return columns; } } /// <summary></summary> public virtual IList ConstraintColumns { get { return columns; } } /// <summary></summary> public virtual IType Type { get { return type; } set { this.type = value; int count = 0; foreach( Column col in ColumnCollection ) { col.Type = type; col.TypeIndex = count++; } } } /// <summary></summary> public string ForeignKeyName { get { return foreignKeyName; } set { foreignKeyName = value; } } /// <summary></summary> public Table Table { get { return table; } set { table = value; } } /// <summary></summary> public virtual void CreateForeignKey() { } /// <summary> /// /// </summary> /// <param name="persistentClass"></param> public void CreateForeignKeyOfClass( System.Type persistentClass ) { ForeignKey fk = table.CreateForeignKey( ConstraintColumns ); fk.ReferencedClass = persistentClass; } /// <summary> /// /// </summary> /// <param name="dialect"></param> /// <returns></returns> public IIdentifierGenerator CreateIdentifierGenerator( Dialect.Dialect dialect ) { if( uniqueIdentifierGenerator == null ) { uniqueIdentifierGenerator = IdentifierGeneratorFactory.Create( identifierGeneratorStrategy, type, identifierGeneratorProperties, dialect ); } return uniqueIdentifierGenerator; } /// <summary> /// /// </summary> /// <param name="propertyClass"></param> /// <param name="propertyName"></param> public virtual void SetTypeByReflection( System.Type propertyClass, string propertyName ) { try { if( type == null ) { type = ReflectHelper.ReflectedPropertyType( propertyClass, propertyName ); int count = 0; foreach( Column col in ColumnCollection ) { col.Type = type; col.TypeIndex = count++; } } } catch( HibernateException he ) { throw new MappingException( "Problem trying to set property type by reflection", he ); } } /// <summary></summary> public virtual OuterJoinFetchStrategy OuterJoinFetchSetting { get { return OuterJoinFetchStrategy.Lazy; } set { throw new NotSupportedException(); } } /// <summary></summary> public IDictionary IdentifierGeneratorProperties { get { return identifierGeneratorProperties; } set { identifierGeneratorProperties = value; } } /// <summary></summary> public string IdentifierGeneratorStrategy { get { return identifierGeneratorStrategy; } set { identifierGeneratorStrategy = value; } } /// <summary></summary> public virtual bool IsComposite { get { return false; } } /// <summary></summary> public bool IsSimpleValue { get { return true; } } /// <summary></summary> public bool IsUnique { get { return unique; } set { unique = value; } } /// <summary></summary> public virtual bool IsNullable { get { bool nullable = true; foreach( Column col in ColumnCollection ) { if ( !col.IsNullable ) { nullable = false; } } return nullable; } } /// <summary></summary> public string NullValue { get { return nullValue; } set { nullValue = value; } } /// <summary></summary> public virtual bool IsAny { get { return false; } } /// <summary></summary> public Formula Formula { get { return formula; } set { formula = value; } } /// <summary></summary> public bool IsValid( IMapping mapping ) { return ColumnSpan == Type.GetColumnSpan( mapping ); } } } Index: Bag.cs =================================================================== RCS file: /cvsroot/nhibernate/nhibernate/src/NHibernate/Mapping/Bag.cs,v retrieving revision 1.6 retrieving revision 1.7 diff -C2 -d -r1.6 -r1.7 *** Bag.cs 14 Feb 2005 03:37:27 -0000 1.6 --- Bag.cs 1 Mar 2005 16:24:49 -0000 1.7 *************** *** 17,21 **** /// <summary></summary> ! public override PersistentCollectionType Type { get { return TypeFactory.Bag( Role ); } --- 17,21 ---- /// <summary></summary> ! public override PersistentCollectionType CollectionType { get { return TypeFactory.Bag( Role ); } *************** *** 28,31 **** --- 28,38 ---- } + /// <summary> + /// + /// </summary> + /// <remarks>Should we create an index on the key columns?</remarks> + public override void CreatePrimaryKey( ) + { + } } } \ No newline at end of file Index: IndexedCollection.cs =================================================================== RCS file: /cvsroot/nhibernate/nhibernate/src/NHibernate/Mapping/IndexedCollection.cs,v retrieving revision 1.5 retrieving revision 1.6 diff -C2 -d -r1.5 -r1.6 *** IndexedCollection.cs 31 Dec 2004 21:27:02 -0000 1.5 --- IndexedCollection.cs 1 Mar 2005 16:24:49 -0000 1.6 *************** *** 1,2 **** --- 1,4 ---- + using NHibernate.Engine; + namespace NHibernate.Mapping { *************** *** 10,14 **** public const string DefaultIndexColumnName = "idx"; ! private Value index; /// <summary> --- 12,16 ---- public const string DefaultIndexColumnName = "idx"; ! private SimpleValue index; /// <summary> *************** *** 21,25 **** /// <summary></summary> ! public Value Index { get { return index; } --- 23,27 ---- /// <summary></summary> ! public SimpleValue Index { get { return index; } *************** *** 34,51 **** /// <summary></summary> ! public void CreatePrimaryKey() { ! PrimaryKey pk = new PrimaryKey(); ! ! foreach( Column col in Key.ColumnCollection ) { ! pk.AddColumn( col ); } ! foreach( Column col in Index.ColumnCollection ) { ! pk.AddColumn( col ); } - - Table.PrimaryKey = pk; } } --- 36,71 ---- /// <summary></summary> ! public override void CreatePrimaryKey() { ! if ( !IsOneToMany ) { ! PrimaryKey pk = new PrimaryKey(); ! ! foreach( Column col in Key.ColumnCollection ) ! { ! pk.AddColumn( col ); ! } ! ! // Index should be last column listed ! foreach( Column col in Index.ColumnCollection ) ! { ! pk.AddColumn( col ); ! } ! ! CollectionTable.PrimaryKey = pk; } ! } ! ! /// <summary> ! /// ! /// </summary> ! /// <param name="mapping"></param> ! public override void Validate( IMapping mapping ) ! { ! base.Validate( mapping ); ! if ( !Index.IsValid( mapping ) ) { ! throw new MappingException( string.Format( "collection index mapping has wrong number of columns: {0} type: {1}", Role, Index.Type.Name ) ); } } } Index: List.cs =================================================================== RCS file: /cvsroot/nhibernate/nhibernate/src/NHibernate/Mapping/List.cs,v retrieving revision 1.8 retrieving revision 1.9 diff -C2 -d -r1.8 -r1.9 *** List.cs 14 Feb 2005 03:37:27 -0000 1.8 --- List.cs 1 Mar 2005 16:24:49 -0000 1.9 *************** *** 17,21 **** /// <summary></summary> ! public override PersistentCollectionType Type { get { return TypeFactory.List( Role ); } --- 17,21 ---- /// <summary></summary> ! public override PersistentCollectionType CollectionType { get { return TypeFactory.List( Role ); } --- NEW FILE: IValue.cs --- using System.Collections; using NHibernate.Engine; using NHibernate.Loader; using NHibernate.Type; namespace NHibernate.Mapping { /// <summary> /// A value is anything that is persisted by value, instead of /// by reference. It is essentially a Hibernate IType, together /// with zero or more columns. Values are wrapped by things with /// higher level semantics, for example properties, collections, /// classes. /// </summary> public interface IValue { /// <summary> /// /// </summary> int ColumnSpan { get; } /// <summary> /// /// </summary> ICollection ColumnCollection { get; } /// <summary> /// /// </summary> IType Type { get; } /// <summary> /// /// </summary> Table Table { get; } /// <summary> /// /// </summary> Formula Formula { get; } /// <summary> /// /// </summary> bool IsUnique { get; } /// <summary> /// /// </summary> bool IsNullable { get; } /// <summary> /// /// </summary> bool IsSimpleValue { get; } /// <summary> /// /// </summary> void CreateForeignKey( ); /// <summary> /// /// </summary> /// <param name="mapping"></param> /// <returns></returns> bool IsValid( IMapping mapping ); /// <summary> /// /// </summary> OuterJoinFetchStrategy OuterJoinFetchSetting { get; } } } Index: Component.cs =================================================================== RCS file: /cvsroot/nhibernate/nhibernate/src/NHibernate/Mapping/Component.cs,v retrieving revision 1.6 retrieving revision 1.7 diff -C2 -d -r1.6 -r1.7 *** Component.cs 31 Dec 2004 21:26:38 -0000 1.6 --- Component.cs 1 Mar 2005 16:24:49 -0000 1.7 *************** *** 5,9 **** { /// <summary></summary> ! public class Component : Value { private ArrayList properties = new ArrayList(); --- 5,9 ---- { /// <summary></summary> ! public class Component : SimpleValue { private ArrayList properties = new ArrayList(); *************** *** 11,14 **** --- 11,15 ---- // TODO: H2.0.3 - make sure this is gone from the mapping file... //private BasicDynaClass dynaClass + private bool dynamic; private bool embedded; private string parentProperty; *************** *** 108,111 **** --- 109,119 ---- /// <summary></summary> + public bool IsDynamic + { + get { return dynamic; } + set { dynamic = value; } + } + + /// <summary></summary> public override bool IsComposite { Index: Table.cs =================================================================== RCS file: /cvsroot/nhibernate/nhibernate/src/NHibernate/Mapping/Table.cs,v retrieving revision 1.15 retrieving revision 1.16 diff -C2 -d -r1.15 -r1.16 *** Table.cs 2 Jan 2005 22:03:39 -0000 1.15 --- Table.cs 1 Mar 2005 16:24:49 -0000 1.16 *************** *** 17,21 **** private string schema; private SequencedHashMap columns = new SequencedHashMap(); ! private Value idValue; private PrimaryKey primaryKey; private IDictionary indexes = new Hashtable(); --- 17,21 ---- private string schema; private SequencedHashMap columns = new SequencedHashMap(); ! private SimpleValue idValue; private PrimaryKey primaryKey; private IDictionary indexes = new Hashtable(); *************** *** 25,28 **** --- 25,29 ---- private bool quoted; private static int tableCounter = 0; + private IList checkConstraints = new ArrayList(); /// <summary> *************** *** 496,501 **** /// Sets the Identifier of the Table. /// </summary> ! /// <param name="idValue">The <see cref="Value"/> that represents the Identifier.</param> ! public void SetIdentifierValue( Value idValue ) { this.idValue = idValue; --- 497,502 ---- /// Sets the Identifier of the Table. /// </summary> ! /// <param name="idValue">The <see cref="SimpleValue"/> that represents the Identifier.</param> ! public void SetIdentifierValue( SimpleValue idValue ) { this.idValue = idValue; *************** *** 512,516 **** } ! } } \ No newline at end of file --- 513,524 ---- } ! /// <summary> ! /// ! /// </summary> ! /// <param name="constraint"></param> ! public void AddCheckConstraint( string constraint ) ! { ! checkConstraints.Add( constraint ); ! } } } \ No newline at end of file Index: Subclass.cs =================================================================== RCS file: /cvsroot/nhibernate/nhibernate/src/NHibernate/Mapping/Subclass.cs,v retrieving revision 1.7 retrieving revision 1.8 diff -C2 -d -r1.7 -r1.8 *** Subclass.cs 3 Jan 2005 03:46:48 -0000 1.7 --- Subclass.cs 1 Mar 2005 16:24:49 -0000 1.8 *************** *** 2,5 **** --- 2,6 ---- using System.Collections; using NHibernate.Cache; + using NHibernate.Engine; namespace NHibernate.Mapping *************** *** 12,16 **** { private PersistentClass superclass; ! private Value key; /// <summary> --- 13,18 ---- { private PersistentClass superclass; ! private SimpleValue key; ! private System.Type classPersisterClass; /// <summary> *************** *** 58,61 **** --- 60,85 ---- /// <summary> + /// + /// </summary> + public override System.Type ClassPersisterClass + { + get + { + if ( classPersisterClass == null ) + { + return Superclass.ClassPersisterClass; + } + else + { + return classPersisterClass; + } + } + set + { + classPersisterClass = value; + } + } + + /// <summary> /// Gets or sets the <see cref="Property"/> that is used as the <c>id</c>. /// </summary> *************** *** 70,77 **** /// <summary> ! /// Gets or sets the <see cref="Value"/> that contains information about the identifier. /// </summary> ! /// <value>The <see cref="Value"/> from the Superclass that contains information about the identifier.</value> ! public override Value Identifier { get { return Superclass.Identifier; } --- 94,101 ---- /// <summary> ! /// Gets or sets the <see cref="SimpleValue"/> that contains information about the identifier. /// </summary> ! /// <value>The <see cref="SimpleValue"/> from the Superclass that contains information about the identifier.</value> ! public override SimpleValue Identifier { get { return Superclass.Identifier; } *************** *** 89,96 **** /// <summary> ! /// Gets or sets the <see cref="Value"/> that contains information about the discriminator. /// </summary> ! /// <value>The <see cref="Value"/> from the Superclass that contains information about the discriminator.</value> ! public override Value Discriminator { get { return Superclass.Discriminator; } --- 113,120 ---- /// <summary> ! /// Gets or sets the <see cref="SimpleValue"/> that contains information about the discriminator. /// </summary> ! /// <value>The <see cref="SimpleValue"/> from the Superclass that contains information about the discriminator.</value> ! public override SimpleValue Discriminator { get { return Superclass.Discriminator; } *************** *** 281,294 **** /// <summary> - /// Gets or sets the <see cref="System.Type"/> of the Persister. - /// </summary> - /// <value>The <see cref="System.Type"/> of the Persister for the Superclass.</value> - public override System.Type Persister - { - get { return Superclass.Persister; } - set { Superclass.Persister = value; } - } - - /// <summary> /// Gets the <see cref="Table"/> of the class /// that is mapped in the <c>class</c> element. --- 305,308 ---- *************** *** 303,310 **** /// <summary> ! /// Gets or sets the <see cref="Value"/> that contains information about the Key. /// </summary> ! /// <value>The <see cref="Value"/> that contains information about the Key.</value> ! public override Value Key { get --- 317,324 ---- /// <summary> ! /// Gets or sets the <see cref="SimpleValue"/> that contains information about the Key. /// </summary> ! /// <value>The <see cref="SimpleValue"/> that contains information about the Key.</value> ! public override SimpleValue Key { get *************** *** 350,354 **** --- 364,409 ---- } + /// <summary> + /// + /// </summary> + public override bool IsJoinedSubclass + { + get { return Table != RootTable; } + } + + /// <summary> + /// + /// </summary> + public override bool IsDiscriminatorInsertable + { + get { return Superclass.IsDiscriminatorInsertable ; } + set { throw new InvalidOperationException( "The DiscriminatorInsertable property can not be set on the Subclass - use the Superclass instead." ); } + } + /// <summary> + /// + /// </summary> + /// <param name="mapping"></param> + public override void Validate( IMapping mapping ) + { + base.Validate( mapping ); + if ( Key != null && !Key.IsValid( mapping ) ) + { + throw new MappingException( string.Format( "subclass key has wrong number of columns: {0} type: {1}", MappedClass.Name, Key.Type.Name ) ); + } + } + + /// <summary> + /// + /// </summary> + public void CreateForeignKey( ) + { + if ( !IsJoinedSubclass ) + { + throw new AssertionFailure( "Not a joined-subclass" ); + } + + Key.CreateForeignKeyOfClass( Superclass.MappedClass ); + } } } \ No newline at end of file Index: Array.cs =================================================================== RCS file: /cvsroot/nhibernate/nhibernate/src/NHibernate/Mapping/Array.cs,v retrieving revision 1.4 retrieving revision 1.5 diff -C2 -d -r1.4 -r1.5 *** Array.cs 31 Dec 2004 21:26:26 -0000 1.4 --- Array.cs 1 Mar 2005 16:24:49 -0000 1.5 *************** *** 27,31 **** /// <summary></summary> ! public override PersistentCollectionType Type { get { return TypeFactory.Array( Role, ElementClass ); } --- 27,31 ---- /// <summary></summary> ! public override PersistentCollectionType CollectionType { get { return TypeFactory.Array( Role, ElementClass ); } |
From: Paul H. <pha...@us...> - 2005-03-01 16:25:34
|
Update of /cvsroot/nhibernate/NHibernateContrib/src/NHibernate.Tool.Net2Hbm In directory sc8-pr-cvs1.sourceforge.net:/tmp/cvs-serv5548/NHibernateContrib/src/NHibernate.Tool.Net2Hbm Modified Files: AssemblyInfo.cs Log Message: Various refactorings on the way to 2.1 querying capability Index: AssemblyInfo.cs =================================================================== RCS file: /cvsroot/nhibernate/NHibernateContrib/src/NHibernate.Tool.Net2Hbm/AssemblyInfo.cs,v retrieving revision 1.3 retrieving revision 1.4 diff -C2 -d -r1.3 -r1.4 *** AssemblyInfo.cs 26 Feb 2005 15:26:25 -0000 1.3 --- AssemblyInfo.cs 1 Mar 2005 16:24:38 -0000 1.4 *************** *** 18,24 **** [assembly: AssemblyProductAttribute("NHibernate.Tool.Net2Hbm")] [assembly: AssemblyCopyrightAttribute("Licensed under LGPL.")] ! [assembly: AssemblyVersionAttribute("0.7.0.0")] ! [assembly: AssemblyInformationalVersionAttribute("0.7")] ! [assembly: AssemblyFileVersionAttribute("0.7.0.0")] //[assembly: AssemblyKeyFileAttribute("..\\NHibernate.snk")] --- 18,24 ---- [assembly: AssemblyProductAttribute("NHibernate.Tool.Net2Hbm")] [assembly: AssemblyCopyrightAttribute("Licensed under LGPL.")] ! [assembly: AssemblyVersionAttribute("0.6.0.0")] ! [assembly: AssemblyInformationalVersionAttribute("0.6")] ! [assembly: AssemblyFileVersionAttribute("0.6.0.0")] //[assembly: AssemblyKeyFileAttribute("..\\NHibernate.snk")] |
From: Paul H. <pha...@us...> - 2005-03-01 16:25:34
|
Update of /cvsroot/nhibernate/nhibernate/src/NHibernate/Engine In directory sc8-pr-cvs1.sourceforge.net:/tmp/cvs-serv5548/nhibernate/src/NHibernate/Engine Modified Files: Cascades.cs IMapping.cs ISessionFactoryImplementor.cs ISessionImplementor.cs Log Message: Various refactorings on the way to 2.1 querying capability Index: IMapping.cs =================================================================== RCS file: /cvsroot/nhibernate/nhibernate/src/NHibernate/Engine/IMapping.cs,v retrieving revision 1.3 retrieving revision 1.4 diff -C2 -d -r1.3 -r1.4 *** IMapping.cs 31 Dec 2004 15:38:35 -0000 1.3 --- IMapping.cs 1 Mar 2005 16:24:45 -0000 1.4 *************** *** 12,18 **** /// /// </summary> ! /// <param name="persistentType"></param> /// <returns></returns> ! IType GetIdentifierType( System.Type persistentType ); } } \ No newline at end of file --- 12,33 ---- /// /// </summary> ! /// <param name="persistentClass"></param> /// <returns></returns> ! IType GetIdentifierType( System.Type persistentClass ); ! ! /// <summary> ! /// ! /// </summary> ! /// <param name="persistentClass"></param> ! /// <returns></returns> ! string GetIdentifierPropertyName( System.Type persistentClass ); ! ! /// <summary> ! /// ! /// </summary> ! /// <param name="persistentClass"></param> ! /// <param name="propertyName"></param> ! /// <returns></returns> ! IType GetPropertyType( System.Type persistentClass, string propertyName ); } } \ No newline at end of file Index: ISessionImplementor.cs =================================================================== RCS file: /cvsroot/nhibernate/nhibernate/src/NHibernate/Engine/ISessionImplementor.cs,v retrieving revision 1.29 retrieving revision 1.30 diff -C2 -d -r1.29 -r1.30 *** ISessionImplementor.cs 16 Feb 2005 20:14:19 -0000 1.29 --- ISessionImplementor.cs 1 Mar 2005 16:24:46 -0000 1.30 *************** *** 63,67 **** /// <param name="id"></param> /// <returns></returns> ! PersistentCollection GetLoadingCollection( CollectionPersister persister, object id ); /// <summary> --- 63,67 ---- /// <param name="id"></param> /// <returns></returns> ! PersistentCollection GetLoadingCollection( ICollectionPersister persister, object id ); /// <summary> Index: ISessionFactoryImplementor.cs =================================================================== RCS file: /cvsroot/nhibernate/nhibernate/src/NHibernate/Engine/ISessionFactoryImplementor.cs,v retrieving revision 1.13 retrieving revision 1.14 diff -C2 -d -r1.13 -r1.14 *** ISessionFactoryImplementor.cs 31 Dec 2004 17:36:22 -0000 1.13 --- ISessionFactoryImplementor.cs 1 Mar 2005 16:24:46 -0000 1.14 *************** *** 54,58 **** /// <param name="role"></param> /// <returns></returns> ! CollectionPersister GetCollectionPersister( string role ); /// <summary> --- 54,58 ---- /// <param name="role"></param> /// <returns></returns> ! ICollectionPersister GetCollectionPersister( string role ); /// <summary> Index: Cascades.cs =================================================================== RCS file: /cvsroot/nhibernate/nhibernate/src/NHibernate/Engine/Cascades.cs,v retrieving revision 1.15 retrieving revision 1.16 diff -C2 -d -r1.15 -r1.16 *** Cascades.cs 14 Feb 2005 03:22:27 -0000 1.15 --- Cascades.cs 1 Mar 2005 16:24:45 -0000 1.16 *************** *** 383,387 **** PersistentCollectionType pctype = ( PersistentCollectionType ) type; ! CollectionPersister persister = session.Factory.GetCollectionPersister( pctype.Role ); IType elemType = persister.ElementType; --- 383,387 ---- PersistentCollectionType pctype = ( PersistentCollectionType ) type; ! ICollectionPersister persister = session.Factory.GetCollectionPersister( pctype.Role ); IType elemType = persister.ElementType; |
From: Paul H. <pha...@us...> - 2005-03-01 16:25:33
|
Update of /cvsroot/nhibernate/nhibernate/src/NHibernate/Dialect In directory sc8-pr-cvs1.sourceforge.net:/tmp/cvs-serv5548/nhibernate/src/NHibernate/Dialect Modified Files: DB2Dialect.cs Dialect.cs FirebirdDialect.cs GenericDialect.cs MsSql2000Dialect.cs MySQLDialect.cs Oracle9Dialect.cs PostgreSQLDialect.cs SQLiteDialect.cs Added Files: ISQLFunction.cs NoArgSQLFunction.cs StandardSQLFunction.cs Log Message: Various refactorings on the way to 2.1 querying capability Index: FirebirdDialect.cs =================================================================== RCS file: /cvsroot/nhibernate/nhibernate/src/NHibernate/Dialect/FirebirdDialect.cs,v retrieving revision 1.10 retrieving revision 1.11 diff -C2 -d -r1.10 -r1.11 *** FirebirdDialect.cs 17 Jan 2005 22:31:47 -0000 1.10 --- FirebirdDialect.cs 1 Mar 2005 16:24:44 -0000 1.11 *************** *** 25,52 **** public FirebirdDialect() : base() { ! Register( DbType.AnsiStringFixedLength, "CHAR(255)" ); ! Register( DbType.AnsiStringFixedLength, 8000, "CHAR($1)" ); ! Register( DbType.AnsiString, "VARCHAR(255)" ); ! Register( DbType.AnsiString, 8000, "VARCHAR($1)" ); ! Register( DbType.AnsiString, 2147483647, "BLOB" ); // should use the IType.ClobType ! Register( DbType.Binary, 2147483647, "BLOB SUB_TYPE 0" ); // should use the IType.BlobType ! Register( DbType.Boolean, "SMALLINT" ); ! Register( DbType.Byte, "SMALLINT" ); ! Register( DbType.Currency, "DECIMAL(16,4)" ); ! Register( DbType.Date, "DATE" ); ! Register( DbType.DateTime, "TIMESTAMP" ); ! Register( DbType.Decimal, "DECIMAL(18,0)" ); // NUMERIC(18,0) is equivalent to DECIMAL(18,0) ! Register( DbType.Decimal, 18, "DECIMAL(18, $1)" ); ! Register( DbType.Double, "DOUBLE PRECISION" ); ! Register( DbType.Int16, "SMALLINT" ); ! Register( DbType.Int32, "INTEGER" ); ! Register( DbType.Int64, "BIGINT" ); ! Register( DbType.Single, "FLOAT" ); ! Register( DbType.StringFixedLength, "CHAR(255)" ); ! Register( DbType.StringFixedLength, 4000, "CHAR($1)" ); ! Register( DbType.String, "VARCHAR(255)" ); ! Register( DbType.String, 4000, "VARCHAR($1)" ); ! Register( DbType.String, 1073741823, "BLOB SUB_TYPE 1" ); // should use the IType.ClobType ! Register( DbType.Time, "TIME" ); DefaultProperties[ Environment.ConnectionDriver ] = "NHibernate.Driver.FirebirdDriver"; --- 25,52 ---- public FirebirdDialect() : base() { ! RegisterColumnType( DbType.AnsiStringFixedLength, "CHAR(255)" ); ! RegisterColumnType( DbType.AnsiStringFixedLength, 8000, "CHAR($1)" ); ! RegisterColumnType( DbType.AnsiString, "VARCHAR(255)" ); ! RegisterColumnType( DbType.AnsiString, 8000, "VARCHAR($1)" ); ! RegisterColumnType( DbType.AnsiString, 2147483647, "BLOB" ); // should use the IType.ClobType ! RegisterColumnType( DbType.Binary, 2147483647, "BLOB SUB_TYPE 0" ); // should use the IType.BlobType ! RegisterColumnType( DbType.Boolean, "SMALLINT" ); ! RegisterColumnType( DbType.Byte, "SMALLINT" ); ! RegisterColumnType( DbType.Currency, "DECIMAL(16,4)" ); ! RegisterColumnType( DbType.Date, "DATE" ); ! RegisterColumnType( DbType.DateTime, "TIMESTAMP" ); ! RegisterColumnType( DbType.Decimal, "DECIMAL(18,0)" ); // NUMERIC(18,0) is equivalent to DECIMAL(18,0) ! RegisterColumnType( DbType.Decimal, 18, "DECIMAL(18, $1)" ); ! RegisterColumnType( DbType.Double, "DOUBLE PRECISION" ); ! RegisterColumnType( DbType.Int16, "SMALLINT" ); ! RegisterColumnType( DbType.Int32, "INTEGER" ); ! RegisterColumnType( DbType.Int64, "BIGINT" ); ! RegisterColumnType( DbType.Single, "FLOAT" ); ! RegisterColumnType( DbType.StringFixedLength, "CHAR(255)" ); ! RegisterColumnType( DbType.StringFixedLength, 4000, "CHAR($1)" ); ! RegisterColumnType( DbType.String, "VARCHAR(255)" ); ! RegisterColumnType( DbType.String, 4000, "VARCHAR($1)" ); ! RegisterColumnType( DbType.String, 1073741823, "BLOB SUB_TYPE 1" ); // should use the IType.ClobType ! RegisterColumnType( DbType.Time, "TIME" ); DefaultProperties[ Environment.ConnectionDriver ] = "NHibernate.Driver.FirebirdDriver"; Index: SQLiteDialect.cs =================================================================== RCS file: /cvsroot/nhibernate/nhibernate/src/NHibernate/Dialect/SQLiteDialect.cs,v retrieving revision 1.1 retrieving revision 1.2 diff -C2 -d -r1.1 -r1.2 *** SQLiteDialect.cs 14 Feb 2005 03:58:53 -0000 1.1 --- SQLiteDialect.cs 1 Mar 2005 16:24:44 -0000 1.2 *************** *** 14,36 **** public class SQLiteDialect : Dialect { public SQLiteDialect() { ! Register(DbType.Binary, "BLOB"); ! Register(DbType.Byte, "INTEGER"); ! Register(DbType.Int16, "INTEGER"); ! Register(DbType.Int32, "INTEGER"); ! Register(DbType.Int64, "INTEGER"); ! Register(DbType.SByte, "INTEGER"); ! Register(DbType.UInt16, "INTEGER"); ! Register(DbType.UInt32, "INTEGER"); ! Register(DbType.UInt64, "INTEGER"); ! Register(DbType.Currency, "NUMERIC"); ! Register(DbType.Decimal, "NUMERIC"); ! Register(DbType.Double, "NUMERIC"); ! Register(DbType.Single, "NUMERIC"); ! Register(DbType.VarNumeric, "NUMERIC"); ! Register(DbType.String, "TEXT"); } public override string IdentitySelectString { --- 14,42 ---- public class SQLiteDialect : Dialect { + /// <summary> + /// + /// </summary> public SQLiteDialect() { ! RegisterColumnType(DbType.Binary, "BLOB"); ! RegisterColumnType(DbType.Byte, "INTEGER"); ! RegisterColumnType(DbType.Int16, "INTEGER"); ! RegisterColumnType(DbType.Int32, "INTEGER"); ! RegisterColumnType(DbType.Int64, "INTEGER"); ! RegisterColumnType(DbType.SByte, "INTEGER"); ! RegisterColumnType(DbType.UInt16, "INTEGER"); ! RegisterColumnType(DbType.UInt32, "INTEGER"); ! RegisterColumnType(DbType.UInt64, "INTEGER"); ! RegisterColumnType(DbType.Currency, "NUMERIC"); ! RegisterColumnType(DbType.Decimal, "NUMERIC"); ! RegisterColumnType(DbType.Double, "NUMERIC"); ! RegisterColumnType(DbType.Single, "NUMERIC"); ! RegisterColumnType(DbType.VarNumeric, "NUMERIC"); ! RegisterColumnType(DbType.String, "TEXT"); } + /// <summary> + /// + /// </summary> public override string IdentitySelectString { Index: GenericDialect.cs =================================================================== RCS file: /cvsroot/nhibernate/nhibernate/src/NHibernate/Dialect/GenericDialect.cs,v retrieving revision 1.10 retrieving revision 1.11 diff -C2 -d -r1.10 -r1.11 *** GenericDialect.cs 31 Dec 2004 17:07:24 -0000 1.10 --- GenericDialect.cs 1 Mar 2005 16:24:44 -0000 1.11 *************** *** 11,32 **** public GenericDialect() : base() { ! Register( DbType.AnsiStringFixedLength, "CHAR($1)" ); ! Register( DbType.AnsiString, "VARCHAR($1)" ); ! Register( DbType.Binary, "VARBINARY($1)" ); ! Register( DbType.Boolean, "BIT" ); ! Register( DbType.Byte, "TINYINT" ); ! Register( DbType.Currency, "MONEY" ); ! Register( DbType.Date, "DATE" ); ! Register( DbType.DateTime, "DATETIME" ); ! Register( DbType.Decimal, "DECIMAL(19, $1)" ); ! Register( DbType.Double, "DOUBLE PRECISION" ); ! Register( DbType.Guid, "UNIQUEIDENTIFIER" ); ! Register( DbType.Int16, "SMALLINT" ); ! Register( DbType.Int32, "INT" ); ! Register( DbType.Int64, "BIGINT" ); ! Register( DbType.Single, "REAL" ); ! Register( DbType.StringFixedLength, "NCHAR($1)" ); ! Register( DbType.String, "NVARCHAR($1)" ); ! Register( DbType.Time, "TIME" ); } --- 11,32 ---- public GenericDialect() : base() { ! RegisterColumnType( DbType.AnsiStringFixedLength, "CHAR($1)" ); ! RegisterColumnType( DbType.AnsiString, "VARCHAR($1)" ); ! RegisterColumnType( DbType.Binary, "VARBINARY($1)" ); ! RegisterColumnType( DbType.Boolean, "BIT" ); ! RegisterColumnType( DbType.Byte, "TINYINT" ); ! RegisterColumnType( DbType.Currency, "MONEY" ); ! RegisterColumnType( DbType.Date, "DATE" ); ! RegisterColumnType( DbType.DateTime, "DATETIME" ); ! RegisterColumnType( DbType.Decimal, "DECIMAL(19, $1)" ); ! RegisterColumnType( DbType.Double, "DOUBLE PRECISION" ); ! RegisterColumnType( DbType.Guid, "UNIQUEIDENTIFIER" ); ! RegisterColumnType( DbType.Int16, "SMALLINT" ); ! RegisterColumnType( DbType.Int32, "INT" ); ! RegisterColumnType( DbType.Int64, "BIGINT" ); ! RegisterColumnType( DbType.Single, "REAL" ); ! RegisterColumnType( DbType.StringFixedLength, "NCHAR($1)" ); ! RegisterColumnType( DbType.String, "NVARCHAR($1)" ); ! RegisterColumnType( DbType.Time, "TIME" ); } --- NEW FILE: ISQLFunction.cs --- using NHibernate.Engine; using NHibernate.Hql; using NHibernate.Type; namespace NHibernate.Dialect { /// <summary> /// Provides support routines for the HQL functions as used /// in the various SQL Dialects /// /// Provides an interface for supporting various HQL functions that are /// translated to SQL. The Dialect and its sub-classes use this interface to /// provide details required for processing of the function. /// </summary> public interface ISQLFunction { /// <summary> /// /// </summary> /// <param name="columnType"></param> /// <param name="mapping"></param> /// <returns></returns> IType ReturnType( IType columnType, IMapping mapping ); /// <summary> /// /// </summary> bool HasArguments { get; } /// <summary> /// /// </summary> bool HasParenthesesIfNoArguments { get; } } } Index: MySQLDialect.cs =================================================================== RCS file: /cvsroot/nhibernate/nhibernate/src/NHibernate/Dialect/MySQLDialect.cs,v retrieving revision 1.26 retrieving revision 1.27 diff -C2 -d -r1.26 -r1.27 *** MySQLDialect.cs 9 Feb 2005 03:09:38 -0000 1.26 --- MySQLDialect.cs 1 Mar 2005 16:24:44 -0000 1.27 *************** *** 34,71 **** public MySQLDialect() : base() { ! Register( DbType.AnsiStringFixedLength, "CHAR(255)" ); ! Register( DbType.AnsiStringFixedLength, 255, "CHAR($1)" ); ! Register( DbType.AnsiStringFixedLength, 65535, "TEXT" ); ! Register( DbType.AnsiStringFixedLength, 16777215, "MEDIUMTEXT" ); ! Register( DbType.AnsiString, "VARCHAR(255)" ); ! Register( DbType.AnsiString, 255, "VARCHAR($1)" ); ! Register( DbType.AnsiString, 65535, "TEXT" ); ! Register( DbType.AnsiString, 16777215, "MEDIUMTEXT" ); ! Register( DbType.Binary, "LONGBLOB" ); ! Register( DbType.Binary, 127, "TINYBLOB" ); ! Register( DbType.Binary, 65535, "BLOB" ); ! Register( DbType.Binary, 16777215, "MEDIUMBLOB" ); ! Register( DbType.Boolean, "TINYINT(1)" ); ! Register( DbType.Byte, "TINYINT UNSIGNED" ); ! Register( DbType.Currency, "MONEY" ); ! Register( DbType.Date, "DATE" ); ! Register( DbType.DateTime, "DATETIME" ); ! Register( DbType.Decimal, "NUMERIC(19,5)" ); ! Register( DbType.Decimal, 19, "NUMERIC(19, $1)" ); ! Register( DbType.Double, "DOUBLE" ); ! Register( DbType.Guid, "VARCHAR(40)" ); ! Register( DbType.Int16, "SMALLINT" ); ! Register( DbType.Int32, "INTEGER" ); ! Register( DbType.Int64, "BIGINT" ); ! Register( DbType.Single, "FLOAT" ); ! Register( DbType.StringFixedLength, "CHAR(255)" ); ! Register( DbType.StringFixedLength, 255, "CHAR($1)" ); ! Register( DbType.StringFixedLength, 65535, "TEXT" ); ! Register( DbType.StringFixedLength, 16777215, "MEDIUMTEXT" ); ! Register( DbType.String, "VARCHAR(255)" ); ! Register( DbType.String, 255, "VARCHAR($1)" ); ! Register( DbType.String, 65535, "TEXT" ); ! Register( DbType.String, 16777215, "MEDIUMTEXT" ); ! Register( DbType.Time, "TIME" ); DefaultProperties[ Environment.OuterJoin ] = "true"; --- 34,71 ---- public MySQLDialect() : base() { ! RegisterColumnType( DbType.AnsiStringFixedLength, "CHAR(255)" ); ! RegisterColumnType( DbType.AnsiStringFixedLength, 255, "CHAR($1)" ); ! RegisterColumnType( DbType.AnsiStringFixedLength, 65535, "TEXT" ); ! RegisterColumnType( DbType.AnsiStringFixedLength, 16777215, "MEDIUMTEXT" ); ! RegisterColumnType( DbType.AnsiString, "VARCHAR(255)" ); ! RegisterColumnType( DbType.AnsiString, 255, "VARCHAR($1)" ); ! RegisterColumnType( DbType.AnsiString, 65535, "TEXT" ); ! RegisterColumnType( DbType.AnsiString, 16777215, "MEDIUMTEXT" ); ! RegisterColumnType( DbType.Binary, "LONGBLOB" ); ! RegisterColumnType( DbType.Binary, 127, "TINYBLOB" ); ! RegisterColumnType( DbType.Binary, 65535, "BLOB" ); ! RegisterColumnType( DbType.Binary, 16777215, "MEDIUMBLOB" ); ! RegisterColumnType( DbType.Boolean, "TINYINT(1)" ); ! RegisterColumnType( DbType.Byte, "TINYINT UNSIGNED" ); ! RegisterColumnType( DbType.Currency, "MONEY" ); ! RegisterColumnType( DbType.Date, "DATE" ); ! RegisterColumnType( DbType.DateTime, "DATETIME" ); ! RegisterColumnType( DbType.Decimal, "NUMERIC(19,5)" ); ! RegisterColumnType( DbType.Decimal, 19, "NUMERIC(19, $1)" ); ! RegisterColumnType( DbType.Double, "DOUBLE" ); ! RegisterColumnType( DbType.Guid, "VARCHAR(40)" ); ! RegisterColumnType( DbType.Int16, "SMALLINT" ); ! RegisterColumnType( DbType.Int32, "INTEGER" ); ! RegisterColumnType( DbType.Int64, "BIGINT" ); ! RegisterColumnType( DbType.Single, "FLOAT" ); ! RegisterColumnType( DbType.StringFixedLength, "CHAR(255)" ); ! RegisterColumnType( DbType.StringFixedLength, 255, "CHAR($1)" ); ! RegisterColumnType( DbType.StringFixedLength, 65535, "TEXT" ); ! RegisterColumnType( DbType.StringFixedLength, 16777215, "MEDIUMTEXT" ); ! RegisterColumnType( DbType.String, "VARCHAR(255)" ); ! RegisterColumnType( DbType.String, 255, "VARCHAR($1)" ); ! RegisterColumnType( DbType.String, 65535, "TEXT" ); ! RegisterColumnType( DbType.String, 16777215, "MEDIUMTEXT" ); ! RegisterColumnType( DbType.Time, "TIME" ); DefaultProperties[ Environment.OuterJoin ] = "true"; Index: PostgreSQLDialect.cs =================================================================== RCS file: /cvsroot/nhibernate/nhibernate/src/NHibernate/Dialect/PostgreSQLDialect.cs,v retrieving revision 1.15 retrieving revision 1.16 diff -C2 -d -r1.15 -r1.16 *** PostgreSQLDialect.cs 30 Jan 2005 19:39:11 -0000 1.15 --- PostgreSQLDialect.cs 1 Mar 2005 16:24:44 -0000 1.16 *************** *** 31,58 **** public PostgreSQLDialect() { ! Register( DbType.AnsiStringFixedLength, "char(255)" ); ! Register( DbType.AnsiStringFixedLength, 8000, "char($1)" ); ! Register( DbType.AnsiString, "varchar(255)" ); ! Register( DbType.AnsiString, 8000, "varchar($1)" ); ! Register( DbType.AnsiString, 2147483647, "text" ); ! Register( DbType.Binary, 2147483647, "bytea" ); ! Register( DbType.Boolean, "boolean" ); ! Register( DbType.Byte, "int2" ); ! Register( DbType.Currency, "decimal(16,4)" ); ! Register( DbType.Date, "date" ); ! Register( DbType.DateTime, "timestamp" ); ! Register( DbType.Decimal, "decimal(19,5)" ); ! Register( DbType.Decimal, 19, "decimal(18, $1)" ); ! Register( DbType.Double, "float8" ); ! Register( DbType.Int16, "int2" ); ! Register( DbType.Int32, "int4" ); ! Register( DbType.Int64, "int8" ); ! Register( DbType.Single, "float4" ); ! Register( DbType.StringFixedLength, "char(255)" ); ! Register( DbType.StringFixedLength, 4000, "char($1)" ); ! Register( DbType.String, "varchar(255)" ); ! Register( DbType.String, 4000, "varchar($1)" ); ! Register( DbType.String, 1073741823, "text" ); // ! Register( DbType.Time, "time" ); DefaultProperties[ Environment.OuterJoin ] = "true"; --- 31,58 ---- public PostgreSQLDialect() { ! RegisterColumnType( DbType.AnsiStringFixedLength, "char(255)" ); ! RegisterColumnType( DbType.AnsiStringFixedLength, 8000, "char($1)" ); ! RegisterColumnType( DbType.AnsiString, "varchar(255)" ); ! RegisterColumnType( DbType.AnsiString, 8000, "varchar($1)" ); ! RegisterColumnType( DbType.AnsiString, 2147483647, "text" ); ! RegisterColumnType( DbType.Binary, 2147483647, "bytea" ); ! RegisterColumnType( DbType.Boolean, "boolean" ); ! RegisterColumnType( DbType.Byte, "int2" ); ! RegisterColumnType( DbType.Currency, "decimal(16,4)" ); ! RegisterColumnType( DbType.Date, "date" ); ! RegisterColumnType( DbType.DateTime, "timestamp" ); ! RegisterColumnType( DbType.Decimal, "decimal(19,5)" ); ! RegisterColumnType( DbType.Decimal, 19, "decimal(18, $1)" ); ! RegisterColumnType( DbType.Double, "float8" ); ! RegisterColumnType( DbType.Int16, "int2" ); ! RegisterColumnType( DbType.Int32, "int4" ); ! RegisterColumnType( DbType.Int64, "int8" ); ! RegisterColumnType( DbType.Single, "float4" ); ! RegisterColumnType( DbType.StringFixedLength, "char(255)" ); ! RegisterColumnType( DbType.StringFixedLength, 4000, "char($1)" ); ! RegisterColumnType( DbType.String, "varchar(255)" ); ! RegisterColumnType( DbType.String, 4000, "varchar($1)" ); ! RegisterColumnType( DbType.String, 1073741823, "text" ); // ! RegisterColumnType( DbType.Time, "time" ); DefaultProperties[ Environment.OuterJoin ] = "true"; --- NEW FILE: NoArgSQLFunction.cs --- using NHibernate.Engine; using NHibernate.Hql; using NHibernate.Type; namespace NHibernate.Dialect { /// <summary> /// Summary description for NoArgSQLFunction. /// </summary> public class NoArgSQLFunction : ISQLFunction { private IType returnType; private bool hasParenthesesIfNoArguments; /// <summary> /// /// </summary> /// <param name="returnType"></param> public NoArgSQLFunction( IType returnType ) : this( returnType, true ) { } /// <summary> /// /// </summary> /// <param name="returnType"></param> /// <param name="hasParenthesesIfNoArguments"></param> public NoArgSQLFunction( IType returnType, bool hasParenthesesIfNoArguments ) { this.returnType = returnType; this.hasParenthesesIfNoArguments = hasParenthesesIfNoArguments; } #region ISQLFunction Members /// <summary> /// /// </summary> /// <param name="columnType"></param> /// <param name="mapping"></param> /// <returns></returns> public IType ReturnType(IType columnType, IMapping mapping) { return returnType; } /// <summary> /// /// </summary> public bool HasArguments { get { return false; } } /// <summary> /// /// </summary> public bool HasParenthesesIfNoArguments { get { return hasParenthesesIfNoArguments; } } #endregion } } Index: DB2Dialect.cs =================================================================== RCS file: /cvsroot/nhibernate/nhibernate/src/NHibernate/Dialect/DB2Dialect.cs,v retrieving revision 1.9 retrieving revision 1.10 diff -C2 -d -r1.9 -r1.10 *** DB2Dialect.cs 30 Jan 2005 19:39:11 -0000 1.9 --- DB2Dialect.cs 1 Mar 2005 16:24:44 -0000 1.10 *************** *** 32,59 **** public DB2Dialect() { ! Register( DbType.AnsiStringFixedLength, "CHAR(254)" ); ! Register( DbType.AnsiStringFixedLength, 254, "CHAR($1)" ); ! Register( DbType.AnsiString, "VARCHAR(254)" ); ! Register( DbType.AnsiString, 8000, "VARCHAR($1)" ); ! Register( DbType.AnsiString, 2147483647, "CLOB" ); ! Register( DbType.Binary, 2147483647, "BLOB" ); ! Register( DbType.Boolean, "SMALLINT" ); ! Register( DbType.Byte, "SMALLINT" ); ! Register( DbType.Currency, "DECIMAL(16,4)" ); ! Register( DbType.Date, "DATE" ); ! Register( DbType.DateTime, "TIMESTAMP" ); ! Register( DbType.Decimal, "DECIMAL(19,5)" ); ! Register( DbType.Decimal, 19, "DECIMAL(19, $1)" ); ! Register( DbType.Double, "DOUBLE" ); ! Register( DbType.Int16, "SMALLINT" ); ! Register( DbType.Int32, "INTEGER" ); ! Register( DbType.Int64, "BIGINT" ); ! Register( DbType.Single, "REAL" ); ! Register( DbType.StringFixedLength, "CHAR(254)" ); ! Register( DbType.StringFixedLength, 254, "CHAR($1)" ); ! Register( DbType.String, "VARCHAR(254)" ); ! Register( DbType.String, 8000, "VARCHAR($1)" ); ! Register( DbType.String, 2147483647, "CLOB" ); ! Register( DbType.Time, "TIME" ); DefaultProperties[ Environment.OuterJoin ] = "true"; --- 32,129 ---- public DB2Dialect() { ! RegisterColumnType( DbType.AnsiStringFixedLength, "CHAR(254)" ); ! RegisterColumnType( DbType.AnsiStringFixedLength, 254, "CHAR($1)" ); ! RegisterColumnType( DbType.AnsiString, "VARCHAR(254)" ); ! RegisterColumnType( DbType.AnsiString, 8000, "VARCHAR($1)" ); ! RegisterColumnType( DbType.AnsiString, 2147483647, "CLOB" ); ! RegisterColumnType( DbType.Binary, 2147483647, "BLOB" ); ! RegisterColumnType( DbType.Boolean, "SMALLINT" ); ! RegisterColumnType( DbType.Byte, "SMALLINT" ); ! RegisterColumnType( DbType.Currency, "DECIMAL(16,4)" ); ! RegisterColumnType( DbType.Date, "DATE" ); ! RegisterColumnType( DbType.DateTime, "TIMESTAMP" ); ! RegisterColumnType( DbType.Decimal, "DECIMAL(19,5)" ); ! RegisterColumnType( DbType.Decimal, 19, "DECIMAL(19, $1)" ); ! RegisterColumnType( DbType.Double, "DOUBLE" ); ! RegisterColumnType( DbType.Int16, "SMALLINT" ); ! RegisterColumnType( DbType.Int32, "INTEGER" ); ! RegisterColumnType( DbType.Int64, "BIGINT" ); ! RegisterColumnType( DbType.Single, "REAL" ); ! RegisterColumnType( DbType.StringFixedLength, "CHAR(254)" ); ! RegisterColumnType( DbType.StringFixedLength, 254, "CHAR($1)" ); ! RegisterColumnType( DbType.String, "VARCHAR(254)" ); ! RegisterColumnType( DbType.String, 8000, "VARCHAR($1)" ); ! RegisterColumnType( DbType.String, 2147483647, "CLOB" ); ! RegisterColumnType( DbType.Time, "TIME" ); ! ! RegisterFunction("abs", new StandardSQLFunction() ); ! RegisterFunction("absval", new StandardSQLFunction() ); ! RegisterFunction("sign", new StandardSQLFunction( NHibernateUtil.Int32 ) ); ! ! RegisterFunction("ceiling", new StandardSQLFunction() ); ! RegisterFunction("ceil", new StandardSQLFunction() ); ! RegisterFunction("floor", new StandardSQLFunction() ); ! RegisterFunction("round", new StandardSQLFunction() ); ! ! RegisterFunction("acos", new StandardSQLFunction( NHibernateUtil.Double ) ); ! RegisterFunction("asin", new StandardSQLFunction( NHibernateUtil.Double ) ); ! RegisterFunction("atan", new StandardSQLFunction( NHibernateUtil.Double ) ); ! RegisterFunction("cos", new StandardSQLFunction( NHibernateUtil.Double ) ); ! RegisterFunction("cot", new StandardSQLFunction( NHibernateUtil.Double ) ); ! RegisterFunction("degrees", new StandardSQLFunction( NHibernateUtil.Double ) ); ! RegisterFunction("exp", new StandardSQLFunction( NHibernateUtil.Double ) ); ! RegisterFunction("float", new StandardSQLFunction( NHibernateUtil.Double ) ); ! RegisterFunction("hex", new StandardSQLFunction( NHibernateUtil.String ) ); ! RegisterFunction("ln", new StandardSQLFunction( NHibernateUtil.Double ) ); ! RegisterFunction("log", new StandardSQLFunction( NHibernateUtil.Double ) ); ! RegisterFunction("log10", new StandardSQLFunction( NHibernateUtil.Double ) ); ! RegisterFunction("radians", new StandardSQLFunction( NHibernateUtil.Double ) ); ! RegisterFunction("rand", new NoArgSQLFunction( NHibernateUtil.Double )); ! RegisterFunction("sin", new StandardSQLFunction( NHibernateUtil.Double ) ); ! RegisterFunction("soundex", new StandardSQLFunction( NHibernateUtil.String ) ); ! RegisterFunction("sqrt", new StandardSQLFunction( NHibernateUtil.Double ) ); ! RegisterFunction("stddev", new StandardSQLFunction( NHibernateUtil.Double ) ); ! RegisterFunction("tan", new StandardSQLFunction( NHibernateUtil.Double ) ); ! RegisterFunction("variance", new StandardSQLFunction( NHibernateUtil.Double ) ); ! ! RegisterFunction("julian_day", new StandardSQLFunction( NHibernateUtil.Int32 ) ); ! RegisterFunction("microsecond", new StandardSQLFunction( NHibernateUtil.Int32 ) ); ! RegisterFunction("midnight_seconds", new StandardSQLFunction( NHibernateUtil.Int32 ) ); ! RegisterFunction("minute", new StandardSQLFunction( NHibernateUtil.Int32 ) ); ! RegisterFunction("month", new StandardSQLFunction( NHibernateUtil.Int32 ) ); ! RegisterFunction("monthname", new StandardSQLFunction( NHibernateUtil.String ) ); ! RegisterFunction("quarter", new StandardSQLFunction( NHibernateUtil.Int32 ) ); ! RegisterFunction("hour", new StandardSQLFunction( NHibernateUtil.Int32 ) ); ! RegisterFunction("second", new StandardSQLFunction( NHibernateUtil.Int32 ) ); ! RegisterFunction("date", new StandardSQLFunction( NHibernateUtil.Date ) ); ! RegisterFunction("day", new StandardSQLFunction( NHibernateUtil.Int32 ) ); ! RegisterFunction("dayname", new StandardSQLFunction( NHibernateUtil.String ) ); ! RegisterFunction("dayofweek", new StandardSQLFunction( NHibernateUtil.Int32 ) ); ! RegisterFunction("dayofweek_iso", new StandardSQLFunction( NHibernateUtil.Int32 ) ); ! RegisterFunction("dayofyear", new StandardSQLFunction( NHibernateUtil.Int32 ) ); ! RegisterFunction("days", new StandardSQLFunction( NHibernateUtil.Int32 ) ); ! RegisterFunction("time", new StandardSQLFunction( NHibernateUtil.Time ) ); ! RegisterFunction("timestamp", new StandardSQLFunction( NHibernateUtil.Timestamp ) ); ! RegisterFunction("timestamp_iso", new StandardSQLFunction( NHibernateUtil.Timestamp ) ); ! RegisterFunction("week", new StandardSQLFunction( NHibernateUtil.Int32 ) ); ! RegisterFunction("week_iso", new StandardSQLFunction( NHibernateUtil.Int32 ) ); ! RegisterFunction("year", new StandardSQLFunction( NHibernateUtil.Int32 ) ); ! ! RegisterFunction("double", new StandardSQLFunction( NHibernateUtil.Double ) ); ! RegisterFunction("varchar", new StandardSQLFunction( NHibernateUtil.String ) ); ! RegisterFunction("real", new StandardSQLFunction( NHibernateUtil.Single ) ); ! RegisterFunction("bigint", new StandardSQLFunction( NHibernateUtil.Int32 ) ); ! RegisterFunction("char", new StandardSQLFunction( NHibernateUtil.Character ) ); ! RegisterFunction("integer", new StandardSQLFunction( NHibernateUtil.Int32 ) ); ! RegisterFunction("smallint", new StandardSQLFunction( NHibernateUtil.Int16 ) ); ! ! RegisterFunction("digits", new StandardSQLFunction( NHibernateUtil.String ) ); ! RegisterFunction("chr", new StandardSQLFunction( NHibernateUtil.Character ) ); ! RegisterFunction("upper", new StandardSQLFunction() ); ! RegisterFunction("ucase", new StandardSQLFunction() ); ! RegisterFunction("lcase", new StandardSQLFunction() ); ! RegisterFunction("lower", new StandardSQLFunction() ); ! RegisterFunction("length", new StandardSQLFunction( NHibernateUtil.Int32 ) ); ! RegisterFunction("ltrim", new StandardSQLFunction() ); DefaultProperties[ Environment.OuterJoin ] = "true"; --- NEW FILE: StandardSQLFunction.cs --- using NHibernate.Engine; using NHibernate.Hql; using NHibernate.Type; namespace NHibernate.Dialect { /// <summary> /// Provides a standard implementation that supports the majority of the HQL /// functions that are translated to SQL. /// </summary> /// <remarks> /// The Dialect and its sub-classes use this class to provide details required /// for processing of the associated function. /// </remarks> public class StandardSQLFunction : ISQLFunction { private IType returnType = null; /// <summary> /// /// </summary> public StandardSQLFunction() { } /// <summary> /// /// </summary> /// <param name="typeValue"></param> public StandardSQLFunction( IType typeValue ) { returnType = typeValue; } /// <summary> /// /// </summary> /// <param name="columnType"></param> /// <param name="mapping"></param> /// <returns></returns> public IType ReturnType( IType columnType, IMapping mapping ) { if ( returnType == null ) return columnType; return returnType; } /// <summary> /// /// </summary> public bool HasArguments { get { return true; } } /// <summary> /// /// </summary> public bool HasParenthesesIfNoArguments { get { return true; } } } } Index: MsSql2000Dialect.cs =================================================================== RCS file: /cvsroot/nhibernate/nhibernate/src/NHibernate/Dialect/MsSql2000Dialect.cs,v retrieving revision 1.24 retrieving revision 1.25 diff -C2 -d -r1.24 -r1.25 *** MsSql2000Dialect.cs 30 Jan 2005 20:03:33 -0000 1.24 --- MsSql2000Dialect.cs 1 Mar 2005 16:24:44 -0000 1.25 *************** *** 34,50 **** public MsSql2000Dialect() : base() { ! Register( DbType.AnsiStringFixedLength, "CHAR(255)" ); ! Register( DbType.AnsiStringFixedLength, 8000, "CHAR($1)" ); ! Register( DbType.AnsiString, "VARCHAR(255)" ); ! Register( DbType.AnsiString, 8000, "VARCHAR($1)" ); ! Register( DbType.AnsiString, 2147483647, "TEXT" ); ! Register( DbType.Binary, "VARBINARY(8000)" ); ! Register( DbType.Binary, 8000, "VARBINARY($1)" ); ! Register( DbType.Binary, 2147483647, "IMAGE" ); ! Register( DbType.Boolean, "BIT" ); ! Register( DbType.Byte, "TINYINT" ); ! Register( DbType.Currency, "MONEY" ); ! Register( DbType.Date, "DATETIME" ); ! Register( DbType.DateTime, "DATETIME" ); // TODO: figure out if this is the good way to fix the problem // with exporting a DECIMAL column --- 34,50 ---- public MsSql2000Dialect() : base() { ! RegisterColumnType( DbType.AnsiStringFixedLength, "CHAR(255)" ); ! RegisterColumnType( DbType.AnsiStringFixedLength, 8000, "CHAR($1)" ); ! RegisterColumnType( DbType.AnsiString, "VARCHAR(255)" ); ! RegisterColumnType( DbType.AnsiString, 8000, "VARCHAR($1)" ); ! RegisterColumnType( DbType.AnsiString, 2147483647, "TEXT" ); ! RegisterColumnType( DbType.Binary, "VARBINARY(8000)" ); ! RegisterColumnType( DbType.Binary, 8000, "VARBINARY($1)" ); ! RegisterColumnType( DbType.Binary, 2147483647, "IMAGE" ); ! RegisterColumnType( DbType.Boolean, "BIT" ); ! RegisterColumnType( DbType.Byte, "TINYINT" ); ! RegisterColumnType( DbType.Currency, "MONEY" ); ! RegisterColumnType( DbType.Date, "DATETIME" ); ! RegisterColumnType( DbType.DateTime, "DATETIME" ); // TODO: figure out if this is the good way to fix the problem // with exporting a DECIMAL column *************** *** 54,71 **** // sql-type="decimal(20,5)" if they need to do that. The Decimal parameter and ddl will get generated // correctly with minimal work. ! Register( DbType.Decimal, "DECIMAL(19,5)" ); ! Register( DbType.Decimal, 19, "DECIMAL(19, $1)" ); ! Register( DbType.Double, "DOUBLE PRECISION" ); //synonym for FLOAT(53) ! Register( DbType.Guid, "UNIQUEIDENTIFIER" ); ! Register( DbType.Int16, "SMALLINT" ); ! Register( DbType.Int32, "INT" ); ! Register( DbType.Int64, "BIGINT" ); ! Register( DbType.Single, "REAL" ); //synonym for FLOAT(24) ! Register( DbType.StringFixedLength, "NCHAR(255)" ); ! Register( DbType.StringFixedLength, 4000, "NCHAR($1)" ); ! Register( DbType.String, "NVARCHAR(255)" ); ! Register( DbType.String, 4000, "NVARCHAR($1)" ); ! Register( DbType.String, 1073741823, "NTEXT" ); ! Register( DbType.Time, "DATETIME" ); DefaultProperties[ Environment.OuterJoin ] = "true"; --- 54,143 ---- // sql-type="decimal(20,5)" if they need to do that. The Decimal parameter and ddl will get generated // correctly with minimal work. ! RegisterColumnType( DbType.Decimal, "DECIMAL(19,5)" ); ! RegisterColumnType( DbType.Decimal, 19, "DECIMAL(19, $1)" ); ! RegisterColumnType( DbType.Double, "DOUBLE PRECISION" ); //synonym for FLOAT(53) ! RegisterColumnType( DbType.Guid, "UNIQUEIDENTIFIER" ); ! RegisterColumnType( DbType.Int16, "SMALLINT" ); ! RegisterColumnType( DbType.Int32, "INT" ); ! RegisterColumnType( DbType.Int64, "BIGINT" ); ! RegisterColumnType( DbType.Single, "REAL" ); //synonym for FLOAT(24) ! RegisterColumnType( DbType.StringFixedLength, "NCHAR(255)" ); ! RegisterColumnType( DbType.StringFixedLength, 4000, "NCHAR($1)" ); ! RegisterColumnType( DbType.String, "NVARCHAR(255)" ); ! RegisterColumnType( DbType.String, 4000, "NVARCHAR($1)" ); ! RegisterColumnType( DbType.String, 1073741823, "NTEXT" ); ! RegisterColumnType( DbType.Time, "DATETIME" ); ! ! RegisterFunction("abs", new StandardSQLFunction() ); ! RegisterFunction("absval", new StandardSQLFunction() ); ! RegisterFunction("sign", new StandardSQLFunction( NHibernateUtil.Int32 ) ); ! ! RegisterFunction("ceiling", new StandardSQLFunction() ); ! RegisterFunction("ceil", new StandardSQLFunction() ); ! RegisterFunction("floor", new StandardSQLFunction() ); ! RegisterFunction("round", new StandardSQLFunction() ); ! ! RegisterFunction("acos", new StandardSQLFunction( NHibernateUtil.Double ) ); ! RegisterFunction("asin", new StandardSQLFunction( NHibernateUtil.Double ) ); ! RegisterFunction("atan", new StandardSQLFunction( NHibernateUtil.Double ) ); ! RegisterFunction("cos", new StandardSQLFunction( NHibernateUtil.Double ) ); ! RegisterFunction("cot", new StandardSQLFunction( NHibernateUtil.Double ) ); ! RegisterFunction("degrees", new StandardSQLFunction( NHibernateUtil.Double ) ); ! RegisterFunction("exp", new StandardSQLFunction( NHibernateUtil.Double ) ); ! RegisterFunction("float", new StandardSQLFunction( NHibernateUtil.Double ) ); ! RegisterFunction("hex", new StandardSQLFunction( NHibernateUtil.String ) ); ! RegisterFunction("ln", new StandardSQLFunction( NHibernateUtil.Double ) ); ! RegisterFunction("log", new StandardSQLFunction( NHibernateUtil.Double ) ); ! RegisterFunction("log10", new StandardSQLFunction( NHibernateUtil.Double ) ); ! RegisterFunction("radians", new StandardSQLFunction( NHibernateUtil.Double ) ); ! RegisterFunction("rand", new NoArgSQLFunction( NHibernateUtil.Double )); ! RegisterFunction("sin", new StandardSQLFunction( NHibernateUtil.Double ) ); ! RegisterFunction("soundex", new StandardSQLFunction( NHibernateUtil.String ) ); ! RegisterFunction("sqrt", new StandardSQLFunction( NHibernateUtil.Double ) ); ! RegisterFunction("stddev", new StandardSQLFunction( NHibernateUtil.Double ) ); ! RegisterFunction("tan", new StandardSQLFunction( NHibernateUtil.Double ) ); ! RegisterFunction("variance", new StandardSQLFunction( NHibernateUtil.Double ) ); ! ! /* ! RegisterFunction("julian_day", new StandardSQLFunction( NHibernateUtil.Int32 ) ); ! RegisterFunction("microsecond", new StandardSQLFunction( NHibernateUtil.Int32 ) ); ! RegisterFunction("midnight_seconds", new StandardSQLFunction( NHibernateUtil.Int32 ) ); ! RegisterFunction("minute", new StandardSQLFunction( NHibernateUtil.Int32 ) ); ! RegisterFunction("month", new StandardSQLFunction( NHibernateUtil.Int32 ) ); ! RegisterFunction("monthname", new StandardSQLFunction( NHibernateUtil.String ) ); ! RegisterFunction("quarter", new StandardSQLFunction( NHibernateUtil.Int32 ) ); ! RegisterFunction("hour", new StandardSQLFunction( NHibernateUtil.Int32 ) ); ! RegisterFunction("second", new StandardSQLFunction( NHibernateUtil.Int32 ) ); ! RegisterFunction("date", new StandardSQLFunction(Hibernate.DATE) ); ! RegisterFunction("day", new StandardSQLFunction( NHibernateUtil.Int32 ) ); ! RegisterFunction("dayname", new StandardSQLFunction( NHibernateUtil.String ) ); ! RegisterFunction("dayofweek", new StandardSQLFunction( NHibernateUtil.Int32 ) ); ! RegisterFunction("dayofweek_iso", new StandardSQLFunction( NHibernateUtil.Int32 ) ); ! RegisterFunction("dayofyear", new StandardSQLFunction( NHibernateUtil.Int32 ) ); ! RegisterFunction("days", new StandardSQLFunction( NHibernateUtil.Int32 ) ); ! RegisterFunction("time", new StandardSQLFunction( NHibernateUtil.Time ) ); ! RegisterFunction("timestamp", new StandardSQLFunction( NHibernateUtil.Timestamp ) ); ! RegisterFunction("timestamp_iso", new StandardSQLFunction( NHibernateUtil.Timestamp ) ); ! RegisterFunction("week", new StandardSQLFunction( NHibernateUtil.Int32 ) ); ! RegisterFunction("week_iso", new StandardSQLFunction( NHibernateUtil.Int32 ) ); ! RegisterFunction("year", new StandardSQLFunction( NHibernateUtil.Int32 ) ); ! ! RegisterFunction("double", new StandardSQLFunction( NHibernateUtil.Double ) ); ! RegisterFunction("varchar", new StandardSQLFunction( NHibernateUtil.String ) ); ! RegisterFunction("real", new StandardSQLFunction( NHibernateUtil.Single ) ); ! RegisterFunction("bigint", new StandardSQLFunction( NHibernateUtil.Int32 ) ); ! RegisterFunction("char", new StandardSQLFunction( NHibernateUtil.Character ) ); ! RegisterFunction("integer", new StandardSQLFunction( NHibernateUtil.Int32 ) ); ! RegisterFunction("smallint", new StandardSQLFunction( NHibernateUtil.Int16 ) ); ! */ ! ! RegisterFunction("digits", new StandardSQLFunction( NHibernateUtil.String ) ); ! RegisterFunction("chr", new StandardSQLFunction( NHibernateUtil.Character ) ); ! RegisterFunction("upper", new StandardSQLFunction() ); ! RegisterFunction("ucase", new StandardSQLFunction() ); ! RegisterFunction("lcase", new StandardSQLFunction() ); ! RegisterFunction("lower", new StandardSQLFunction() ); ! RegisterFunction("length", new StandardSQLFunction( NHibernateUtil.Int32 ) ); ! RegisterFunction("ltrim", new StandardSQLFunction() ); DefaultProperties[ Environment.OuterJoin ] = "true"; Index: Oracle9Dialect.cs =================================================================== RCS file: /cvsroot/nhibernate/nhibernate/src/NHibernate/Dialect/Oracle9Dialect.cs,v retrieving revision 1.20 retrieving revision 1.21 diff -C2 -d -r1.20 -r1.21 *** Oracle9Dialect.cs 30 Jan 2005 19:39:11 -0000 1.20 --- Oracle9Dialect.cs 1 Mar 2005 16:24:44 -0000 1.21 *************** *** 33,38 **** public class Oracle9Dialect : Dialect { - private readonly IDictionary aggregateFunctions = new Hashtable(); - /// <summary></summary> public Oracle9Dialect() : base() --- 33,36 ---- *************** *** 42,100 **** DefaultProperties[ Environment.ConnectionDriver ] = "NHibernate.Driver.OracleClientDriver"; ! Register( DbType.AnsiStringFixedLength, "CHAR(255)" ); ! Register( DbType.AnsiStringFixedLength, 2000, "CHAR($1)" ); ! Register( DbType.AnsiString, "VARCHAR2(255)" ); ! Register( DbType.AnsiString, 2000, "VARCHAR2($1)" ); ! Register( DbType.AnsiString, 2147483647, "CLOB" ); // should use the IType.ClobType ! Register( DbType.Binary, "RAW(2000)" ); ! Register( DbType.Binary, 2000, "RAW($1)" ); ! Register( DbType.Binary, 2147483647, "BLOB" ); ! Register( DbType.Boolean, "NUMBER(1,0)" ); ! Register( DbType.Byte, "NUMBER(3,0)" ); ! Register( DbType.Currency, "NUMBER(19,1)" ); ! Register( DbType.Date, "DATE" ); ! Register( DbType.DateTime, "DATE" ); ! Register( DbType.Decimal, "NUMBER(19,5)" ); ! Register( DbType.Decimal, 19, "NUMBER(19, $1)" ); // having problems with both ODP and OracleClient from MS not being able // to read values out of a field that is DOUBLE PRECISION ! Register( DbType.Double, "DOUBLE PRECISION" ); //"FLOAT(53)" ); //Oracle does not have a guid datatype ! //Register( DbType.Guid, "UNIQUEIDENTIFIER" ); ! Register( DbType.Int16, "NUMBER(5,0)" ); ! Register( DbType.Int32, "NUMBER(10,0)" ); ! Register( DbType.Int64, "NUMBER(20,0)" ); ! Register( DbType.Single, "FLOAT(24)" ); ! Register( DbType.StringFixedLength, "NCHAR(255)" ); ! Register( DbType.StringFixedLength, 2000, "NCHAR($1)" ); ! Register( DbType.String, "NVARCHAR2(255)" ); ! Register( DbType.String, 2000, "NVARCHAR2($1)" ); ! Register( DbType.String, 1073741823, "NCLOB" ); ! Register( DbType.Time, "DATE" ); ! // add all the functions from the base into this instance ! foreach( DictionaryEntry de in base.AggregateFunctions ) ! { ! aggregateFunctions[ de.Key ] = de.Value; ! } ! aggregateFunctions[ "trunc" ] = new QueryFunctionStandard(); ! aggregateFunctions[ "round" ] = new QueryFunctionStandard(); ! aggregateFunctions[ "abs" ] = new QueryFunctionStandard( NHibernateUtil.Int32 ); ! aggregateFunctions[ "sign" ] = new QueryFunctionStandard( NHibernateUtil.Int32 ); ! aggregateFunctions[ "ceil" ] = new QueryFunctionStandard( NHibernateUtil.Int32 ); ! aggregateFunctions[ "floor" ] = new QueryFunctionStandard( NHibernateUtil.Int32 ); ! aggregateFunctions[ "sqrt" ] = new QueryFunctionStandard(); ! aggregateFunctions[ "exp" ] = new QueryFunctionStandard(); ! aggregateFunctions[ "ln" ] = new QueryFunctionStandard(); ! aggregateFunctions[ "sin" ] = new QueryFunctionStandard(); ! aggregateFunctions[ "sinh" ] = new QueryFunctionStandard(); ! aggregateFunctions[ "cos" ] = new QueryFunctionStandard(); ! aggregateFunctions[ "cosh" ] = new QueryFunctionStandard(); ! aggregateFunctions[ "tan" ] = new QueryFunctionStandard(); ! aggregateFunctions[ "tanh" ] = new QueryFunctionStandard(); ! aggregateFunctions[ "stddev" ] = new QueryFunctionStandard(); ! aggregateFunctions[ "variance" ] = new QueryFunctionStandard(); ! aggregateFunctions[ "sysdate" ] = new SysdateQueryFunctionInfo(); ! aggregateFunctions[ "lastday" ] = new QueryFunctionStandard( NHibernateUtil.Date ); } --- 40,137 ---- DefaultProperties[ Environment.ConnectionDriver ] = "NHibernate.Driver.OracleClientDriver"; ! RegisterColumnType( DbType.AnsiStringFixedLength, "CHAR(255)" ); ! RegisterColumnType( DbType.AnsiStringFixedLength, 2000, "CHAR($1)" ); ! RegisterColumnType( DbType.AnsiString, "VARCHAR2(255)" ); ! RegisterColumnType( DbType.AnsiString, 2000, "VARCHAR2($1)" ); ! RegisterColumnType( DbType.AnsiString, 2147483647, "CLOB" ); // should use the IType.ClobType ! RegisterColumnType( DbType.Binary, "RAW(2000)" ); ! RegisterColumnType( DbType.Binary, 2000, "RAW($1)" ); ! RegisterColumnType( DbType.Binary, 2147483647, "BLOB" ); ! RegisterColumnType( DbType.Boolean, "NUMBER(1,0)" ); ! RegisterColumnType( DbType.Byte, "NUMBER(3,0)" ); ! RegisterColumnType( DbType.Currency, "NUMBER(19,1)" ); ! RegisterColumnType( DbType.Date, "DATE" ); ! RegisterColumnType( DbType.DateTime, "DATE" ); ! RegisterColumnType( DbType.Decimal, "NUMBER(19,5)" ); ! RegisterColumnType( DbType.Decimal, 19, "NUMBER(19, $1)" ); // having problems with both ODP and OracleClient from MS not being able // to read values out of a field that is DOUBLE PRECISION ! RegisterColumnType( DbType.Double, "DOUBLE PRECISION" ); //"FLOAT(53)" ); //Oracle does not have a guid datatype ! //RegisterColumnType( DbType.Guid, "UNIQUEIDENTIFIER" ); ! RegisterColumnType( DbType.Int16, "NUMBER(5,0)" ); ! RegisterColumnType( DbType.Int32, "NUMBER(10,0)" ); ! RegisterColumnType( DbType.Int64, "NUMBER(20,0)" ); ! RegisterColumnType( DbType.Single, "FLOAT(24)" ); ! RegisterColumnType( DbType.StringFixedLength, "NCHAR(255)" ); ! RegisterColumnType( DbType.StringFixedLength, 2000, "NCHAR($1)" ); ! RegisterColumnType( DbType.String, "NVARCHAR2(255)" ); ! RegisterColumnType( DbType.String, 2000, "NVARCHAR2($1)" ); ! RegisterColumnType( DbType.String, 1073741823, "NCLOB" ); ! RegisterColumnType( DbType.Time, "DATE" ); ! RegisterFunction( "abs", new StandardSQLFunction() ); ! RegisterFunction( "sign", new StandardSQLFunction( NHibernateUtil.Int32 ) ); ! ! RegisterFunction( "acos", new StandardSQLFunction( NHibernateUtil.Double ) ); ! RegisterFunction( "asin", new StandardSQLFunction( NHibernateUtil.Double ) ); ! RegisterFunction( "atan", new StandardSQLFunction( NHibernateUtil.Double ) ); ! RegisterFunction( "cos", new StandardSQLFunction( NHibernateUtil.Double ) ); ! RegisterFunction( "cosh", new StandardSQLFunction( NHibernateUtil.Double ) ); ! RegisterFunction( "exp", new StandardSQLFunction( NHibernateUtil.Double ) ); ! RegisterFunction( "ln", new StandardSQLFunction( NHibernateUtil.Double ) ); ! RegisterFunction( "sin", new StandardSQLFunction( NHibernateUtil.Double ) ); ! RegisterFunction( "sinh", new StandardSQLFunction( NHibernateUtil.Double ) ); ! RegisterFunction( "stddev", new StandardSQLFunction( NHibernateUtil.Double ) ); ! RegisterFunction( "sqrt", new StandardSQLFunction( NHibernateUtil.Double ) ); ! RegisterFunction( "tan", new StandardSQLFunction( NHibernateUtil.Double ) ); ! RegisterFunction( "tanh", new StandardSQLFunction( NHibernateUtil.Double ) ); ! RegisterFunction( "variance", new StandardSQLFunction( NHibernateUtil.Double ) ); ! ! RegisterFunction( "round", new StandardSQLFunction() ); ! RegisterFunction( "trunc", new StandardSQLFunction() ); ! RegisterFunction( "ceil", new StandardSQLFunction() ); ! RegisterFunction( "floor", new StandardSQLFunction() ); ! ! RegisterFunction( "chr", new StandardSQLFunction( NHibernateUtil.Character ) ); ! RegisterFunction( "initcap", new StandardSQLFunction() ); ! RegisterFunction( "lower", new StandardSQLFunction() ); ! RegisterFunction( "ltrim", new StandardSQLFunction() ); ! RegisterFunction( "rtrim", new StandardSQLFunction() ); ! RegisterFunction( "soundex", new StandardSQLFunction() ); ! RegisterFunction( "upper", new StandardSQLFunction() ); ! RegisterFunction( "ascii", new StandardSQLFunction( NHibernateUtil.Int32 ) ); ! RegisterFunction( "length", new StandardSQLFunction( NHibernateUtil.Int64 ) ); ! ! RegisterFunction( "to_char", new StandardSQLFunction( NHibernateUtil.String ) ); ! RegisterFunction( "to_date", new StandardSQLFunction( NHibernateUtil.Timestamp ) ); ! ! RegisterFunction( "lastday", new StandardSQLFunction( NHibernateUtil.Date ) ); ! RegisterFunction( "sysdate", new NoArgSQLFunction( NHibernateUtil.Date, false) ); ! RegisterFunction( "uid", new NoArgSQLFunction( NHibernateUtil.Int32, false) ); ! RegisterFunction( "user", new NoArgSQLFunction( NHibernateUtil.String, false) ); ! ! // Multi-param string dialect functions... ! RegisterFunction( "concat", new StandardSQLFunction( NHibernateUtil.String ) ); ! RegisterFunction( "instr", new StandardSQLFunction( NHibernateUtil.String ) ); ! RegisterFunction( "instrb", new StandardSQLFunction( NHibernateUtil.String ) ); ! RegisterFunction( "lpad", new StandardSQLFunction( NHibernateUtil.String ) ); ! RegisterFunction( "replace", new StandardSQLFunction( NHibernateUtil.String ) ); ! RegisterFunction( "rpad", new StandardSQLFunction( NHibernateUtil.String ) ); ! RegisterFunction( "substr", new StandardSQLFunction( NHibernateUtil.String ) ); ! RegisterFunction( "substrb", new StandardSQLFunction( NHibernateUtil.String ) ); ! RegisterFunction( "translate", new StandardSQLFunction( NHibernateUtil.String ) ); ! ! // Multi-param numeric dialect functions... ! RegisterFunction( "atan2", new StandardSQLFunction( NHibernateUtil.Single ) ); ! RegisterFunction( "log", new StandardSQLFunction( NHibernateUtil.Int32 ) ); ! RegisterFunction( "mod", new StandardSQLFunction( NHibernateUtil.Int32 ) ); ! RegisterFunction( "nvl", new StandardSQLFunction() ); ! RegisterFunction( "power", new StandardSQLFunction( NHibernateUtil.Single ) ); ! ! // Multi-param date dialect functions... ! RegisterFunction( "add_months", new StandardSQLFunction( NHibernateUtil.Date ) ); ! RegisterFunction( "months_between", new StandardSQLFunction( NHibernateUtil.Single ) ); ! RegisterFunction( "next_day", new StandardSQLFunction( NHibernateUtil.Date ) ); } *************** *** 186,230 **** /// <summary></summary> - public override IDictionary AggregateFunctions - { - get { return aggregateFunctions; } - } - - /// <summary></summary> public override bool UseMaxForLimit { get { return true; } } - - /// <summary></summary> - public class SysdateQueryFunctionInfo : IQueryFunctionInfo - { - #region IQueryFunctionInfo Members - - /// <summary> - /// - /// </summary> - /// <param name="columnType"></param> - /// <param name="mapping"></param> - /// <returns></returns> - public IType QueryFunctionType( IType columnType, IMapping mapping ) - { - return NHibernateUtil.Date; - } - - /// <summary></summary> - public bool IsFunctionArgs - { - get { return false; } - } - - /// <summary></summary> - public bool IsFunctionNoArgsUseParanthesis - { - get { return false; } - } - - #endregion - } } } \ No newline at end of file --- 223,230 ---- Index: Dialect.cs =================================================================== RCS file: /cvsroot/nhibernate/nhibernate/src/NHibernate/Dialect/Dialect.cs,v retrieving revision 1.44 retrieving revision 1.45 diff -C2 -d -r1.44 -r1.45 *** Dialect.cs 9 Feb 2005 03:09:38 -0000 1.44 --- Dialect.cs 1 Mar 2005 16:24:44 -0000 1.45 *************** *** 28,33 **** private TypeNames typeNames = new TypeNames( "$1" ); private IDictionary properties = new Hashtable(); ! private static readonly IDictionary aggregateFunctions = new Hashtable(); /// <summary></summary> --- 28,34 ---- private TypeNames typeNames = new TypeNames( "$1" ); private IDictionary properties = new Hashtable(); + private IDictionary sqlFunctions; ! private static readonly IDictionary standardAggregateFunctions = new Hashtable(); /// <summary></summary> *************** *** 39,47 **** static Dialect() { ! aggregateFunctions[ "count" ] = new CountQueryFunctionInfo(); ! aggregateFunctions[ "avg" ] = new AvgQueryFunctionInfo(); ! aggregateFunctions[ "max" ] = new QueryFunctionStandard(); ! aggregateFunctions[ "min" ] = new QueryFunctionStandard(); ! aggregateFunctions[ "sum" ] = new QueryFunctionStandard(); } --- 40,48 ---- static Dialect() { ! standardAggregateFunctions[ "count" ] = new CountQueryFunctionInfo(); ! standardAggregateFunctions[ "avg" ] = new AvgQueryFunctionInfo(); ! standardAggregateFunctions[ "max" ] = new StandardSQLFunction(); ! standardAggregateFunctions[ "min" ] = new StandardSQLFunction(); ! standardAggregateFunctions[ "sum" ] = new StandardSQLFunction(); } *************** *** 63,66 **** --- 64,68 ---- { log.Info( "Using dialect: " + this ); + sqlFunctions = new Hashtable( standardAggregateFunctions ) ; } *************** *** 108,111 **** --- 110,123 ---- /// <summary> + /// + /// </summary> + /// <param name="name"></param> + /// <param name="function"></param> + protected void RegisterFunction( string name, ISQLFunction function ) + { + sqlFunctions.Add( name, function ); + } + + /// <summary> /// Subclasses register a typename for the given type code and maximum /// column length. <c>$1</c> in the type name will be replaced by the column *************** *** 115,119 **** /// <param name="capacity">Maximum length of database type</param> /// <param name="name">The database type name</param> ! protected void Register( DbType code, int capacity, string name ) { typeNames.Put( code, capacity, name ); --- 127,131 ---- /// <param name="capacity">Maximum length of database type</param> /// <param name="name">The database type name</param> ! protected void RegisterColumnType( DbType code, int capacity, string name ) { typeNames.Put( code, capacity, name ); *************** *** 126,130 **** /// <param name="code">The typecode</param> /// <param name="name">The database type name</param> ! protected void Register( DbType code, string name ) { typeNames.Put( code, name ); --- 138,142 ---- /// <param name="code">The typecode</param> /// <param name="name">The database type name</param> ! protected void RegisterColumnType( DbType code, string name ) { typeNames.Put( code, name ); *************** *** 559,565 **** /// specialization's data. /// </remarks> ! public virtual IDictionary AggregateFunctions { ! get { return aggregateFunctions; } } --- 571,577 ---- /// specialization's data. /// </remarks> ! public virtual IDictionary Functions { ! get { return sqlFunctions; } } *************** *** 825,831 **** /// /// </summary> ! public class CountQueryFunctionInfo : IQueryFunctionInfo { ! #region IQueryFunctionInfo Members /// <summary> --- 837,843 ---- /// /// </summary> ! public class CountQueryFunctionInfo : ISQLFunction { ! #region ISQLFunction Members /// <summary> *************** *** 835,851 **** /// <param name="mapping"></param> /// <returns></returns> ! public IType QueryFunctionType( IType columnType, IMapping mapping ) { return NHibernateUtil.Int32; } ! /// <summary></summary> ! public bool IsFunctionArgs { get { return true; } } ! /// <summary></summary> ! public bool IsFunctionNoArgsUseParanthesis { get { return true; } --- 847,867 ---- /// <param name="mapping"></param> /// <returns></returns> ! public IType ReturnType(IType columnType, IMapping mapping) { return NHibernateUtil.Int32; } ! /// <summary> ! /// ! /// </summary> ! public bool HasArguments { get { return true; } } ! /// <summary> ! /// ! /// </summary> ! public bool HasParenthesesIfNoArguments { get { return true; } *************** *** 856,862 **** /// <summary></summary> ! public class AvgQueryFunctionInfo : IQueryFunctionInfo { ! #region IQueryFunctionInfo Members /// <summary> --- 872,878 ---- /// <summary></summary> ! public class AvgQueryFunctionInfo : ISQLFunction { ! #region ISQLFunction Members /// <summary> *************** *** 866,870 **** /// <param name="mapping"></param> /// <returns></returns> ! public IType QueryFunctionType( IType columnType, IMapping mapping ) { SqlType[ ] sqlTypes; --- 882,886 ---- /// <param name="mapping"></param> /// <returns></returns> ! public IType ReturnType(IType columnType, IMapping mapping) { SqlType[ ] sqlTypes; *************** *** 895,906 **** } ! /// <summary></summary> ! public bool IsFunctionArgs { get { return true; } } ! /// <summary></summary> ! public bool IsFunctionNoArgsUseParanthesis { get { return true; } --- 911,926 ---- } ! /// <summary> ! /// ! /// </summary> ! public bool HasArguments { get { return true; } } ! /// <summary> ! /// ! /// </summary> ! public bool HasParenthesesIfNoArguments { get { return true; } |
Update of /cvsroot/nhibernate/nhibernate/src/NHibernate/Impl In directory sc8-pr-cvs1.sourceforge.net:/tmp/cvs-serv5548/nhibernate/src/NHibernate/Impl Modified Files: CollectionEntry.cs CollectionKey.cs FilterImpl.cs MessageHelper.cs OnLockVisitor.cs OnUpdateVisitor.cs QueryImpl.cs ScheduledCollectionAction.cs ScheduledCollectionRecreate.cs ScheduledCollectionRemove.cs ScheduledCollectionUpdate.cs ScheduledDeletion.cs ScheduledUpdate.cs SessionFactoryImpl.cs SessionImpl.cs WrapVisitor.cs Added Files: AbstractQueryImpl.cs Log Message: Various refactorings on the way to 2.1 querying capability Index: SessionImpl.cs =================================================================== RCS file: /cvsroot/nhibernate/nhibernate/src/NHibernate/Impl/SessionImpl.cs,v retrieving revision 1.67 retrieving revision 1.68 diff -C2 -d -r1.67 -r1.68 *** SessionImpl.cs 16 Feb 2005 20:14:20 -0000 1.67 --- SessionImpl.cs 1 Mar 2005 16:24:47 -0000 1.68 *************** *** 1286,1290 **** } ! internal void RemoveCollection( CollectionPersister role, object id ) { if( log.IsDebugEnabled ) --- 1286,1290 ---- } ! internal void RemoveCollection( ICollectionPersister role, object id ) { if( log.IsDebugEnabled ) *************** *** 1306,1310 **** } ! internal static bool IsOwnerUnchanged( ICollectionSnapshot snapshot, CollectionPersister persister, object id ) { return IsCollectionSnapshotValid( snapshot ) && --- 1306,1310 ---- } ! internal static bool IsOwnerUnchanged( ICollectionSnapshot snapshot, ICollectionPersister persister, object id ) { return IsCollectionSnapshotValid( snapshot ) && *************** *** 1884,1887 **** --- 1884,1888 ---- IClassPersister persister = e.Persister; + ISoftLock myLock = null; if( lockMode.GreaterThan( e.LockMode ) ) *************** *** 1899,1903 **** if( persister.HasCache ) { ! persister.Cache.Lock( e.Id ); } try --- 1900,1904 ---- if( persister.HasCache ) { ! myLock = persister.Cache.Lock( e.Id ); } try *************** *** 1916,1920 **** if( persister.HasCache ) { ! persister.Cache.Release( e.Id ); } } --- 1917,1921 ---- if( persister.HasCache ) { ! persister.Cache.Release( e.Id, myLock ); } } *************** *** 2350,2353 **** --- 2351,2356 ---- private object DoLoad( System.Type clazz, object id, LockMode lockMode, bool allowNull ) { + ISoftLock myLock = null; + if( log.IsDebugEnabled ) { *************** *** 2362,2366 **** if( persister.HasCache ) { ! persister.Cache.Lock( id ); } //increments the lock object result; --- 2365,2369 ---- if( persister.HasCache ) { ! myLock = persister.Cache.Lock( id ); } //increments the lock object result; *************** *** 2375,2379 **** if( persister.HasCache ) { ! persister.Cache.Release( id ); } } --- 2378,2382 ---- if( persister.HasCache ) { ! persister.Cache.Release( id, myLock ); } } *************** *** 3407,3411 **** ce.reached = true; ! CollectionPersister persister = GetCollectionPersister( ( ( PersistentCollectionType ) type ).Role ); ce.currentPersister = persister; ce.currentKey = GetEntityIdentifier( owner ); --- 3410,3414 ---- ce.reached = true; ! ICollectionPersister persister = GetCollectionPersister( ( ( PersistentCollectionType ) type ).Role ); ce.currentPersister = persister; ce.currentKey = GetEntityIdentifier( owner ); *************** *** 3566,3570 **** /// <param name="id"></param> /// <returns></returns> ! public PersistentCollection GetLoadingCollection( CollectionPersister persister, object id ) { LoadingCollectionEntry lce = ( LoadingCollectionEntry ) loadingCollections[ id ]; --- 3569,3573 ---- /// <param name="id"></param> /// <returns></returns> ! public PersistentCollection GetLoadingCollection( ICollectionPersister persister, object id ) { LoadingCollectionEntry lce = ( LoadingCollectionEntry ) loadingCollections[ id ]; *************** *** 3594,3598 **** if( loadingRole != null ) { ! CollectionPersister persister = GetCollectionPersister( loadingRole ); foreach( LoadingCollectionEntry lce in loadingCollections.Values ) { --- 3597,3601 ---- if( loadingRole != null ) { ! ICollectionPersister persister = GetCollectionPersister( loadingRole ); foreach( LoadingCollectionEntry lce in loadingCollections.Values ) { *************** *** 3645,3649 **** collectionEntries[collection] = entry; ! CollectionKey ck = new CollectionKey(entry.loadedPersister, key); PersistentCollection old = (PersistentCollection) collectionsByKey[ck]; collectionsByKey[ck] = collection; --- 3648,3652 ---- collectionEntries[collection] = entry; ! CollectionKey ck = new CollectionKey( entry.loadedPersister, key); PersistentCollection old = (PersistentCollection) collectionsByKey[ck]; collectionsByKey[ck] = collection; *************** *** 3705,3709 **** /// <param name="persister"></param> /// <param name="id"></param> ! private void AddUninitializedCollection( PersistentCollection collection, CollectionPersister persister, object id ) { CollectionEntry ce = new CollectionEntry( persister, id, flushing ); --- 3708,3712 ---- /// <param name="persister"></param> /// <param name="id"></param> ! private void AddUninitializedCollection( PersistentCollection collection, ICollectionPersister persister, object id ) { CollectionEntry ce = new CollectionEntry( persister, id, flushing ); *************** *** 3712,3716 **** } ! private void AddUninitializedDetachedCollection( PersistentCollection collection, CollectionPersister persister, object id ) { CollectionEntry ce = new CollectionEntry( persister, id ); --- 3715,3719 ---- } ! private void AddUninitializedDetachedCollection( PersistentCollection collection, ICollectionPersister persister, object id ) { CollectionEntry ce = new CollectionEntry( persister, id ); *************** *** 3725,3729 **** /// <param name="persister"></param> /// <param name="id"></param> ! public void AddInitializedCollection( PersistentCollection collection, CollectionPersister persister, object id ) { CollectionEntry ce = new CollectionEntry( persister, id, flushing ); --- 3728,3732 ---- /// <param name="persister"></param> /// <param name="id"></param> ! public void AddInitializedCollection( PersistentCollection collection, ICollectionPersister persister, object id ) { CollectionEntry ce = new CollectionEntry( persister, id, flushing ); *************** *** 3747,3751 **** /// <param name="collection"></param> /// <param name="persister"></param> ! internal void AddNewCollection(PersistentCollection collection, CollectionPersister persister) { CollectionEntry ce = AddCollection(collection); --- 3750,3754 ---- /// <param name="collection"></param> /// <param name="persister"></param> ! internal void AddNewCollection(PersistentCollection collection, ICollectionPersister persister) { CollectionEntry ce = AddCollection(collection); *************** *** 3794,3798 **** } ! internal CollectionPersister GetCollectionPersister( string role ) { return factory.GetCollectionPersister( role ); --- 3797,3801 ---- } ! internal ICollectionPersister GetCollectionPersister( string role ) { return factory.GetCollectionPersister( role ); *************** *** 3880,3886 **** { log.Debug("collection not cached"); ! CollectionPersister persister = ce.loadedPersister; object id = ce.loadedKey; - object owner = GetEntity( new Key( id, GetPersister( persister.OwnerClass ) ) ); --- 3883,3888 ---- { log.Debug("collection not cached"); ! ICollectionPersister persister = ce.loadedPersister; object id = ce.loadedKey; object owner = GetEntity( new Key( id, GetPersister( persister.OwnerClass ) ) ); *************** *** 3888,3892 **** try { ! persister.Initializer.Initialize( id, collection, owner, this ); } catch( ADOException sqle ) --- 3890,3894 ---- try { ! ((CollectionPersister) persister).Initializer.Initialize( id, collection, owner, this ); } catch( ADOException sqle ) *************** *** 3911,3914 **** --- 3913,3925 ---- } log.Debug("collection initialized"); + + /* + log.Debug("collection not cached"); + ICollectionPersister persister = ce.loadedPersister; + object id = ce.loadedKey; + object owner = GetEntity( new Key( id, GetPersister( persister.OwnerClass ) ) ); + persister.Initialize( id, owner, this ); + log.Debug("collection initialized"); + */ } } *************** *** 3920,3924 **** } ! public object GetCollectionOwner(object key, CollectionPersister collectionPersister) { //TODO:give collection persister a reference to the owning class persister --- 3931,3935 ---- } ! public object GetCollectionOwner(object key, ICollectionPersister collectionPersister) { //TODO:give collection persister a reference to the owning class persister *************** *** 4220,4224 **** FilterTranslator q; ! CollectionPersister roleBeforeFlush = e.loadedPersister; if( roleBeforeFlush == null ) { //ie. it was previously unreferenced --- 4231,4235 ---- FilterTranslator q; ! ICollectionPersister roleBeforeFlush = e.loadedPersister; if( roleBeforeFlush == null ) { //ie. it was previously unreferenced *************** *** 4561,4565 **** // that references it ! CollectionPersister persister = factory.GetCollectionPersister(role); PersistentCollection collection = GetLoadingCollection(role, id); --- 4572,4576 ---- // that references it ! ICollectionPersister persister = factory.GetCollectionPersister(role); PersistentCollection collection = GetLoadingCollection(role, id); *************** *** 4602,4606 **** /// <param name="collection"></param> /// <returns><c>true</c> if the collection was initialized from the cache, otherwise <c>false</c>.</returns> ! private bool InitializeCollectionFromCache(object id, object owner, CollectionPersister persister, PersistentCollection collection) { if( persister.HasCache==false ) --- 4613,4617 ---- /// <param name="collection"></param> /// <returns><c>true</c> if the collection was initialized from the cache, otherwise <c>false</c>.</returns> ! private bool InitializeCollectionFromCache(object id, object owner, ICollectionPersister persister, PersistentCollection collection) { if( persister.HasCache==false ) Index: WrapVisitor.cs =================================================================== RCS file: /cvsroot/nhibernate/nhibernate/src/NHibernate/Impl/WrapVisitor.cs,v retrieving revision 1.3 retrieving revision 1.4 diff -C2 -d -r1.3 -r1.4 *** WrapVisitor.cs 14 Feb 2005 03:31:51 -0000 1.3 --- WrapVisitor.cs 1 Mar 2005 16:24:47 -0000 1.4 *************** *** 51,55 **** } ! CollectionPersister persister = Session.GetCollectionPersister( collectionType.Role ); if( collectionType.IsArrayType ) --- 51,55 ---- } ! ICollectionPersister persister = Session.GetCollectionPersister( collectionType.Role ); if( collectionType.IsArrayType ) Index: SessionFactoryImpl.cs =================================================================== RCS file: /cvsroot/nhibernate/nhibernate/src/NHibernate/Impl/SessionFactoryImpl.cs,v retrieving revision 1.41 retrieving revision 1.42 diff -C2 -d -r1.41 -r1.42 *** SessionFactoryImpl.cs 7 Feb 2005 01:34:41 -0000 1.41 --- SessionFactoryImpl.cs 1 Mar 2005 16:24:46 -0000 1.42 *************** *** 32,36 **** /// <item> /// Caches "compiled" mappings - ie. <see cref="IClassPersister"/> ! /// and <see cref="CollectionPersister"/> /// </item> /// <item> --- 32,36 ---- /// <item> /// Caches "compiled" mappings - ie. <see cref="IClassPersister"/> ! /// and <see cref="ICollectionPersister"/> /// </item> /// <item> *************** *** 121,128 **** foreach( PersistentClass model in cfg.ClassMappings ) { ! System.Type persisterClass = model.Persister; // not used !?! IClassPersister cp; cp = PersisterFactory.Create( model, this ); ! classPersisters[ model.PersistentClazz ] = cp; // Adds the "Namespace.ClassName" (FullClassname) as a lookup to get to the Persiter. --- 121,128 ---- foreach( PersistentClass model in cfg.ClassMappings ) { ! System.Type persisterClass = model.ClassPersisterClass; // not used !?! IClassPersister cp; cp = PersisterFactory.Create( model, this ); ! classPersisters[ model.MappedClass ] = cp; // Adds the "Namespace.ClassName" (FullClassname) as a lookup to get to the Persiter. *************** *** 135,139 **** // In HQL the Imports are used to get from the Classname to the Persister. The // Imports provide the ability to jump from the Classname to the AssemblyQualifiedName. ! classPersistersByName[ model.PersistentClazz.AssemblyQualifiedName ] = cp; } --- 135,139 ---- // In HQL the Imports are used to get from the Classname to the Persister. The // Imports provide the ability to jump from the Classname to the AssemblyQualifiedName. ! classPersistersByName[ model.MappedClass.AssemblyQualifiedName ] = cp; } *************** *** 141,145 **** foreach( Mapping.Collection map in cfg.CollectionMappings ) { ! collectionPersisters[ map.Role ] = new CollectionPersister( map, cfg, this ); } --- 141,146 ---- foreach( Mapping.Collection map in cfg.CollectionMappings ) { ! //collectionPersisters[ map.Role ] = new CollectionPersister( map, cfg, this ); ! collectionPersisters[ map.Role ] = PersisterFactory.CreateCollectionPersister( cfg, map, this ); } *************** *** 531,537 **** /// <param name="role"></param> /// <returns></returns> ! public CollectionPersister GetCollectionPersister( string role ) { ! CollectionPersister result = collectionPersisters[ role ] as CollectionPersister; if( result == null ) { --- 532,538 ---- /// <param name="role"></param> /// <returns></returns> ! public ICollectionPersister GetCollectionPersister( string role ) { ! ICollectionPersister result = collectionPersisters[ role ] as ICollectionPersister; if( result == null ) { *************** *** 599,602 **** --- 600,624 ---- } + /// <summary> + /// + /// </summary> + /// <param name="objectClass"></param> + /// <returns></returns> + public string GetIdentifierPropertyName( System.Type objectClass ) + { + return GetPersister( objectClass ).IdentifierPropertyName; + } + + /// <summary> + /// + /// </summary> + /// <param name="persistentClass"></param> + /// <param name="propertyName"></param> + /// <returns></returns> + public IType GetPropertyType( System.Type persistentClass, string propertyName ) + { + return GetPersister( persistentClass ).GetPropertyType( propertyName ); + } + #region System.Runtime.Serialization.IObjectReference Members *************** *** 667,671 **** throw new HibernateException( "Query does not refer to any persistent classes: " + queryString ); } ! return GetShallowQuery( queries[ 0 ] ).NamedParameters; } --- 689,693 ---- throw new HibernateException( "Query does not refer to any persistent classes: " + queryString ); } ! return GetQuery( queries[ 0 ] ).NamedParameters; } *************** *** 701,705 **** public ICollectionMetadata GetCollectionMetadata( string roleName ) { ! return GetCollectionPersister( roleName ); } --- 723,727 ---- public ICollectionMetadata GetCollectionMetadata( string roleName ) { ! return GetCollectionPersister( roleName ) as ICollectionMetadata; } *************** *** 780,784 **** } ! foreach( CollectionPersister p in collectionPersisters.Values ) { if( p.HasCache ) --- 802,806 ---- } ! foreach( ICollectionPersister p in collectionPersisters.Values ) { if( p.HasCache ) *************** *** 832,836 **** public void EvictCollection( string roleName, object id ) { ! CollectionPersister p = GetCollectionPersister( roleName ); if( p.HasCache ) { --- 854,858 ---- public void EvictCollection( string roleName, object id ) { ! ICollectionPersister p = GetCollectionPersister( roleName ); if( p.HasCache ) { *************** *** 845,849 **** public void EvictCollection( string roleName ) { ! CollectionPersister p = GetCollectionPersister( roleName ); if( p.HasCache ) { --- 867,871 ---- public void EvictCollection( string roleName ) { ! ICollectionPersister p = GetCollectionPersister( roleName ); if( p.HasCache ) { Index: QueryImpl.cs =================================================================== RCS file: /cvsroot/nhibernate/nhibernate/src/NHibernate/Impl/QueryImpl.cs,v retrieving revision 1.20 retrieving revision 1.21 diff -C2 -d -r1.20 -r1.21 *** QueryImpl.cs 17 Jan 2005 03:40:57 -0000 1.20 --- QueryImpl.cs 1 Mar 2005 16:24:46 -0000 1.21 *************** *** 10,786 **** namespace NHibernate.Impl { ! internal class QueryImpl : IQuery { ! private ISessionImplementor session; ! private string queryString; ! ! private RowSelection selection; ! private ArrayList values = new ArrayList( 4 ); ! private ArrayList types = new ArrayList( 4 ); ! private IDictionary namedParameters = new Hashtable( 4 ); ! private IDictionary namedParametersLists = new Hashtable( 4 ); ! private IDictionary lockModes = new Hashtable( 2 ); ! ! /// <summary> ! /// ! /// </summary> ! /// <param name="queryString"></param> ! /// <param name="session"></param> ! public QueryImpl( string queryString, ISessionImplementor session ) ! { ! this.session = session; ! this.queryString = queryString; ! selection = new RowSelection(); ! } ! ! /// <summary></summary> ! public virtual IEnumerable Enumerable() ! { ! //TODO: see if there is a better way to implement ! QueryParameters qp = new QueryParameters( ! ( IType[ ] ) types.ToArray( typeof( IType ) ), ! ( object[ ] ) values.ToArray( typeof( object ) ), ! new Hashtable( namedParameters ), ! lockModes, ! selection ); ! ! string query = BindParameterLists( qp.NamedParameters ); ! return session.Enumerable( query, qp ); ! } ! ! /// <summary></summary> ! public IDictionary LockModes ! { ! get { return lockModes; } ! } ! ! /// <summary> ! /// ! /// </summary> ! /// <param name="alias"></param> ! /// <param name="lockMode"></param> ! public virtual void SetLockMode( string alias, LockMode lockMode ) ! { ! lockModes[ alias ] = lockMode; ! } ! ! /// <summary></summary> ! public virtual IList List() ! { ! //TODO: see if there is a better way to implement ! QueryParameters qp = new QueryParameters( ! ( IType[ ] ) types.ToArray( typeof( IType ) ), ! ( object[ ] ) values.ToArray( typeof( object ) ), ! new Hashtable( namedParameters ), ! lockModes, ! selection ); ! ! string query = BindParameterLists( qp.NamedParameters ); ! return session.Find( query, qp ); ! } ! ! /// <summary> ! /// ! /// </summary> ! /// <param name="maxResults"></param> ! /// <returns></returns> ! public IQuery SetMaxResults( int maxResults ) ! { ! selection.MaxRows = maxResults; ! return this; ! } ! ! /// <summary> ! /// ! /// </summary> ! /// <param name="timeout"></param> ! /// <returns></returns> ! public IQuery SetTimeout( int timeout ) ! { ! selection.Timeout = timeout; ! return this; ! } ! ! /// <summary> ! /// ! /// </summary> ! /// <param name="firstResult"></param> ! /// <returns></returns> ! public IQuery SetFirstResult( int firstResult ) ! { ! selection.FirstRow = firstResult; ! return this; ! } ! ! /// <summary> ! /// ! /// </summary> ! /// <param name="position"></param> ! /// <param name="val"></param> ! /// <param name="type"></param> ! /// <returns></returns> ! public IQuery SetParameter( int position, object val, IType type ) ! { ! int size = values.Count; ! if( position < size ) ! { ! values[ position ] = val; ! types[ position ] = type; ! } ! else ! { ! for( int i = 0; i < position - size; i++ ) ! { ! values.Add( null ); ! types.Add( null ); ! } ! values.Add( val ); ! types.Add( type ); ! } ! return this; ! } ! ! /// <summary> ! /// ! /// </summary> ! /// <param name="name"></param> ! /// <param name="val"></param> ! /// <param name="type"></param> ! /// <returns></returns> ! public IQuery SetParameter( string name, object val, IType type ) ! { ! namedParameters[ name ] = new TypedValue( type, val ); ! return this; ! } ! ! /// <summary> ! /// ! /// </summary> ! /// <param name="position"></param> ! /// <param name="val"></param> ! /// <returns></returns> ! public IQuery SetAnsiString( int position, string val ) ! { ! SetParameter( position, val, NHibernateUtil.AnsiString ); ! return this; ! } ! ! /// <summary> ! /// ! /// </summary> ! /// <param name="position"></param> ! /// <param name="val"></param> ! /// <returns></returns> ! public IQuery SetString( int position, string val ) ! { ! SetParameter( position, val, NHibernateUtil.String ); ! return this; ! } ! ! /// <summary> ! /// ! /// </summary> ! /// <param name="position"></param> ! /// <param name="val"></param> ! /// <returns></returns> ! public IQuery SetCharacter( int position, char val ) ! { ! SetParameter( position, val, NHibernateUtil.Character ); // ); ! return this; ! } ! ! /// <summary> ! /// ! /// </summary> ! /// <param name="position"></param> ! /// <param name="val"></param> ! /// <returns></returns> ! public IQuery SetBoolean( int position, bool val ) ! { ! SetParameter( position, val, NHibernateUtil.Boolean ); // ); ! return this; ! } ! ! /// <summary> ! /// ! /// </summary> ! /// <param name="position"></param> ! /// <param name="val"></param> ! /// <returns></returns> ! public IQuery SetByte( int position, byte val ) ! { ! SetParameter( position, val, NHibernateUtil.Byte ); ! return this; ! } ! ! /// <summary> ! /// ! /// </summary> ! /// <param name="position"></param> ! /// <param name="val"></param> ! /// <returns></returns> ! public IQuery SetInt16( int position, short val ) ! { ! SetParameter( position, val, NHibernateUtil.Int16 ); ! return this; ! } ! ! /// <summary> ! /// ! /// </summary> ! /// <param name="position"></param> ! /// <param name="val"></param> ! /// <returns></returns> ! public IQuery SetInt32( int position, int val ) ! { ! SetParameter( position, val, NHibernateUtil.Int32 ); ! return this; ! } ! ! /// <summary> ! /// ! /// </summary> ! /// <param name="position"></param> ! /// <param name="val"></param> ! /// <returns></returns> ! public IQuery SetInt64( int position, long val ) ! { ! SetParameter( position, val, NHibernateUtil.Int64 ); ! return this; ! } ! ! /// <summary> ! /// ! /// </summary> ! /// <param name="position"></param> ! /// <param name="val"></param> ! /// <returns></returns> ! public IQuery SetSingle( int position, float val ) ! { ! SetParameter( position, val, NHibernateUtil.Single ); ! return this; ! } ! ! /// <summary> ! /// ! /// </summary> ! /// <param name="position"></param> ! /// <param name="val"></param> ! /// <returns></returns> ! public IQuery SetDouble( int position, double val ) ! { ! SetParameter( position, val, NHibernateUtil.Double ); ! return this; ! } ! ! /// <summary> ! /// ! /// </summary> ! /// <param name="position"></param> ! /// <param name="val"></param> ! /// <returns></returns> ! public IQuery SetBinary( int position, byte[ ] val ) ! { ! SetParameter( position, val, NHibernateUtil.Binary ); ! return this; ! } ! ! /// <summary> ! /// ! /// </summary> ! /// <param name="position"></param> ! /// <param name="val"></param> ! /// <returns></returns> ! public IQuery SetDecimal( int position, decimal val ) ! { ! SetParameter( position, val, NHibernateUtil.Decimal ); ! return this; ! } ! ! /// <summary> ! /// ! /// </summary> ! /// <param name="position"></param> ! /// <param name="val"></param> ! /// <returns></returns> ! public IQuery SetDateTime( int position, DateTime val ) ! { ! SetParameter( position, val, NHibernateUtil.DateTime ); ! return this; ! } ! ! /// <summary> ! /// ! /// </summary> ! /// <param name="position"></param> ! /// <param name="val"></param> ! /// <returns></returns> ! public IQuery SetTime( int position, DateTime val ) ! { ! SetParameter( position, val, NHibernateUtil.DateTime ); //TODO: change to time ! return this; ! } ! ! /// <summary> ! /// ! /// </summary> ! /// <param name="position"></param> ! /// <param name="val"></param> ! /// <returns></returns> ! public IQuery SetTimestamp( int position, DateTime val ) ! { ! SetParameter( position, val, NHibernateUtil.Timestamp ); ! return this; ! } ! ! /// <summary> ! /// ! /// </summary> ! /// <param name="position"></param> ! /// <param name="val"></param> ! /// <returns></returns> ! public IQuery SetEntity( int position, object val ) ! { ! SetParameter( position, val, NHibernateUtil.Entity( NHibernateProxyHelper.GetClass( val ) ) ); ! return this; ! } ! ! /// <summary> ! /// ! /// </summary> ! /// <param name="position"></param> ! /// <param name="val"></param> ! /// <returns></returns> ! public IQuery SetEnum( int position, Enum val ) ! { ! SetParameter( position, val, NHibernateUtil.Enum( val.GetType() ) ); ! return this; ! } ! ! /// <summary> ! /// ! /// </summary> ! /// <param name="name"></param> ! /// <param name="val"></param> ! /// <returns></returns> ! public IQuery SetAnsiString( string name, string val ) ! { ! SetParameter( name, val, NHibernateUtil.AnsiString ); ! return this; ! } ! ! /// <summary> ! /// ! /// </summary> ! /// <param name="name"></param> ! /// <param name="val"></param> ! /// <returns></returns> ! public IQuery SetString( string name, string val ) ! { ! SetParameter( name, val, NHibernateUtil.String ); ! return this; ! } ! ! /// <summary> ! /// ! /// </summary> ! /// <param name="name"></param> ! /// <param name="val"></param> ! /// <returns></returns> ! public IQuery SetCharacter( string name, char val ) ! { ! SetParameter( name, val, NHibernateUtil.Character ); ! return this; ! } ! ! /// <summary> ! /// ! /// </summary> ! /// <param name="name"></param> ! /// <param name="val"></param> ! /// <returns></returns> ! public IQuery SetBoolean( string name, bool val ) ! { ! SetParameter( name, val, NHibernateUtil.Boolean ); ! return this; ! } ! ! /// <summary> ! /// ! /// </summary> ! /// <param name="name"></param> ! /// <param name="val"></param> ! /// <returns></returns> ! public IQuery SetByte( string name, byte val ) ! { ! SetParameter( name, val, NHibernateUtil.Byte ); ! return this; ! } ! ! /// <summary> ! /// ! /// </summary> ! /// <param name="name"></param> ! /// <param name="val"></param> ! /// <returns></returns> ! public IQuery SetInt16( string name, short val ) ! { ! SetParameter( name, val, NHibernateUtil.Int16 ); ! return this; ! } ! ! /// <summary> ! /// ! /// </summary> ! /// <param name="name"></param> ! /// <param name="val"></param> ! /// <returns></returns> ! public IQuery SetInt32( string name, int val ) ! { ! SetParameter( name, val, NHibernateUtil.Int32 ); ! return this; ! } ! ! /// <summary> ! /// ! /// </summary> ! /// <param name="name"></param> ! /// <param name="val"></param> ! /// <returns></returns> ! public IQuery SetInt64( string name, long val ) ! { ! SetParameter( name, val, NHibernateUtil.Int64 ); ! return this; ! } ! ! /// <summary> ! /// ! /// </summary> ! /// <param name="name"></param> ! /// <param name="val"></param> ! /// <returns></returns> ! public IQuery SetSingle( string name, float val ) ! { ! SetParameter( name, val, NHibernateUtil.Single ); ! return this; ! } ! ! /// <summary> ! /// ! /// </summary> ! /// <param name="name"></param> ! /// <param name="val"></param> ! /// <returns></returns> ! public IQuery SetDouble( string name, double val ) ! { ! SetParameter( name, val, NHibernateUtil.Double ); ! return this; ! } ! ! /// <summary> ! /// ! /// </summary> ! /// <param name="name"></param> ! /// <param name="val"></param> ! /// <returns></returns> ! public IQuery SetBinary( string name, byte[ ] val ) ! { ! SetParameter( name, val, NHibernateUtil.Binary ); ! return this; ! } ! ! /// <summary> ! /// ! /// </summary> ! /// <param name="name"></param> ! /// <param name="val"></param> ! /// <returns></returns> ! public IQuery SetDecimal( string name, decimal val ) ! { ! SetParameter( name, val, NHibernateUtil.Decimal ); ! return this; ! } ! ! /// <summary> ! /// ! /// </summary> ! /// <param name="name"></param> ! /// <param name="val"></param> ! /// <returns></returns> ! public IQuery SetDateTime( string name, DateTime val ) ! { ! SetParameter( name, val, NHibernateUtil.DateTime ); ! return this; ! } ! ! /// <summary> ! /// ! /// </summary> ! /// <param name="name"></param> ! /// <param name="val"></param> ! /// <returns></returns> ! public IQuery SetTime( string name, DateTime val ) ! { ! SetParameter( name, val, NHibernateUtil.DateTime ); //TODO: change to time ! return this; ! } ! ! /// <summary> ! /// ! /// </summary> ! /// <param name="name"></param> ! /// <param name="val"></param> ! /// <returns></returns> ! public IQuery SetTimestamp( string name, DateTime val ) ! { ! SetParameter( name, val, NHibernateUtil.Timestamp ); ! return this; ! } ! ! /// <summary> ! /// ! /// </summary> ! /// <param name="name"></param> ! /// <param name="val"></param> ! /// <returns></returns> ! public IQuery SetEntity( string name, object val ) ! { ! SetParameter( name, val, NHibernateUtil.Entity( NHibernateProxyHelper.GetClass( val ) ) ); ! return this; ! } ! ! /// <summary> ! /// ! /// </summary> ! /// <param name="name"></param> ! /// <param name="val"></param> ! /// <returns></returns> ! public IQuery SetEnum( string name, Enum val ) ! { ! SetParameter( name, val, NHibernateUtil.Enum( val.GetType() ) ); ! return this; ! } ! ! /// <summary> ! /// ! /// </summary> ! /// <param name="name"></param> ! /// <param name="val"></param> ! /// <returns></returns> ! public IQuery SetParameter( string name, object val ) ! { ! SetParameter( name, val, GuessType( val ) ); ! return this; ! } ! ! /// <summary> ! /// ! /// </summary> ! /// <param name="position"></param> ! /// <param name="val"></param> ! /// <returns></returns> ! public IQuery SetParameter( int position, object val ) ! { ! SetParameter( position, val, GuessType( val ) ); ! return this; ! } ! ! private IType GuessType( object param ) ! { ! System.Type clazz = NHibernateProxyHelper.GetClass( param ); ! return GuessType( clazz ); ! } ! ! private IType GuessType( System.Type clazz ) ! { ! string typename = clazz.AssemblyQualifiedName; ! IType type = TypeFactory.HueristicType( typename ); ! bool serializable = type != null && type is SerializableType; ! if( type == null || serializable ) ! { ! try ! { ! session.Factory.GetPersister( clazz ); ! } ! catch( MappingException ) ! { ! if( serializable ) ! { ! return type; ! } ! else ! { ! throw new HibernateException( "Could not determine a type for class: " + typename ); ! } ! } ! return NHibernateUtil.Entity( clazz ); ! } ! else ! { ! return type; ! } ! } ! ! /// <summary></summary> ! public IType[ ] ReturnTypes ! { ! get { return session.Factory.GetReturnTypes( queryString ); } ! } ! ! /// <summary> ! /// ! /// </summary> ! /// <param name="name"></param> ! /// <param name="vals"></param> ! /// <param name="type"></param> ! /// <returns></returns> ! public IQuery SetParameterList( string name, ICollection vals, IType type ) ! { ! namedParametersLists.Add( name, new TypedValue( type, vals ) ); ! return this; ! } ! ! /// <summary> ! /// ! /// </summary> ! /// <param name="namedParams"></param> ! /// <returns></returns> ! protected string BindParameterLists( IDictionary namedParams ) ! { ! string query = queryString; ! foreach( DictionaryEntry de in namedParametersLists ) ! { ! query = BindParameterList( query, ( string ) de.Key, ( TypedValue ) de.Value, namedParams ); ! } ! return query; ! } ! ! private string BindParameterList( string queryString, string name, TypedValue typedList, IDictionary namedParams ) ! { ! ICollection vals = ( ICollection ) typedList.Value; ! IType type = typedList.Type; ! StringBuilder list = new StringBuilder( 16 ); ! int i = 0; ! foreach( object obj in vals ) ! { ! string alias = name + i++ + StringHelper.Underscore; ! namedParams.Add( alias, new TypedValue( type, obj ) ); ! list.Append( ':' + alias ); ! if( i < vals.Count ) ! { ! list.Append( StringHelper.CommaSpace ); ! } ! } ! ! return StringHelper.Replace( queryString, ':' + name, list.ToString() ); ! } ! ! /// <summary> ! /// ! /// </summary> ! /// <param name="name"></param> ! /// <param name="vals"></param> ! /// <returns></returns> ! public IQuery SetParameterList( string name, ICollection vals ) ! { ! foreach( object obj in vals ) ! { ! SetParameterList( name, vals, GuessType( obj ) ); ! break; // fairly hackish...need the type of the first object ! } ! return this; ! } ! ! /// <summary></summary> ! public string[ ] NamedParameters ! { ! get ! { ! ICollection parms = session.Factory.GetNamedParameters( queryString ); ! string[ ] retVal = new String[parms.Count]; ! int i = 0; ! foreach( string parm in parms ) ! { ! retVal[ i++ ] = parm; ! } ! return retVal; ! } ! } ! ! /// <summary> ! /// ! /// </summary> ! /// <param name="bean"></param> ! /// <returns></returns> ! public IQuery SetProperties( object bean ) ! { ! System.Type clazz = bean.GetType(); ! foreach( string namedParam in session.Factory.GetNamedParameters( queryString ) ) ! { ! try ! { ! IGetter getter = ReflectHelper.GetGetter( clazz, namedParam ); ! SetParameter( namedParam, getter.Get( bean ), GuessType( getter.ReturnType ) ); ! } ! catch( Exception ) ! { ! } ! } ! return this; ! } ! ! /// <summary></summary> ! internal ISessionImplementor Session ! { ! get { return session; } ! } ! ! /// <summary></summary> ! internal ArrayList Values ! { ! get { return values; } ! } ! ! /// <summary></summary> ! internal ArrayList Types ! { ! get { return types; } ! } ! ! internal RowSelection Selection { - get { return selection; } } ! /// <summary></summary> ! public string QueryString { ! get { return queryString; } } /// <summary></summary> ! internal IDictionary NamedParams ! { ! get { return namedParameters; } ! } ! ! /// <summary> ! /// ! /// </summary> ! /// <param name="name"></param> ! /// <param name="vals"></param> ! /// <param name="type"></param> ! /// <returns></returns> ! public IQuery SetParameterList( string name, object[ ] vals, IType type ) ! { ! return SetParameterList( name, vals, type ); ! } ! ! // ! public IQuery SetParameterList( string name, object[ ] vals ) { ! return SetParameterList( name, vals ); } - } } \ No newline at end of file --- 10,34 ---- namespace NHibernate.Impl { ! internal class QueryImpl : AbstractQueryImpl { ! public QueryImpl( string queryString, ISessionImplementor session ) : base( queryString, session ) { } ! /// <summary></summary> ! public override IEnumerable Enumerable() { ! VerifyParameters(); ! IDictionary namedParams = NamedParams; ! return Session.Enumerable( BindParameterLists( namedParams ), QueryParams( namedParams ) ); } /// <summary></summary> ! public override IList List() { ! VerifyParameters(); ! IDictionary namedParams = NamedParams; ! return Session.Find( BindParameterLists( namedParams ), QueryParams( namedParams ) ); } } } \ No newline at end of file Index: ScheduledCollectionRecreate.cs =================================================================== RCS file: /cvsroot/nhibernate/nhibernate/src/NHibernate/Impl/ScheduledCollectionRecreate.cs,v retrieving revision 1.5 retrieving revision 1.6 diff -C2 -d -r1.5 -r1.6 *** ScheduledCollectionRecreate.cs 31 Dec 2004 19:52:53 -0000 1.5 --- ScheduledCollectionRecreate.cs 1 Mar 2005 16:24:46 -0000 1.6 *************** *** 15,22 **** /// </summary> /// <param name="collection">The <see cref="PersistentCollection"/> to recreate.</param> ! /// <param name="persister">The <see cref="CollectionPersister"/> that is responsible for the persisting the Collection.</param> /// <param name="id">The identifier of the Collection owner.</param> /// <param name="session">The <see cref="ISessionImplementor"/> that the Action is occuring in.</param> ! public ScheduledCollectionRecreate( PersistentCollection collection, CollectionPersister persister, object id, ISessionImplementor session ) : base( persister, id, session ) { --- 15,22 ---- /// </summary> /// <param name="collection">The <see cref="PersistentCollection"/> to recreate.</param> ! /// <param name="persister">The <see cref="ICollectionPersister"/> that is responsible for the persisting the Collection.</param> /// <param name="id">The identifier of the Collection owner.</param> /// <param name="session">The <see cref="ISessionImplementor"/> that the Action is occuring in.</param> ! public ScheduledCollectionRecreate( PersistentCollection collection, ICollectionPersister persister, object id, ISessionImplementor session ) : base( persister, id, session ) { *************** *** 27,32 **** public override void Execute() { - Persister.Softlock( Id ); Persister.Recreate( _collection, Id, Session ); } } --- 27,33 ---- public override void Execute() { Persister.Recreate( _collection, Id, Session ); + // TODO: Commented out as isn't in the 2.1 implementation - test + //Persister.Softlock( Id ); } } Index: OnUpdateVisitor.cs =================================================================== RCS file: /cvsroot/nhibernate/nhibernate/src/NHibernate/Impl/OnUpdateVisitor.cs,v retrieving revision 1.2 retrieving revision 1.3 diff -C2 -d -r1.2 -r1.3 *** OnUpdateVisitor.cs 7 Feb 2005 01:34:41 -0000 1.2 --- OnUpdateVisitor.cs 1 Mar 2005 16:24:46 -0000 1.3 *************** *** 38,42 **** protected override object ProcessCollection(object collection, PersistentCollectionType type) { ! CollectionPersister persister = Session.GetCollectionPersister( type.Role ); if( collection is PersistentCollection ) --- 38,42 ---- protected override object ProcessCollection(object collection, PersistentCollectionType type) { ! ICollectionPersister persister = Session.GetCollectionPersister( type.Role ); if( collection is PersistentCollection ) Index: FilterImpl.cs =================================================================== RCS file: /cvsroot/nhibernate/nhibernate/src/NHibernate/Impl/FilterImpl.cs,v retrieving revision 1.9 retrieving revision 1.10 diff -C2 -d -r1.9 -r1.10 *** FilterImpl.cs 31 Dec 2004 19:51:30 -0000 1.9 --- FilterImpl.cs 1 Mar 2005 16:24:46 -0000 1.10 *************** *** 26,37 **** public override IEnumerable Enumerable() { ! //TODO: see if there is a better way to implement ! QueryParameters qp = new QueryParameters( TypeArray(), ValueArray() ); ! qp.NamedParameters = new Hashtable( NamedParams ); ! qp.RowSelection = Selection; ! qp.LockModes = LockModes; ! ! string query = BindParameterLists( qp.NamedParameters ); ! return Session.EnumerableFilter( collection, query, qp ); } --- 26,33 ---- public override IEnumerable Enumerable() { ! // HACK: Reintroduce once Filter parsing bug resolved ! //VerifyParameters(); ! IDictionary namedParams = NamedParams; ! return Session.EnumerableFilter( collection, BindParameterLists( namedParams ), QueryParams( namedParams ) ); } *************** *** 39,53 **** public override IList List() { ! //TODO: see if there is a better way to implement ! QueryParameters qp = new QueryParameters( TypeArray(), ValueArray() ); ! qp.NamedParameters = new Hashtable( NamedParams ); ! qp.RowSelection = Selection; ! qp.LockModes = LockModes; ! ! string query = BindParameterLists( qp.NamedParameters ); ! return Session.Filter( collection, query, qp ); } ! private IType[ ] TypeArray() { IList typeList = Types; --- 35,45 ---- public override IList List() { ! // HACK: Reintroduce once Filter parsing bug resolved ! //VerifyParameters(); ! IDictionary namedParams = NamedParams; ! return Session.Filter( collection, BindParameterLists( namedParams ), QueryParams( namedParams ) ); } ! protected override IType[ ] TypeArray() { IList typeList = Types; *************** *** 61,65 **** } ! private object[ ] ValueArray() { IList valueList = Values; --- 53,57 ---- } ! protected override object[ ] ValueArray() { IList valueList = Values; Index: MessageHelper.cs =================================================================== RCS file: /cvsroot/nhibernate/nhibernate/src/NHibernate/Impl/MessageHelper.cs,v retrieving revision 1.5 retrieving revision 1.6 diff -C2 -d -r1.5 -r1.6 *** MessageHelper.cs 23 Jan 2005 15:50:21 -0000 1.5 --- MessageHelper.cs 1 Mar 2005 16:24:46 -0000 1.6 *************** *** 110,114 **** /// <param name="id"></param> /// <returns></returns> ! public static String InfoString( CollectionPersister persister, object id ) { StringBuilder s = new StringBuilder(); --- 110,114 ---- /// <param name="id"></param> /// <returns></returns> ! public static String InfoString( ICollectionPersister persister, object id ) { StringBuilder s = new StringBuilder(); Index: ScheduledDeletion.cs =================================================================== RCS file: /cvsroot/nhibernate/nhibernate/src/NHibernate/Impl/ScheduledDeletion.cs,v retrieving revision 1.5 retrieving revision 1.6 diff -C2 -d -r1.5 -r1.6 *** ScheduledDeletion.cs 31 Dec 2004 19:53:33 -0000 1.5 --- ScheduledDeletion.cs 1 Mar 2005 16:24:46 -0000 1.6 *************** *** 1,2 **** --- 1,3 ---- + using NHibernate.Cache; using NHibernate.Engine; using NHibernate.Persister; *************** *** 10,13 **** --- 11,15 ---- { private object _version; + private ISoftLock _lock; /// <summary> *************** *** 30,34 **** if( Persister.HasCache ) { ! Persister.Cache.Lock( Id ); } Persister.Delete( Id, _version, Instance, Session ); --- 32,36 ---- if( Persister.HasCache ) { ! _lock = Persister.Cache.Lock( Id ); } Persister.Delete( Id, _version, Instance, Session ); *************** *** 41,45 **** if( Persister.HasCache ) { ! Persister.Cache.Release( Id ); } } --- 43,47 ---- if( Persister.HasCache ) { ! Persister.Cache.Release( Id, _lock ); } } Index: OnLockVisitor.cs =================================================================== RCS file: /cvsroot/nhibernate/nhibernate/src/NHibernate/Impl/OnLockVisitor.cs,v retrieving revision 1.2 retrieving revision 1.3 diff -C2 -d -r1.2 -r1.3 *** OnLockVisitor.cs 7 Feb 2005 01:34:41 -0000 1.2 --- OnLockVisitor.cs 1 Mar 2005 16:24:46 -0000 1.3 *************** *** 22,26 **** protected override object ProcessCollection(object collection, PersistentCollectionType type) { ! CollectionPersister persister = Session.GetCollectionPersister( type.Role ); if( collection == null ) --- 22,26 ---- protected override object ProcessCollection(object collection, PersistentCollectionType type) { ! ICollectionPersister persister = Session.GetCollectionPersister( type.Role ); if( collection == null ) Index: ScheduledCollectionAction.cs =================================================================== RCS file: /cvsroot/nhibernate/nhibernate/src/NHibernate/Impl/ScheduledCollectionAction.cs,v retrieving revision 1.9 retrieving revision 1.10 diff -C2 -d -r1.9 -r1.10 *** ScheduledCollectionAction.cs 31 Dec 2004 19:52:43 -0000 1.9 --- ScheduledCollectionAction.cs 1 Mar 2005 16:24:46 -0000 1.10 *************** *** 1,2 **** --- 1,3 ---- + using NHibernate.Cache; using NHibernate.Collection; using NHibernate.Engine; *************** *** 10,24 **** internal abstract class ScheduledCollectionAction : IExecutable { ! private CollectionPersister _persister; private object _id; private ISessionImplementor _session; /// <summary> /// Initializes a new instance of <see cref="ScheduledCollectionAction"/>. /// </summary> ! /// <param name="persister">The <see cref="CollectionPersister"/> that is responsible for the persisting the Collection.</param> /// <param name="id">The identifier of the Collection owner.</param> /// <param name="session">The <see cref="ISessionImplementor"/> that the Action is occuring in.</param> ! public ScheduledCollectionAction( CollectionPersister persister, object id, ISessionImplementor session ) { _persister = persister; --- 11,26 ---- internal abstract class ScheduledCollectionAction : IExecutable { ! private ICollectionPersister _persister; private object _id; private ISessionImplementor _session; + private ISoftLock _lock = null; /// <summary> /// Initializes a new instance of <see cref="ScheduledCollectionAction"/>. /// </summary> ! /// <param name="persister">The <see cref="ICollectionPersister"/> that is responsible for the persisting the Collection.</param> /// <param name="id">The identifier of the Collection owner.</param> /// <param name="session">The <see cref="ISessionImplementor"/> that the Action is occuring in.</param> ! public ScheduledCollectionAction( ICollectionPersister persister, object id, ISessionImplementor session ) { _persister = persister; *************** *** 28,34 **** /// <summary> ! /// Gets the <see cref="CollectionPersister"/> that is responsible for persisting the Collection. /// </summary> ! public CollectionPersister Persister { get { return _persister; } --- 30,36 ---- /// <summary> ! /// Gets the <see cref="ICollectionPersister"/> that is responsible for persisting the Collection. /// </summary> ! public ICollectionPersister Persister { get { return _persister; } *************** *** 56,60 **** public void AfterTransactionCompletion() { ! _persister.ReleaseSoftlock( _id ); } --- 58,65 ---- public void AfterTransactionCompletion() { ! if ( _persister.HasCache ) ! { ! _persister.Cache.Release( _id, _lock ); ! } } *************** *** 64,68 **** public object[ ] PropertySpaces { ! get { return new string[ ] {_persister.QualifiedTableName}; } //TODO: cache the array on the persister } --- 69,73 ---- public object[ ] PropertySpaces { ! get { return new object[ ] {_persister.CollectionSpace}; } //TODO: cache the array on the persister } Index: CollectionKey.cs =================================================================== RCS file: /cvsroot/nhibernate/nhibernate/src/NHibernate/Impl/CollectionKey.cs,v retrieving revision 1.2 retrieving revision 1.3 diff -C2 -d -r1.2 -r1.3 *** CollectionKey.cs 7 Feb 2005 01:34:40 -0000 1.2 --- CollectionKey.cs 1 Mar 2005 16:24:46 -0000 1.3 *************** *** 11,15 **** private object key; ! public CollectionKey(string role, object key) { this.role = role; --- 11,15 ---- private object key; ! public CollectionKey( string role, object key ) { this.role = role; *************** *** 17,22 **** } ! public CollectionKey(CollectionPersister persister, object key) ! : this(persister.Role, key) { } --- 17,22 ---- } ! public CollectionKey( ICollectionPersister persister, object key ) ! : this( persister.Role, key ) { } --- NEW FILE: AbstractQueryImpl.cs --- using System; using System.Collections; using System.Text; using Iesi.Collections; using NHibernate.Engine; using NHibernate.Property; using NHibernate.Proxy; using NHibernate.Type; using NHibernate.Util; namespace NHibernate.Impl { /// <summary> /// Abstract implementation of the IQuery interface. /// </summary> internal abstract class AbstractQueryImpl : IQuery { private string queryString; private IDictionary lockModes = new Hashtable( 2 ); private ISessionImplementor session; private RowSelection selection; private ArrayList values = new ArrayList( 4 ); private ArrayList types = new ArrayList( 4 ); private int positionalParameterCount = 0; private ISet actualNamedParameters; private IDictionary namedParameters = new Hashtable( 4 ); private IDictionary namedParametersLists = new Hashtable( 4 ); private static readonly object UNSET_PARAMETER = new Object(); private static readonly object UNSET_TYPE = new Object(); /// <summary> /// /// </summary> /// <param name="queryString"></param> /// <param name="session"></param> public AbstractQueryImpl( string queryString, ISessionImplementor session ) { this.session = session; this.queryString = queryString; selection = new RowSelection(); InitParameterBookKeeping(); } protected void VerifyParameters() { actualNamedParameters = new ListSet( session.Factory.GetNamedParameters( queryString ) ); if ( actualNamedParameters.Count != namedParameters.Count + namedParametersLists.Count ) { Set missingParams = new ListSet( actualNamedParameters ); missingParams.RemoveAll( namedParametersLists.Keys ); missingParams.RemoveAll( namedParameters.Keys ); throw new QueryException( "Not all named parameters have been set: " + missingParams ) ; } if ( positionalParameterCount != values.Count ) throw new QueryException( string.Format( "Not all positional parameters have been set. Expected {0}, set {1}.", positionalParameterCount, values.Count ) ); for ( int i = 0; i < values.Count; i++ ) { if ( values[i] == UNSET_PARAMETER || types[i] == UNSET_TYPE ) throw new QueryException( string.Format( "Not all positional parameters have been set. Found unset parameter at position {0}.", i) ); } } // Leave it to the kids to do public abstract IEnumerable Enumerable(); /// <summary></summary> public IDictionary LockModes { get { return lockModes; } } /// <summary> /// /// </summary> /// <param name="alias"></param> /// <param name="lockMode"></param> public virtual void SetLockMode( string alias, LockMode lockMode ) { lockModes[ alias ] = lockMode; } protected virtual IType[] TypeArray() { return ( IType[ ] ) types.ToArray( typeof( IType ) ); } protected virtual object[] ValueArray() { return ( object[ ] ) values.ToArray( typeof( object ) ); } protected QueryParameters QueryParams( IDictionary namedParams ) { return new QueryParameters( TypeArray(), ValueArray(), namedParams, lockModes, selection ); } // Leave it to the kids to do public abstract IList List(); /// <summary> /// /// </summary> /// <param name="maxResults"></param> /// <returns></returns> public IQuery SetMaxResults( int maxResults ) { selection.MaxRows = maxResults; return this; } /// <summary> /// /// </summary> /// <param name="timeout"></param> /// <returns></returns> public IQuery SetTimeout( int timeout ) { selection.Timeout = timeout; return this; } /// <summary> /// /// </summary> /// <param name="firstResult"></param> /// <returns></returns> public IQuery SetFirstResult( int firstResult ) { selection.FirstRow = firstResult; return this; } /// <summary> /// /// </summary> /// <param name="position"></param> /// <param name="val"></param> /// <param name="type"></param> /// <returns></returns> public IQuery SetParameter( int position, object val, IType type ) { if ( positionalParameterCount == 0 ) throw new ArgumentOutOfRangeException( string.Format( "No positional parameters in query: {0}", queryString ) ); if ( position < 0 || position > positionalParameterCount - 1 ) throw new ArgumentOutOfRangeException( string.Format( "Positional parameter does not exists: {0} in query: {1}", position, queryString ) ); int size = values.Count; if ( position < size ) { values[ position ] = val; types[ position ] = type; } else { // Put guard values in for any positions before the wanted position - allows us to detect unset parameters on validate. for( int i = 0; i < position - size; i++ ) { values.Add( UNSET_PARAMETER ); types.Add( UNSET_TYPE ); } values.Add( val ); types.Add( type ); } return this; } /// <summary> /// /// </summary> /// <param name="name"></param> /// <param name="val"></param> /// <param name="type"></param> /// <returns></returns> public IQuery SetParameter( string name, object val, IType type ) { namedParameters[ name ] = new TypedValue( type, val ); return this; } /// <summary> /// /// </summary> /// <param name="position"></param> /// <param name="val"></param> /// <returns></returns> public IQuery SetAnsiString( int position, string val ) { SetParameter( position, val, NHibernateUtil.AnsiString ); return this; } /// <summary> /// /// </summary> /// <param name="position"></param> /// <param name="val"></param> /// <returns></returns> public IQuery SetString( int position, string val ) { SetParameter( position, val, NHibernateUtil.String ); return this; } /// <summary> /// /// </summary> /// <param name="position"></param> /// <param name="val"></param> /// <returns></returns> public IQuery SetCharacter( int position, char val ) { SetParameter( position, val, NHibernateUtil.Character ); // ); return this; } /// <summary> /// /// </summary> /// <param name="position"></param> /// <param name="val"></param> /// <returns></returns> public IQuery SetBoolean( int position, bool val ) { SetParameter( position, val, NHibernateUtil.Boolean ); // ); return this; } /// <summary> /// /// </summary> /// <param name="position"></param> /// <param name="val"></param> /// <returns></returns> public IQuery SetByte( int position, byte val ) { SetParameter( position, val, NHibernateUtil.Byte ); return this; } /// <summary> /// /// </summary> /// <param name="position"></param> /// <param name="val"></param> /// <returns></returns> public IQuery SetInt16( int position, short val ) { SetParameter( position, val, NHibernateUtil.Int16 ); return this; } /// <summary> /// /// </summary> /// <param name="position"></param> /// <param name="val"></param> /// <returns></returns> public IQuery SetInt32( int position, int val ) { SetParameter( position, val, NHibernateUtil.Int32 ); return this; } /// <summary> /// /// </summary> /// <param name="position"></param> /// <param name="val"></param> /// <returns></returns> public IQuery SetInt64( int position, long val ) { SetParameter( position, val, NHibernateUtil.Int64 ); return this; } /// <summary> /// /// </summary> /// <param name="position"></param> /// <param name="val"></param> /// <returns></returns> public IQuery SetSingle( int position, float val ) { SetParameter( position, val, NHibernateUtil.Single ); return this; } /// <summary> /// /// </summary> /// <param name="position"></param> /// <param name="val"></param> /// <returns></returns> public IQuery SetDouble( int position, double val ) { SetParameter( position, val, NHibernateUtil.Double ); return this; } /// <summary> /// /// </summary> /// <param name="position"></param> /// <param name="val"></param> /// <returns></returns> public IQuery SetBinary( int position, byte[ ] val ) { SetParameter( position, val, NHibernateUtil.Binary ); return this; } /// <summary> /// /// </summary> /// <param name="position"></param> /// <param name="val"></param> /// <returns></returns> public IQuery SetDecimal( int position, decimal val ) { SetParameter( position, val, NHibernateUtil.Decimal ); return this; } /// <summary> /// /// </summary> /// <param name="position"></param> /// <param name="val"></param> /// <returns></returns> public IQuery SetDateTime( int position, DateTime val ) { SetParameter( position, val, NHibernateUtil.DateTime ); return this; } /// <summary> /// /// </summary> /// <param name="position"></param> /// <param name="val"></param> /// <returns></returns> public IQuery SetTime( int position, DateTime val ) { SetParameter( position, val, NHibernateUtil.DateTime ); //TODO: change to time return this; } /// <summary> /// /// </summary> /// <param name="position"></param> /// <param name="val"></param> /// <returns></returns> public IQuery SetTimestamp( int position, DateTime val ) { SetParameter( position, val, NHibernateUtil.Timestamp ); return this; } /// <summary> /// /// </summary> /// <param name="position"></param> /// <param name="val"></param> /// <returns></returns> public IQuery SetEntity( int position, object val ) { SetParameter( position, val, NHibernateUtil.Entity( NHibernateProxyHelper.GetClass( val ) ) ); return this; } /// <summary> /// /// </summary> /// <param name="position"></param> /// <param name="val"></param> /// <returns></returns> public IQuery SetEnum( int position, Enum val ) { SetParameter( position, val, NHibernateUtil.Enum( val.GetType() ) ); return this; } /// <summary> /// /// </summary> /// <param name="name"></param> /// <param name="val"></param> /// <returns></returns> public IQuery SetAnsiString( string name, string val ) { SetParameter( name, val, NHibernateUtil.AnsiString ); return this; } /// <summary> /// /// </summary> /// <param name="name"></param> /// <param name="val"></param> /// <returns></returns> public IQuery SetString( string name, string val ) { SetParameter( name, val, NHibernateUtil.String ); return this; } /// <summary> /// /// </summary> /// <param name="name"></param> /// <param name="val"></param> /// <returns></returns> public IQuery SetCharacter( string name, char val ) { SetParameter( name, val, NHibernateUtil.Character ); return this; } ///... [truncated message content] |
Update of /cvsroot/nhibernate/nhibernate/src/NHibernate/Collection In directory sc8-pr-cvs1.sourceforge.net:/tmp/cvs-serv5548/nhibernate/src/NHibernate/Collection Modified Files: ArrayHolder.cs Bag.cs CollectionPersister.cs IdentifierBag.cs List.cs Map.cs PersistentCollection.cs Set.cs SortedMap.cs SortedSet.cs Added Files: AbstractCollectionPersister.cs BasicCollectionPersister.cs CollectionPropertyMapping.cs CompositeElementPropertyMapping.cs ElementPropertyMapping.cs ICollectionPersister.cs IQueryableCollection.cs OneToManyPersister.cs Log Message: Various refactorings on the way to 2.1 querying capability --- NEW FILE: CompositeElementPropertyMapping.cs --- using NHibernate.Engine; using NHibernate.Persister; using NHibernate.Type; using NHibernate.Util; namespace NHibernate.Collection { /// <summary> /// Summary description for CompositeElementPropertyMapping. /// </summary> public class CompositeElementPropertyMapping : AbstractPropertyMapping { private readonly IAbstractComponentType compositeType; /// <summary> /// /// </summary> /// <param name="elementColumns"></param> /// <param name="compositeType"></param> /// <param name="factory"></param> public CompositeElementPropertyMapping( string[] elementColumns, IAbstractComponentType compositeType, ISessionFactoryImplementor factory ) { this.compositeType = compositeType; InitComponentPropertyPaths( null, compositeType, elementColumns, factory ); } /// <summary></summary> public override IType Type { get { return compositeType; } } /// <summary></summary> public override string ClassName { get { return compositeType.Name; } } } } --- NEW FILE: ICollectionPersister.cs --- using System.Data; using NHibernate.Cache; using NHibernate.Engine; using NHibernate.Id; using NHibernate.Metadata; using NHibernate.Type; namespace NHibernate.Collection { /// <summary> /// <p>A strategy for persisting a collection role. Defines a contract between /// the persistence strategy and the actual persistent collection framework /// and session. Does not define operations that are required for querying /// collections, or loading by outer join.</p> /// <p> /// Implements persistence of a collection instance while the instance is /// referenced in a particular role.</p> /// <p> /// This class is highly coupled to the <tt>PersistentCollection</tt> /// hierarchy, since double dispatch is used to load and update collection /// elements.</p> /// </summary> /// <remarks> /// May be considered an immutable view of the mapping object /// </remarks> public interface ICollectionPersister { /// <summary> /// Initialize the given collection with the given key /// </summary> /// <param name="key"></param> /// <param name="owner"></param> /// <param name="session"></param> void Initialize( object key, object owner, ISessionImplementor session ); /// <summary> /// Get the cache /// </summary> ICacheConcurrencyStrategy Cache { get; } /// <summary> /// Is this collection role cacheable /// </summary> bool HasCache { get; } /// <summary> /// Get the associated <c>IType</c> /// </summary> PersistentCollectionType CollectionType { get; } /// <summary> /// Get the "key" type (the type of the foreign key) /// </summary> IType KeyType { get; } /// <summary> /// Get the "index" type for a list or map (optional operation) /// </summary> IType IndexType { get; } /// <summary> /// Get the "element" type /// </summary> IType ElementType { get; } /// <summary> /// Return the element class of an array, or null otherwise /// </summary> System.Type ElementClass { get; } /// <summary> /// Read the key from a row of the <tt>IDataReader</tt> /// </summary> /// <param name="rs"></param> /// <param name="session"></param> /// <returns></returns> object ReadKey( IDataReader rs, ISessionImplementor session ); /// <summary> /// /// </summary> /// <param name="rs"></param> /// <param name="owner"></param> /// <param name="session"></param> /// <returns></returns> object ReadElement( IDataReader rs, object owner, ISessionImplementor session ); /// <summary> /// /// </summary> /// <param name="rs"></param> /// <param name="session"></param> /// <returns></returns> object ReadIdentifier( IDataReader rs, ISessionImplementor session ); /// <summary> /// /// </summary> /// <param name="rs"></param> /// <param name="session"></param> /// <returns></returns> object ReadIndex( IDataReader rs, ISessionImplementor session ); /// <summary> /// /// </summary> /// <param name="st"></param> /// <param name="key"></param> /// <param name="writeOrder"></param> /// <param name="session"></param> void WriteKey( IDbCommand st, object key, bool writeOrder, ISessionImplementor session ); /// <summary> /// /// </summary> /// <param name="st"></param> /// <param name="elt"></param> /// <param name="writeOrder"></param> /// <param name="session"></param> void WriteElement( IDbCommand st, object elt, bool writeOrder, ISessionImplementor session ); /// <summary> /// /// </summary> /// <param name="st"></param> /// <param name="idx"></param> /// <param name="writeOrder"></param> /// <param name="session"></param> void WriteIndex( IDbCommand st, object idx, bool writeOrder, ISessionImplementor session ); /// <summary> /// /// </summary> /// <param name="st"></param> /// <param name="idx"></param> /// <param name="writeOrder"></param> /// <param name="session"></param> void WriteIdentifier( IDbCommand st, object idx, bool writeOrder, ISessionImplementor session ); /// <summary> /// Is this an array or primitive values? /// </summary> bool IsPrimitiveArray { get; } /// <summary> /// Is this an array? /// </summary> bool IsArray { get; } /// <summary> /// Is this a one-to-many association? /// </summary> bool IsOneToMany { get; } /// <summary> /// Is this an "indexed" collection? (list or map) /// </summary> bool HasIndex { get; } /// <summary> /// Is this collection lazyily initialized? /// </summary> bool IsLazy { get; } /// <summary> /// Is this collection "inverse", so state changes are not propogated to the database. /// </summary> bool IsInverse { get; } /// <summary> /// Completely remove the persistent state of the collection /// </summary> /// <param name="id"></param> /// <param name="session"></param> void Remove( object id, ISessionImplementor session ); /// <summary> /// (Re)create the collection's persistent state /// </summary> /// <param name="collection"></param> /// <param name="key"></param> /// <param name="session"></param> void Recreate( PersistentCollection collection, object key, ISessionImplementor session ); /// <summary> /// Delete the persistent state of any elements that were removed from the collection /// </summary> /// <param name="collection"></param> /// <param name="key"></param> /// <param name="session"></param> void DeleteRows( PersistentCollection collection, object key, ISessionImplementor session ); /// <summary> /// Update the persistent state of any elements that were modified /// </summary> /// <param name="collection"></param> /// <param name="key"></param> /// <param name="session"></param> void UpdateRows( PersistentCollection collection, object key, ISessionImplementor session ); /// <summary> /// Insert the persistent state of any new collection elements /// </summary> /// <param name="collection"></param> /// <param name="key"></param> /// <param name="session"></param> void InsertRows( PersistentCollection collection, object key, ISessionImplementor session ); /// <summary> /// Get the name of this collection role (the fully qualified class name, extended by a "property path") /// </summary> string Role { get; } /// <summary> /// Get the entity class that "owns" this collection /// </summary> System.Type OwnerClass { get; } /// <summary> /// Get the surrogate key generation strategy (optional operation) /// </summary> IIdentifierGenerator IdentifierGenerator { get; } /// <summary> /// Get the type of the surrogate key /// </summary> IType IdentifierType { get; } /// <summary> /// Does this collection implement "orphan delete"? /// </summary> bool HasOrphanDelete { get; } /// <summary> /// Is this an ordered collection? (An ordered collection is /// ordered by the initialization operation, not by sorting /// that happens in memory, as in the case of a sorted collection.) /// </summary> bool HasOrdering { get; } /// <summary> /// Get the "space" that holds the persistent state /// </summary> object CollectionSpace { get; } /// <summary> /// /// </summary> ICollectionMetadata CollectionMetadata { get; } } } Index: Map.cs =================================================================== RCS file: /cvsroot/nhibernate/nhibernate/src/NHibernate/Collection/Map.cs,v retrieving revision 1.20 retrieving revision 1.21 diff -C2 -d -r1.20 -r1.21 *** Map.cs 14 Feb 2005 03:35:19 -0000 1.20 --- Map.cs 1 Mar 2005 16:24:44 -0000 1.21 *************** *** 23,27 **** /// <param name="persister"></param> /// <returns></returns> ! protected override object Snapshot( CollectionPersister persister ) { Hashtable clonedMap = new Hashtable( map.Count ); --- 23,27 ---- /// <param name="persister"></param> /// <returns></returns> ! protected override object Snapshot( ICollectionPersister persister ) { Hashtable clonedMap = new Hashtable( map.Count ); *************** *** 70,73 **** --- 70,83 ---- /// <summary> + /// + /// </summary> + /// <param name="collection"></param> + /// <returns></returns> + public override bool IsWrapper( object collection ) + { + return map == collection; + } + + /// <summary> /// Construct an uninitialized Map. /// </summary> *************** *** 93,97 **** /// </summary> /// <param name="persister"></param> ! public override void BeforeInitialize( CollectionPersister persister ) { if( persister.HasOrdering ) --- 103,107 ---- /// </summary> /// <param name="persister"></param> ! public override void BeforeInitialize( ICollectionPersister persister ) { if( persister.HasOrdering ) *************** *** 278,282 **** /// <param name="i"></param> /// <param name="writeOrder"></param> ! public override void WriteTo( IDbCommand st, CollectionPersister persister, object entry, int i, bool writeOrder ) { DictionaryEntry e = ( DictionaryEntry ) entry; --- 288,292 ---- /// <param name="i"></param> /// <param name="writeOrder"></param> ! public override void WriteTo( IDbCommand st, ICollectionPersister persister, object entry, int i, bool writeOrder ) { DictionaryEntry e = ( DictionaryEntry ) entry; *************** *** 292,296 **** /// <param name="owner"></param> /// <returns></returns> ! public override object ReadFrom( IDataReader rs, CollectionPersister persister, object owner ) { object element = persister.ReadElement(rs, owner, session); --- 302,306 ---- /// <param name="owner"></param> /// <returns></returns> ! public override object ReadFrom( IDataReader rs, ICollectionPersister persister, object owner ) { object element = persister.ReadElement(rs, owner, session); *************** *** 318,322 **** /// <param name="disassembled">The disassembled Map.</param> /// <param name="owner">The owner object.</param> ! public override void InitializeFromCache(CollectionPersister persister, object disassembled, object owner) { BeforeInitialize( persister ); --- 328,332 ---- /// <param name="disassembled">The disassembled Map.</param> /// <param name="owner">The owner object.</param> ! public override void InitializeFromCache( ICollectionPersister persister, object disassembled, object owner ) { BeforeInitialize( persister ); *************** *** 335,339 **** /// <param name="persister"></param> /// <returns></returns> ! public override object Disassemble( CollectionPersister persister ) { object[ ] result = new object[map.Count*2]; --- 345,349 ---- /// <param name="persister"></param> /// <returns></returns> ! public override object Disassemble( ICollectionPersister persister ) { object[ ] result = new object[map.Count*2]; --- NEW FILE: CollectionPropertyMapping.cs --- using NHibernate.Persister; using NHibernate.Type; using NHibernate.Util; namespace NHibernate.Collection { /// <summary> /// Summary description for CollectionPropertyMapping. /// </summary> public class CollectionPropertyMapping : IPropertyMapping { /// <summary></summary> public const string CollectionSize = "size"; /// <summary></summary> public const string CollectionElements = "elements"; /// <summary></summary> public const string CollectionIndices = "indices"; /// <summary></summary> public const string CollectionMaxIndex = "maxIndex"; /// <summary></summary> public const string CollectionMinIndex = "minIndex"; /// <summary></summary> public const string CollectionMaxElement = "maxElement"; /// <summary></summary> public const string CollectionMinElement = "minElement"; private readonly IQueryableCollection memberPersister; private const string InvalidPropertyMessage = "expecting 'elements' or 'indicies' after {0}"; /// <summary> /// /// </summary> /// <param name="memberPersister"></param> public CollectionPropertyMapping( IQueryableCollection memberPersister ) { this.memberPersister = memberPersister; } /// <summary> /// /// </summary> public IType Type { get { return memberPersister.CollectionType; } } /// <summary> /// /// </summary> /// <param name="propertyName"></param> /// <returns></returns> public IType ToType( string propertyName ) { switch ( propertyName ) { case CollectionElements: case CollectionMaxElement: case CollectionMinElement: return memberPersister.ElementType; case CollectionIndices: case CollectionMaxIndex: case CollectionMinIndex: CheckIndex( propertyName ); return memberPersister.IndexType; case CollectionSize: return NHibernateUtil.Int32; default: throw new QueryException( string.Format( InvalidPropertyMessage, propertyName ) ); } } /// <summary> /// /// </summary> /// <param name="alias"></param> /// <param name="propertyName"></param> /// <returns></returns> public string[] ToColumns( string alias, string propertyName ) { string[] cols; switch ( propertyName ) { case CollectionElements: cols = memberPersister.ElementColumnNames; return StringHelper.Qualify( alias, cols ); case CollectionIndices: CheckIndex( propertyName ); cols = memberPersister.IndexColumnNames; return StringHelper.Qualify( alias, cols ); case CollectionSize: return new string[] { "count(*)" }; case CollectionMaxIndex: CheckIndex( propertyName ); return ColumnFunction( propertyName, "max", memberPersister.IndexColumnNames ) ; case CollectionMinIndex: CheckIndex( propertyName ); return ColumnFunction( propertyName, "min", memberPersister.IndexColumnNames ) ; case CollectionMaxElement: return ColumnFunction( propertyName, "max", memberPersister.IndexColumnNames ) ; case CollectionMinElement: return ColumnFunction( propertyName, "min", memberPersister.IndexColumnNames ) ; default: throw new QueryException( string.Format( InvalidPropertyMessage, propertyName ) ); } } private void CheckIndex( string propertyName ) { if ( !memberPersister.HasIndex ) { throw new QueryException( string.Format( "unindexed collection before {0}", propertyName ) ); } } private string[] ColumnFunction( string propertyName, string function, string[] cols ) { if ( cols.Length !=1 ) { throw new QueryException( string.Format( "composite collection element in {0}", propertyName ) ); } return new string[] { function + StringHelper.OpenParen + cols[0] + StringHelper.ClosedParen }; } } } Index: CollectionPersister.cs =================================================================== RCS file: /cvsroot/nhibernate/nhibernate/src/NHibernate/Collection/CollectionPersister.cs,v retrieving revision 1.33 retrieving revision 1.34 diff -C2 -d -r1.33 -r1.34 *** CollectionPersister.cs 14 Feb 2005 03:35:19 -0000 1.33 --- CollectionPersister.cs 1 Mar 2005 16:24:44 -0000 1.34 *************** *** 11,14 **** --- 11,15 ---- using NHibernate.Mapping; using NHibernate.Metadata; + using NHibernate.Persister; using NHibernate.SqlCommand; using NHibernate.Type; *************** *** 25,29 **** /// May be considered an immutable view of the mapping object /// </remarks> ! public sealed class CollectionPersister : ICollectionMetadata { private static readonly ILog log = LogManager.GetLogger( typeof( CollectionPersister ) ); --- 26,30 ---- /// May be considered an immutable view of the mapping object /// </remarks> ! public sealed class CollectionPersister : ICollectionMetadata, IQueryableCollection { private static readonly ILog log = LogManager.GetLogger( typeof( CollectionPersister ) ); *************** *** 65,69 **** private readonly ICacheConcurrencyStrategy cache; private readonly PersistentCollectionType collectionType; ! private readonly OuterJoinLoaderType enableJoinedFetch; private readonly System.Type ownerClass; --- 66,70 ---- private readonly ICacheConcurrencyStrategy cache; private readonly PersistentCollectionType collectionType; ! private readonly OuterJoinFetchStrategy enableJoinedFetch; private readonly System.Type ownerClass; *************** *** 81,84 **** --- 82,87 ---- private readonly Dialect.Dialect dialect; private readonly ISessionFactoryImplementor factory; + private readonly IPropertyMapping elementPropertyMapping; + private readonly IClassPersister elementPersister; /// <summary> *************** *** 92,96 **** this.factory = factory; this.dialect = factory.Dialect; ! collectionType = collection.Type; role = collection.Role; ownerClass = collection.OwnerClass; --- 95,99 ---- this.factory = factory; this.dialect = factory.Dialect; ! collectionType = collection.CollectionType; role = collection.Role; ownerClass = collection.OwnerClass; *************** *** 100,104 **** hasOrder = sqlOrderByString != null; sqlOrderByStringTemplate = hasOrder ? Template.RenderOrderByStringTemplate( sqlOrderByString, dialect ) : null; - sqlWhereString = collection.Where; hasWhere = sqlWhereString != null; --- 103,106 ---- *************** *** 107,110 **** --- 109,114 ---- hasOrphanDelete = collection.OrphanDelete; + //batchSize = collection.BatchSize; + cache = collection.Cache; *************** *** 131,147 **** ICollection iter; if( isOneToMany ) { ! EntityType type = collection.OneToMany.Type; elementType = type; ! PersistentClass associatedClass = datastore.GetClassMapping( type.PersistentClass ); span = associatedClass.Identifier.ColumnSpan; iter = associatedClass.Key.ColumnCollection; table = associatedClass.Table; ! enableJoinedFetch = OuterJoinLoaderType.Eager; } else { ! table = collection.Table; elementType = collection.Element.Type; span = collection.Element.ColumnSpan; --- 135,162 ---- ICollection iter; + elementType = collection.Element.Type; + + if ( elementType.IsEntityType ) + { + elementPersister = factory.GetPersister( ( (EntityType) elementType).AssociatedClass ); + } + else + { + elementPersister = null; + } + if( isOneToMany ) { ! EntityType type = (EntityType) collection.Element.Type; elementType = type; ! PersistentClass associatedClass = datastore.GetClassMapping( type.AssociatedClass ); span = associatedClass.Identifier.ColumnSpan; iter = associatedClass.Key.ColumnCollection; table = associatedClass.Table; ! enableJoinedFetch = OuterJoinFetchStrategy.Eager; } else { ! table = collection.CollectionTable; elementType = collection.Element.Type; span = collection.Element.ColumnSpan; *************** *** 149,153 **** iter = collection.Element.ColumnCollection; CheckColumnDuplication( distinctColumns, collection.Element.ColumnCollection ); - } --- 164,167 ---- *************** *** 257,260 **** --- 271,312 ---- } loader = CreateCollectionQuery( factory ); + + if ( elementType.IsComponentType ) + { + elementPropertyMapping = new CompositeElementPropertyMapping( elementColumnNames, (IAbstractComponentType) elementType, factory ); + } + else if ( !elementType.IsEntityType ) + { + elementPropertyMapping = new ElementPropertyMapping( elementColumnNames, elementType ); + } + else + { + IClassPersister persister = factory.GetPersister( ( (EntityType) elementType).AssociatedClass ); + // Not all classpersisters implement IPropertyMapping! + if ( persister is IPropertyMapping ) + { + elementPropertyMapping = (IPropertyMapping) persister; + } + else + { + elementPropertyMapping = new ElementPropertyMapping( elementColumnNames, elementType ); + } + } + } + + /// <summary> + /// + /// </summary> + public ICollectionMetadata CollectionMetadata + { + get { return this; } + } + + /// <summary> + /// + /// </summary> + public object CollectionSpace + { + get { return QualifiedTableName; } } *************** *** 282,296 **** /// /// </summary> ! public ICacheConcurrencyStrategy Cache ! { ! get { return cache; } ! } ! ! /// <summary> ! /// ! /// </summary> ! public bool HasCache { ! get { return cache != null; } } --- 334,343 ---- /// /// </summary> ! /// <param name="key"></param> ! /// <param name="owner"></param> ! /// <param name="session"></param> ! public void Initialize( object key, object owner, ISessionImplementor session ) { ! Initializer.Initialize( key, null, owner, session ); } *************** *** 298,308 **** /// /// </summary> ! /// <param name="id"></param> ! public void Softlock( object id ) { ! if( cache != null ) ! { ! cache.Lock( id ); ! } } --- 345,351 ---- /// /// </summary> ! public ICacheConcurrencyStrategy Cache { ! get { return cache; } } *************** *** 310,320 **** /// /// </summary> ! /// <param name="id"></param> ! public void ReleaseSoftlock( object id ) { ! if( cache != null ) ! { ! cache.Release( id ); ! } } --- 353,359 ---- /// /// </summary> ! public bool HasCache { ! get { return cache != null; } } *************** *** 365,369 **** /// /// </summary> ! public OuterJoinLoaderType EnableJoinFetch { get { return enableJoinedFetch; } --- 404,414 ---- /// /// </summary> ! public OuterJoinFetchStrategy EnableJoinFetch ! { ! get { return enableJoinedFetch; } ! } ! ! /// <summary></summary> ! public OuterJoinFetchStrategy EnableJoinedFetch { get { return enableJoinedFetch; } *************** *** 591,594 **** --- 636,647 ---- } + /// <summary> + /// + /// </summary> + public bool IsCollection + { + get { return true; } + } + /// <summary></summary> public bool IsArray *************** *** 604,622 **** public string SelectClauseFragment( string alias ) { - SelectFragment frag = new SelectFragment( factory.Dialect ) - .SetSuffix( String.Empty ) - .AddColumns( alias, elementColumnNames, elementColumnAliases ); - if( hasIndex ) - { - frag.AddColumns( alias, indexColumnNames, indexColumnAliases ); - } - if( hasIdentifier ) - { - frag.AddColumn( alias, identifierColumnName, identifierColumnAlias ); - } // TODO: fix this once the interface is changed from a String to a SqlString // this works for now because there are no parameters in the select string. ! return frag.ToSqlStringFragment( false ) ! .ToString(); } --- 657,663 ---- public string SelectClauseFragment( string alias ) { // TODO: fix this once the interface is changed from a String to a SqlString // this works for now because there are no parameters in the select string. ! return SelectFragment( alias).ToString(); } *************** *** 828,831 **** --- 869,878 ---- /// <summary></summary> + public string TableName + { + get { return qualifiedTableName; } + } + + /// <summary></summary> public string QualifiedTableName { *************** *** 1220,1223 **** --- 1267,1425 ---- } + #region IJoinable 2.1 bits + /// <summary> + /// + /// </summary> + public string Name + { + get { return Role; } + } + + /// <summary> + /// + /// </summary> + /// <returns></returns> + public bool ConsumesAlias( ) + { + return false; + } + + /// <summary> + /// + /// </summary> + public bool IsManyToMany + { + get { return ElementType.IsEntityType; } + } + + /// <summary> + /// + /// </summary> + public string[] JoinKeyColumns + { + get { return KeyColumnNames; } + } + + /// <summary> + /// + /// </summary> + /// <param name="alias"></param> + /// <param name="suffix"></param> + /// <param name="includeCollectionColumns"></param> + /// <returns></returns> + public SqlString SelectFragment( string alias, string suffix, bool includeCollectionColumns ) + { + return includeCollectionColumns ? SelectFragment( alias ) : null; + } + + /// <summary> + /// + /// </summary> + /// <param name="alias"></param> + /// <param name="innerJoin"></param> + /// <param name="includeSubclasses"></param> + /// <returns></returns> + public SqlString FromJoinFragment( string alias, bool innerJoin, bool includeSubclasses ) + { + return null; + } + + /// <summary> + /// + /// </summary> + /// <param name="alias"></param> + /// <param name="innerJoin"></param> + /// <param name="includeSubclasses"></param> + /// <returns></returns> + public SqlString WhereJoinFragment( string alias, bool innerJoin, bool includeSubclasses ) + { + return null; + } + #endregion + + #region IPropertyMapping 2.1 bits + + /// <summary> + /// + /// </summary> + /// <param name="alias"></param> + /// <param name="propertyName"></param> + /// <returns></returns> + public string[] ToColumns( string alias, string propertyName ) + { + if ( "index".Equals( propertyName ) ) + { + if ( IsManyToMany ) + { + throw new QueryException( "index() function not supported for many-to-many association" ); + } + return StringHelper.Qualify( alias, indexColumnNames ); + } + return elementPropertyMapping.ToColumns( alias, propertyName ); + } + + /// <summary> + /// + /// </summary> + /// <param name="propertyName"></param> + /// <returns></returns> + public IType ToType( string propertyName ) + { + if ( "index".Equals( propertyName ) ) + { + return indexType; + } + return elementPropertyMapping.ToType( propertyName ); + } + + /// <summary> + /// + /// </summary> + public IType Type + { + get { return elementPropertyMapping.Type; } + } + #endregion + + #region IQueryableCollection 2.1 bits + /// <summary> + /// + /// </summary> + public IClassPersister ElementPersister + { + get + { + if ( elementPersister == null ) + { + throw new AssertionFailure( "Not an association" ); + } + + return (ILoadable) elementPersister; + } + } + + /// <summary> + /// + /// </summary> + /// <param name="alias"></param> + /// <returns></returns> + public SqlString SelectFragment( string alias ) + { + SelectFragment frag = new SelectFragment( factory.Dialect ) + .SetSuffix( String.Empty ) + .AddColumns( alias, elementColumnNames, elementColumnAliases ); + if( hasIndex ) + { + frag.AddColumns( alias, indexColumnNames, indexColumnAliases ); + } + if( hasIdentifier ) + { + frag.AddColumn( alias, identifierColumnName, identifierColumnAlias ); + } + // TODO: fix this once the interface is changed from a String to a SqlString + // this works for now because there are no parameters in the select string. + return frag.ToSqlStringFragment( false ); + } + #endregion } } \ No newline at end of file Index: Set.cs =================================================================== RCS file: /cvsroot/nhibernate/nhibernate/src/NHibernate/Collection/Set.cs,v retrieving revision 1.25 retrieving revision 1.26 diff -C2 -d -r1.25 -r1.26 *** Set.cs 14 Feb 2005 03:35:19 -0000 1.25 --- Set.cs 1 Mar 2005 16:24:44 -0000 1.26 *************** *** 43,47 **** /// </summary> /// <param name="persister"></param> ! protected override object Snapshot( CollectionPersister persister ) { Hashtable clonedMap = new Hashtable( internalSet.Count ); --- 43,47 ---- /// </summary> /// <param name="persister"></param> ! protected override object Snapshot( ICollectionPersister persister ) { Hashtable clonedMap = new Hashtable( internalSet.Count ); *************** *** 97,100 **** --- 97,110 ---- /// /// </summary> + /// <param name="collection"></param> + /// <returns></returns> + public override bool IsWrapper( object collection ) + { + return internalSet == collection; + } + + /// <summary> + /// + /// </summary> /// <param name="session"></param> internal Set( ISessionImplementor session ) : base( session ) *************** *** 123,127 **** /// <param name="disassembled">The disassembled Set.</param> /// <param name="owner">The owner object.</param> ! public override void InitializeFromCache(CollectionPersister persister, object disassembled, object owner) { BeforeInitialize( persister ); --- 133,137 ---- /// <param name="disassembled">The disassembled Set.</param> /// <param name="owner">The owner object.</param> ! public override void InitializeFromCache( ICollectionPersister persister, object disassembled, object owner ) { BeforeInitialize( persister ); *************** *** 138,142 **** /// </summary> /// <param name="persister"></param> ! public override void BeforeInitialize( CollectionPersister persister ) { if( persister.HasOrdering ) --- 148,152 ---- /// </summary> /// <param name="persister"></param> ! public override void BeforeInitialize( ICollectionPersister persister ) { if( persister.HasOrdering ) *************** *** 379,383 **** /// <param name="i"></param> /// <param name="writeOrder"></param> ! public override void WriteTo( IDbCommand st, CollectionPersister persister, object entry, int i, bool writeOrder ) { persister.WriteElement( st, entry, writeOrder, session ); --- 389,393 ---- /// <param name="i"></param> /// <param name="writeOrder"></param> ! public override void WriteTo( IDbCommand st, ICollectionPersister persister, object entry, int i, bool writeOrder ) { persister.WriteElement( st, entry, writeOrder, session ); *************** *** 391,395 **** /// <param name="owner"></param> /// <returns></returns> ! public override object ReadFrom( IDataReader rs, CollectionPersister persister, object owner ) { object element = persister.ReadElement(rs, owner, session); --- 401,405 ---- /// <param name="owner"></param> /// <returns></returns> ! public override object ReadFrom( IDataReader rs, ICollectionPersister persister, object owner ) { object element = persister.ReadElement(rs, owner, session); *************** *** 436,440 **** /// </summary> /// <param name="persister"></param> ! public override object Disassemble( CollectionPersister persister ) { object[ ] result = new object[internalSet.Count]; --- 446,450 ---- /// </summary> /// <param name="persister"></param> ! public override object Disassemble( ICollectionPersister persister ) { object[ ] result = new object[internalSet.Count]; --- NEW FILE: AbstractCollectionPersister.cs --- using System; using System.Collections; using System.Data; using Iesi.Collections; using log4net; using NHibernate.Cache; using NHibernate.Cfg; using NHibernate.Dialect; using NHibernate.Engine; using NHibernate.Id; using NHibernate.Impl; using NHibernate.Loader; using NHibernate.Mapping; using NHibernate.Metadata; using NHibernate.Persister; using NHibernate.SqlCommand; using NHibernate.Type; using NHibernate.Util; using Array = NHibernate.Mapping.Array; [...1268 lines suppressed...] /// <param name="includeSubclasses"></param> /// <returns></returns> public abstract SqlString FromJoinFragment( string alias, bool innerJoin, bool includeSubclasses ); /// <summary> /// /// </summary> /// <param name="alias"></param> /// <param name="innerJoin"></param> /// <param name="includeSubclasses"></param> /// <returns></returns> public abstract SqlString WhereJoinFragment( string alias, bool innerJoin, bool includeSubclasses ); /// <summary> /// /// </summary> /// <returns></returns> public abstract bool ConsumesAlias( ); } } --- NEW FILE: OneToManyPersister.cs --- using System; using System.Collections; using System.Data; using NHibernate.Cache; using NHibernate.Cfg; using NHibernate.Dialect; using NHibernate.Engine; using NHibernate.Id; using NHibernate.Impl; using NHibernate.Loader; using NHibernate.Mapping; using NHibernate.Metadata; using NHibernate.Persister; using NHibernate.SqlCommand; using NHibernate.Type; using NHibernate.Util; namespace NHibernate.Collection { /// <summary> /// Summary description for OneToManyPersister. /// </summary> public class OneToManyPersister : AbstractCollectionPersister { /// <summary> /// /// </summary> /// <param name="collection"></param> /// <param name="datastore"></param> /// <param name="factory"></param> public OneToManyPersister( Mapping.Collection collection, Configuration datastore, ISessionFactoryImplementor factory ) : base( collection, datastore, factory ) { } /// <summary> /// /// </summary> /// <returns></returns> protected override SqlString GenerateDeleteString( ) { SqlUpdateBuilder update = new SqlUpdateBuilder( factory ); update.SetTableName( QualifiedTableName ) .AddColumns( KeyColumnNames, "null" ) .SetIdentityColumn( KeyColumnNames, KeyType ); if( HasIndex ) { update.AddColumns( IndexColumnNames, "null" ); } if( HasWhere ) { update.AddWhereFragment( Where ); } return update.ToSqlString(); } /// <summary> /// /// </summary> /// <returns></returns> protected override SqlString GenerateInsertRowString( ) { SqlUpdateBuilder update = new SqlUpdateBuilder( factory ); update.SetTableName( QualifiedTableName ) .AddColumns( KeyColumnNames, KeyType ) .SetIdentityColumn( ElementColumnNames, ElementType ); if( HasIndex ) { update.AddColumns( IndexColumnNames, IndexType ); } return update.ToSqlString(); } /// <summary> /// /// </summary> /// <returns></returns> protected override SqlString GenerateUpdateRowString( ) { return null; } /// <summary> /// /// </summary> /// <returns></returns> protected override SqlString GenerateDeleteRowString( ) { SqlUpdateBuilder update = new SqlUpdateBuilder( factory ); update.SetTableName( QualifiedTableName ) .AddColumns( KeyColumnNames, "null" ); if( HasIndex ) { update.AddColumns( IndexColumnNames, "null" ); } if( HasIdentifier ) { update.AddWhereFragment( RowSelectColumnNames, RowSelectType, " = " ); } else { update.AddWhereFragment( KeyColumnNames, KeyType, " = " ); update.AddWhereFragment( RowSelectColumnNames, RowSelectType, " = " ); } return update.ToSqlString(); } /// <summary> /// /// </summary> /// <returns></returns> public override bool ConsumesAlias( ) { return true; } /// <summary> /// /// </summary> public override bool IsOneToMany { get { return true; } } /// <summary> /// /// </summary> public override bool IsManyToMany { get { return false; } } /// <summary> /// /// </summary> /// <param name="id"></param> /// <param name="collection"></param> /// <param name="session"></param> /// <returns></returns> protected int DoUpdateRows( object id, PersistentCollection collection, ISessionImplementor session ) { // we finish all the "removes" first to take care of possible unique // constraints and so that we can take better advantage of batching IDbCommand st; ICollection entries; int i; int count; try { // update removed rows fks to null count = 0; try { st = null; i = 0; entries = collection.Entries(); foreach( object entry in entries ) { if( collection.NeedsUpdating( entry, i, ElementType ) ) // will still be issued when it used to be null { if( st == null ) { st = session.Batcher.PrepareBatchCommand( SqlDeleteRowString ); } WriteKey( st, id, false, session ); WriteIndex( st, collection.GetIndex( entry, i ), false, session ); session.Batcher.AddToBatch( -1 ); count++; } i++; } } catch( Exception e ) { //TODO: change to SqlException session.Batcher.AbortBatch( e ); throw; } // now update all changed or added rows fks count = 0; try { st = null; i = 0; entries = collection.Entries(); foreach( object entry in entries ) { if( collection.NeedsUpdating( entry, i, ElementType ) ) // will still be issued when it used to be null { if( st == null ) { st = session.Batcher.PrepareBatchCommand( SqlInsertRowString ); } WriteKey( st, id, false, session ); collection.WriteTo( st, this, entry, i, false ); session.Batcher.AddToBatch( 1 ); count++; } i++; } } catch( Exception e ) { //TODO: change to SqlException session.Batcher.AbortBatch( e ); throw; } return count; } catch ( Exception ) { //TODO: change to SqlException throw; } } /// <summary> /// /// </summary> /// <param name="alias"></param> /// <param name="suffix"></param> /// <param name="includeCollectionColumns"></param> /// <returns></returns> public override SqlString SelectFragment( string alias, string suffix, bool includeCollectionColumns ) { IOuterJoinLoadable ojl = (IOuterJoinLoadable) ElementPersister; if ( includeCollectionColumns ) { // Super impl will ignore suffix for collection columns! return SelectFragment( alias ).Append( StringHelper.CommaSpace ); } else { // Use suffix for the entity columns. return ojl.SelectFragment( alias, suffix ); } } /// <summary> /// /// </summary> /// <param name="factory"></param> /// <returns></returns> protected override ICollectionInitializer CreateCollectionInitializer( ISessionFactoryImplementor factory ) { // Don't worry about batching for now // TODO: Uncomment when we implement OneToManyLoader /* Loader nonbatchLoader = new OneToManyLoader( this, factory ); if ( batchSize > 1 ) { Loader batchLoader = new OneToManyLoader( this, batchSize, factory ); int smallBatchSize = (int) Math.Round( Math.Sqrt( batchSize ) ); Loader smallBatchLoader = new OneToManyLoader( this, smallBatchSize, factory ); // the strategy for choosing batch or single load return new BatchingCollectionInitializer( this, batchSize, batchLoader, smallBatchSize, smallBatchLoader, nonbatchLoader ); } else { // don't to batch loading return (ICollectionInitializer) nonbatchLoader; } */ return null; } /// <summary> /// /// </summary> /// <param name="alias"></param> /// <param name="innerJoin"></param> /// <param name="includeSubclasses"></param> /// <returns></returns> public override SqlString FromJoinFragment( string alias, bool innerJoin, bool includeSubclasses ) { return ( (IJoinable) ElementPersister).FromJoinFragment( alias, innerJoin, includeSubclasses ); } /// <summary> /// /// </summary> /// <param name="alias"></param> /// <param name="innerJoin"></param> /// <param name="includeSubclasses"></param> /// <returns></returns> public override SqlString WhereJoinFragment( string alias, bool innerJoin, bool includeSubclasses ) { return ( (IJoinable) ElementPersister).WhereJoinFragment( alias, innerJoin, includeSubclasses ); } } } --- NEW FILE: ElementPropertyMapping.cs --- using NHibernate.Persister; using NHibernate.Type; using NHibernate.Util; namespace NHibernate.Collection { /// <summary> /// Summary description for ElementPropertyMapping. /// </summary> public class ElementPropertyMapping : IPropertyMapping { private readonly string[] elementColumns; private readonly IType type; /// <summary> /// /// </summary> /// <param name="elementColumns"></param> /// <param name="type"></param> public ElementPropertyMapping( string[] elementColumns, IType type) { this.elementColumns = elementColumns; this.type = type; } #region IPropertyMapping Members /// <summary> /// /// </summary> /// <param name="propertyName"></param> /// <returns></returns> public IType ToType( string propertyName ) { if ( propertyName == null || "id".Equals( propertyName ) ) { return type; } else { throw new QueryException( string.Format( "cannot dereference scalar collection element: {0}", propertyName ) ); } } /// <summary> /// /// </summary> /// <param name="alias"></param> /// <param name="propertyName"></param> /// <returns></returns> public string[] ToColumns( string alias, string propertyName ) { if ( propertyName == null || "id".Equals( propertyName ) ) { return StringHelper.Qualify( alias, elementColumns ); } else { throw new QueryException( string.Format( "cannot dereference scalar collection element: {0}", propertyName ) ); } } /// <summary> /// /// </summary> public IType Type { get { return type; } } #endregion } } Index: Bag.cs =================================================================== RCS file: /cvsroot/nhibernate/nhibernate/src/NHibernate/Collection/Bag.cs,v retrieving revision 1.14 retrieving revision 1.15 diff -C2 -d -r1.14 -r1.15 *** Bag.cs 14 Feb 2005 03:35:19 -0000 1.14 --- Bag.cs 1 Mar 2005 16:24:44 -0000 1.15 *************** *** 62,65 **** --- 62,76 ---- } + + /// <summary> + /// + /// </summary> + /// <param name="collection"></param> + /// <returns></returns> + public override bool IsWrapper( object collection ) + { + return bag == collection; + } + /// <summary> /// *************** *** 78,82 **** /// <param name="owner"></param> /// <returns></returns> ! public override object ReadFrom( IDataReader reader, CollectionPersister persister, object owner ) { object element = persister.ReadElement( reader, owner, session ); --- 89,93 ---- /// <param name="owner"></param> /// <returns></returns> ! public override object ReadFrom( IDataReader reader, ICollectionPersister persister, object owner ) { object element = persister.ReadElement( reader, owner, session ); *************** *** 93,97 **** /// <param name="i"></param> /// <param name="writeOrder"></param> ! public override void WriteTo( IDbCommand st, CollectionPersister persister, object entry, int i, bool writeOrder ) { persister.WriteElement( st, entry, writeOrder, session ); --- 104,108 ---- /// <param name="i"></param> /// <param name="writeOrder"></param> ! public override void WriteTo( IDbCommand st, ICollectionPersister persister, object entry, int i, bool writeOrder ) { persister.WriteElement( st, entry, writeOrder, session ); *************** *** 102,106 **** /// </summary> /// <param name="persister"></param> ! public override void BeforeInitialize( CollectionPersister persister ) { this.bag = new ArrayList(); --- 113,117 ---- /// </summary> /// <param name="persister"></param> ! public override void BeforeInitialize( ICollectionPersister persister ) { this.bag = new ArrayList(); *************** *** 157,161 **** /// <param name="persister"></param> /// <returns></returns> ! protected override object Snapshot( CollectionPersister persister ) { ArrayList clonedList = new ArrayList( bag.Count ); --- 168,172 ---- /// <param name="persister"></param> /// <returns></returns> ! protected override object Snapshot( ICollectionPersister persister ) { ArrayList clonedList = new ArrayList( bag.Count ); *************** *** 186,190 **** /// <param name="persister"></param> /// <returns></returns> ! public override object Disassemble( CollectionPersister persister ) { int length = bag.Count; --- 197,201 ---- /// <param name="persister"></param> /// <returns></returns> ! public override object Disassemble( ICollectionPersister persister ) { int length = bag.Count; *************** *** 205,209 **** /// <param name="disassembled">The disassembled Bag.</param> /// <param name="owner">The owner object.</param> ! public override void InitializeFromCache(CollectionPersister persister, object disassembled, object owner) { BeforeInitialize( persister ); --- 216,220 ---- /// <param name="disassembled">The disassembled Bag.</param> /// <param name="owner">The owner object.</param> ! public override void InitializeFromCache( ICollectionPersister persister, object disassembled, object owner ) { BeforeInitialize( persister ); *************** *** 228,232 **** /// <c>many-to-many</c> so it is just recreated. /// </returns> ! public override bool NeedsRecreate( CollectionPersister persister ) { return !persister.IsOneToMany; --- 239,243 ---- /// <c>many-to-many</c> so it is just recreated. /// </returns> ! public override bool NeedsRecreate( ICollectionPersister persister ) { return !persister.IsOneToMany; Index: ArrayHolder.cs =================================================================== RCS file: /cvsroot/nhibernate/nhibernate/src/NHibernate/Collection/ArrayHolder.cs,v retrieving revision 1.17 retrieving revision 1.18 diff -C2 -d -r1.17 -r1.18 *** ArrayHolder.cs 14 Feb 2005 03:35:19 -0000 1.17 --- ArrayHolder.cs 1 Mar 2005 16:24:44 -0000 1.18 *************** *** 48,52 **** /// <param name="persister"></param> /// <returns></returns> ! protected override object Snapshot( CollectionPersister persister ) { int length = /*(array==null) ? temp.Count :*/ array.Length; --- 48,52 ---- /// <param name="persister"></param> /// <returns></returns> ! protected override object Snapshot( ICollectionPersister persister ) { int length = /*(array==null) ? temp.Count :*/ array.Length; *************** *** 95,99 **** /// <param name="session"></param> /// <param name="persister"></param> ! public ArrayHolder( ISessionImplementor session, CollectionPersister persister ) : base( session ) { --- 95,99 ---- /// <param name="session"></param> /// <param name="persister"></param> ! public ArrayHolder( ISessionImplementor session, ICollectionPersister persister ) : base( session ) { *************** *** 112,115 **** --- 112,125 ---- /// /// </summary> + /// <param name="collection"></param> + /// <returns></returns> + public override bool IsWrapper( object collection ) + { + return array == collection; + } + + /// <summary> + /// + /// </summary> /// <param name="elementType"></param> /// <returns></returns> *************** *** 165,169 **** /// <param name="i"></param> /// <param name="writeOrder"></param> ! public override void WriteTo( IDbCommand st, CollectionPersister persister, object entry, int i, bool writeOrder ) { persister.WriteElement( st, entry, writeOrder, session ); --- 175,179 ---- /// <param name="i"></param> /// <param name="writeOrder"></param> ! public override void WriteTo( IDbCommand st, ICollectionPersister persister, object entry, int i, bool writeOrder ) { persister.WriteElement( st, entry, writeOrder, session ); *************** *** 178,182 **** /// <param name="owner"></param> /// <returns></returns> ! public override object ReadFrom( IDataReader rs, CollectionPersister persister, object owner ) { object element = persister.ReadElement(rs, owner, session); --- 188,192 ---- /// <param name="owner"></param> /// <returns></returns> ! public override object ReadFrom( IDataReader rs, ICollectionPersister persister, object owner ) { object element = persister.ReadElement(rs, owner, session); *************** *** 235,239 **** /// </summary> /// <param name="persister"></param> ! public override void BeforeInitialize( CollectionPersister persister ) { } --- 245,249 ---- /// </summary> /// <param name="persister"></param> ! public override void BeforeInitialize( ICollectionPersister persister ) { } *************** *** 261,265 **** /// <param name="disassembled">The disassembled Array.</param> /// <param name="owner">The owner object.</param> ! public override void InitializeFromCache(CollectionPersister persister, object disassembled, object owner) { object[] cached = ( object[] ) disassembled; --- 271,275 ---- /// <param name="disassembled">The disassembled Array.</param> /// <param name="owner">The owner object.</param> ! public override void InitializeFromCache( ICollectionPersister persister, object disassembled, object owner ) { object[] cached = ( object[] ) disassembled; *************** *** 279,283 **** /// <param name="persister"></param> /// <returns></returns> ! public override object Disassemble( CollectionPersister persister ) { int length = array.Length; --- 289,293 ---- /// <param name="persister"></param> /// <returns></returns> ! public override object Disassemble( ICollectionPersister persister ) { int length = array.Length; Index: List.cs =================================================================== RCS file: /cvsroot/nhibernate/nhibernate/src/NHibernate/Collection/List.cs,v retrieving revision 1.19 retrieving revision 1.20 diff -C2 -d -r1.19 -r1.20 *** List.cs 14 Feb 2005 03:35:19 -0000 1.19 --- List.cs 1 Mar 2005 16:24:44 -0000 1.20 *************** *** 20,24 **** /// <param name="persister"></param> /// <returns></returns> ! protected override object Snapshot( CollectionPersister persister ) { ArrayList clonedList = new ArrayList( list.Count ); --- 20,24 ---- /// <param name="persister"></param> /// <returns></returns> ! protected override object Snapshot( ICollectionPersister persister ) { ArrayList clonedList = new ArrayList( list.Count ); *************** *** 69,72 **** --- 69,82 ---- /// /// </summary> + /// <param name="collection"></param> + /// <returns></returns> + public override bool IsWrapper( object collection ) + { + return list == collection; + } + + /// <summary> + /// + /// </summary> /// <param name="session"></param> internal List( ISessionImplementor session ) : base( session ) *************** *** 90,94 **** /// </summary> /// <param name="persister"></param> ! public override void BeforeInitialize( CollectionPersister persister ) { this.list = new ArrayList(); --- 100,104 ---- /// </summary> /// <param name="persister"></param> ! public override void BeforeInitialize( ICollectionPersister persister ) { this.list = new ArrayList(); *************** *** 289,293 **** /// <param name="i"></param> /// <param name="writeOrder"></param> ! public override void WriteTo( IDbCommand st, CollectionPersister persister, object entry, int i, bool writeOrder ) { persister.WriteElement( st, entry, writeOrder, session ); --- 299,303 ---- /// <param name="i"></param> /// <param name="writeOrder"></param> ! public override void WriteTo( IDbCommand st, ICollectionPersister persister, object entry, int i, bool writeOrder ) { persister.WriteElement( st, entry, writeOrder, session ); *************** *** 302,306 **** /// <param name="owner"></param> /// <returns></returns> ! public override object ReadFrom( IDataReader rs, CollectionPersister persister, object owner ) { object element = persister.ReadElement(rs, owner, session); --- 312,316 ---- /// <param name="owner"></param> /// <returns></returns> ! public override object ReadFrom( IDataReader rs, ICollectionPersister persister, object owner ) { object element = persister.ReadElement(rs, owner, session); *************** *** 328,332 **** /// <param name="disassembled">The disassembled List.</param> /// <param name="owner">The owner object.</param> ! public override void InitializeFromCache(CollectionPersister persister, object disassembled, object owner) { BeforeInitialize( persister ); --- 338,342 ---- /// <param name="disassembled">The disassembled List.</param> /// <param name="owner">The owner object.</param> ! public override void InitializeFromCache( ICollectionPersister persister, object disassembled, object owner ) { BeforeInitialize( persister ); *************** *** 344,348 **** /// <param name="persister"></param> /// <returns></returns> ! public override object Disassemble( CollectionPersister persister ) { int length = list.Count; --- 354,358 ---- /// <param name="persister"></param> /// <returns></returns> ! public override object Disassemble( ICollectionPersister persister ) { int length = list.Count; --- NEW FILE: IQueryableCollection.cs --- using NHibernate.Loader; using NHibernate.Persister; using NHibernate.SqlCommand; namespace NHibernate.Collection { /// <summary> /// A collection role that may be queried or loaded by outer join. /// </summary> public interface IQueryableCollection : IPropertyMapping, IJoinable, ICollectionPersister { /// <summary> /// Get the names of the collection index columns if this is an indexed collection (optional operation) /// </summary> string[] IndexColumnNames { get; } /// <summary> /// Get the names of the collection element columns (or the primary key columns in the case of a one-to-many association) /// </summary> string[] ElementColumnNames { get; } /// <summary> /// Get the names of the collection key columns /// </summary> string[] KeyColumnNames { get; } /// <summary> /// Does this collection role have a where clause filter? /// </summary> bool HasWhere { get; } /// <summary> /// Get the persister of the element class, if this is a /// collection of entities (optional operation). Note that /// for a one-to-many association, the returned persister /// must be <tt>OuterJoinLoadable</tt>. /// </summary> IClassPersister ElementPersister { get; } /// <summary> /// Should we load this collection role by outer joining? /// </summary> OuterJoinFetchStrategy EnableJoinedFetch { get; } /// <summary> /// Generate a list of collection index and element columns /// </summary> /// <param name="alias"></param> /// <returns></returns> SqlString SelectFragment( string alias ); /// <summary> /// Get the extra where clause filter SQL /// </summary> /// <param name="alias"></param> /// <returns></returns> string GetSQLWhereString( string alias ); /// <summary> /// Get the order by SQL /// </summary> /// <param name="alias"></param> /// <returns></returns> string GetSQLOrderByString( string alias ); } } Index: SortedSet.cs =================================================================== RCS file: /cvsroot/nhibernate/nhibernate/src/NHibernate/Collection/SortedSet.cs,v retrieving revision 1.14 retrieving revision 1.15 diff -C2 -d -r1.14 -r1.15 *** SortedSet.cs 14 Feb 2005 03:35:19 -0000 1.14 --- SortedSet.cs 1 Mar 2005 16:24:44 -0000 1.15 *************** *** 23,27 **** /// <param name="persister"></param> /// <returns></returns> ! protected override object Snapshot( CollectionPersister persister ) { SortedList clonedSet = new SortedList( comparer, internalSet.Count ); --- 23,27 ---- /// <param name="persister"></param> /// <returns></returns> ! protected override object Snapshot( ICollectionPersister persister ) { SortedList clonedSet = new SortedList( comparer, internalSet.Count ); *************** *** 45,49 **** /// </summary> /// <param name="persister"></param> ! public override void BeforeInitialize( CollectionPersister persister ) { internalSet = new Iesi.Collections.SortedSet( Comparer ); --- 45,49 ---- /// </summary> /// <param name="persister"></param> ! public override void BeforeInitialize( ICollectionPersister persister ) { internalSet = new Iesi.Collections.SortedSet( Comparer ); --- NEW FILE: BasicCollectionPersister.cs --- using System; using System.Collections; using System.Data; using NHibernate.Cache; using NHibernate.Cfg; using NHibernate.Dialect; using NHibernate.Engine; using NHibernate.Id; using NHibernate.Impl; using NHibernate.Loader; using NHibernate.Mapping; using NHibernate.Metadata; using NHibernate.Persister; using NHibernate.SqlCommand; using NHibernate.Type; using NHibernate.Util; namespace NHibernate.Collection { /// <summary> /// Collection persister for collections of values and many-to-many associations. /// </summary> public class BasicCollectionPersister : AbstractCollectionPersister { /// <summary> /// /// </summary> /// <param name="collection"></param> /// <param name="datastore"></param> /// <param name="factory"></param> public BasicCollectionPersister( Mapping.Collection collection, Configuration datastore, ISessionFactoryImplementor factory ) : base( collection, datastore, factory ) { } /// <summary> /// /// </summary> /// <returns></returns> protected override SqlString GenerateDeleteString( ) { SqlDeleteBuilder delete = new SqlDeleteBuilder( factory ); delete.SetTableName( QualifiedTableName ); if( HasIdentifier ) { delete.AddWhereFragment( RowSelectColumnNames, RowSelectType, " = " ); } else { delete.AddWhereFragment( KeyColumnNames, KeyType, " = " ) .AddWhereFragment( RowSelectColumnNames, RowSelectType, " = " ); } return delete.ToSqlString(); } /// <summary> /// /// </summary> /// <returns></returns> protected override SqlString GenerateInsertRowString( ) { SqlInsertBuilder insert = new SqlInsertBuilder( factory ); insert.SetTableName( QualifiedTableName ) .AddColumn( KeyColumnNames, KeyType ); if( HasIndex ) { insert.AddColumn( IndexColumnNames, IndexType ); } if( HasIdentifier ) { insert.AddColumn( new string[ ] { IdentifierColumnName }, IdentifierType ); } insert.AddColumn( ElementColumnNames, ElementType ); return insert.ToSqlString(); } /// <summary> /// /// </summary> /// <returns></returns> protected override SqlString GenerateUpdateRowString( ) { SqlUpdateBuilder update = new SqlUpdateBuilder( factory ); update.SetTableName( QualifiedTableName ) .AddColumns( ElementColumnNames, ElementType ); if( HasIdentifier ) { update.AddWhereFragment( RowSelectColumnNames, RowSelectType, " = " ); } else { update.AddWhereFragment( KeyColumn... [truncated message content] |
From: Paul H. <pha...@us...> - 2005-03-01 16:25:25
|
Update of /cvsroot/nhibernate/nhibernate/src/NHibernate/Driver In directory sc8-pr-cvs1.sourceforge.net:/tmp/cvs-serv5548/nhibernate/src/NHibernate/Driver Modified Files: SQLiteDriver.cs Log Message: Various refactorings on the way to 2.1 querying capability Index: SQLiteDriver.cs =================================================================== RCS file: /cvsroot/nhibernate/nhibernate/src/NHibernate/Driver/SQLiteDriver.cs,v retrieving revision 1.1 retrieving revision 1.2 diff -C2 -d -r1.1 -r1.2 *** SQLiteDriver.cs 14 Feb 2005 03:58:53 -0000 1.1 --- SQLiteDriver.cs 1 Mar 2005 16:24:45 -0000 1.2 *************** *** 23,26 **** --- 23,29 ---- System.Type _commandType; + /// <summary> + /// + /// </summary> public SQLiteDriver() { *************** *** 40,43 **** --- 43,49 ---- } + /// <summary> + /// + /// </summary> public override System.Type CommandType { *************** *** 45,48 **** --- 51,57 ---- } + /// <summary> + /// + /// </summary> public override System.Type ConnectionType { *************** *** 50,53 **** --- 59,65 ---- } + /// <summary> + /// + /// </summary> public override bool UseNamedPrefixInSql { *************** *** 55,58 **** --- 67,73 ---- } + /// <summary> + /// + /// </summary> public override bool UseNamedPrefixInParameter { *************** *** 60,63 **** --- 75,81 ---- } + /// <summary> + /// + /// </summary> public override string NamedPrefix { |
Update of /cvsroot/nhibernate/NHibernateContrib/src/NHibernate.Tool.hbm2net In directory sc8-pr-cvs1.sourceforge.net:/tmp/cvs-serv5548/NHibernateContrib/src/NHibernate.Tool.hbm2net Modified Files: AbstractRenderer.cs AssemblyInfo.cs BasicRenderer.cs ClassMapping.cs ClassName.cs CodeGenerator.cs DOMRenderer.cs FieldProperty.cs FinderRenderer.cs Generator.cs JavaTool.cs MappingElement.cs MetaAttributeHelper.cs MethodSignatureBuilder.cs NHibernate.Tool.hbm2net-1.1.csproj QueryBuilder.cs Renderer.cs StringResourceLoader.cs SupportClass.cs VelocityRenderer.cs Added Files: SubclassMapping.cs Log Message: Various refactorings on the way to 2.1 querying capability Index: Renderer.cs =================================================================== RCS file: /cvsroot/nhibernate/NHibernateContrib/src/NHibernate.Tool.hbm2net/Renderer.cs,v retrieving revision 1.1 retrieving revision 1.2 diff -C2 -d -r1.1 -r1.2 *** Renderer.cs 30 Dec 2004 16:54:54 -0000 1.1 --- Renderer.cs 1 Mar 2005 16:24:39 -0000 1.2 *************** *** 24,28 **** /// @throws Exception /// </param> ! void render(String savedToPackage, String savedToClass, ClassMapping classMapping, IDictionary class2classmap, StreamWriter writer); /// <summary> Called by the generator to determine the package name of the rendered class. --- 24,28 ---- /// @throws Exception /// </param> ! void render(string savedToPackage, string savedToClass, ClassMapping classMapping, IDictionary class2classmap, StreamWriter writer); /// <summary> Called by the generator to determine the package name of the rendered class. *************** *** 33,37 **** /// <returns> the package name the class should be saved to /// </returns> ! String getSaveToPackage(ClassMapping classMapping); /// <summary> Called by the generator to determine the class name of the rendered class. --- 33,37 ---- /// <returns> the package name the class should be saved to /// </returns> ! string getSaveToPackage(ClassMapping classMapping); /// <summary> Called by the generator to determine the class name of the rendered class. *************** *** 42,46 **** /// <returns> the class name the class should be saved to /// </returns> ! String getSaveToClassName(ClassMapping classMapping); } } \ No newline at end of file --- 42,46 ---- /// <returns> the class name the class should be saved to /// </returns> ! string getSaveToClassName(ClassMapping classMapping); } } \ No newline at end of file Index: MetaAttributeHelper.cs =================================================================== RCS file: /cvsroot/nhibernate/NHibernateContrib/src/NHibernate.Tool.hbm2net/MetaAttributeHelper.cs,v retrieving revision 1.1 retrieving revision 1.2 diff -C2 -d -r1.1 -r1.2 *** MetaAttributeHelper.cs 30 Dec 2004 16:54:54 -0000 1.1 --- MetaAttributeHelper.cs 1 Mar 2005 16:24:39 -0000 1.2 *************** *** 21,28 **** internal class MetaAttribute { ! internal String value_Renamed; internal bool inheritable = true; ! internal MetaAttribute(String value_Renamed, bool inherit) { this.value_Renamed = value_Renamed; --- 21,28 ---- internal class MetaAttribute { ! internal string value_Renamed; internal bool inheritable = true; ! internal MetaAttribute(string value_Renamed, bool inherit) { this.value_Renamed = value_Renamed; *************** *** 30,34 **** } ! public override String ToString() { return value_Renamed; --- 30,34 ---- } ! public override string ToString() { return value_Renamed; *************** *** 46,50 **** SupportClass.ListCollectionSupport metaAttributeList = new SupportClass.ListCollectionSupport(); metaAttributeList.AddAll(element.SelectNodes("meta", CodeGenerator.nsmgr)); ! metaAttributeList.AddAll(element.SelectNodes("urn:meta", CodeGenerator.nsmgr)); for (IEnumerator iter = metaAttributeList.GetEnumerator(); iter.MoveNext(); ) --- 46,50 ---- SupportClass.ListCollectionSupport metaAttributeList = new SupportClass.ListCollectionSupport(); metaAttributeList.AddAll(element.SelectNodes("meta", CodeGenerator.nsmgr)); ! metaAttributeList.AddAll(element.SelectNodes("meta", CodeGenerator.nsmgr)); for (IEnumerator iter = metaAttributeList.GetEnumerator(); iter.MoveNext(); ) *************** *** 52,58 **** Element metaAttrib = (Element) iter.Current; // does not use getTextNormalize() or getTextTrim() as that would remove the formatting in new lines in items like description for javadocs. ! String attribute = (metaAttrib.Attributes["attribute"] == null?string.Empty:metaAttrib.Attributes["attribute"].Value); ! String value_Renamed = metaAttrib.InnerText; ! String inheritStr = (metaAttrib.Attributes["inherit"] == null?null:metaAttrib.Attributes["inherit"].Value); bool inherit = true; if ((Object) inheritStr != null) --- 52,58 ---- Element metaAttrib = (Element) iter.Current; // does not use getTextNormalize() or getTextTrim() as that would remove the formatting in new lines in items like description for javadocs. ! string attribute = (metaAttrib.Attributes["attribute"] == null?string.Empty:metaAttrib.Attributes["attribute"].Value); ! string value_Renamed = metaAttrib.InnerText; ! string inheritStr = (metaAttrib.Attributes["inherit"] == null?null:metaAttrib.Attributes["inherit"].Value); bool inherit = true; if ((Object) inheritStr != null) *************** *** 90,94 **** for (IEnumerator iter = new SupportClass.SetSupport(inherited.Keys).GetEnumerator(); iter.MoveNext(); ) { ! String key = (String) iter.Current; if (!local.ContainsKey(key)) --- 90,94 ---- for (IEnumerator iter = new SupportClass.SetSupport(inherited.Keys).GetEnumerator(); iter.MoveNext(); ) { ! string key = (String) iter.Current; if (!local.ContainsKey(key)) *************** *** 121,125 **** } ! public static String getMetaAsString(SupportClass.ListCollectionSupport meta, String seperator) { StringBuilder buf = new StringBuilder(); --- 121,125 ---- } ! public static string getMetaAsString(SupportClass.ListCollectionSupport meta, string seperator) { StringBuilder buf = new StringBuilder(); *************** *** 155,159 **** } ! internal static String getMetaAsString(SupportClass.ListCollectionSupport c) { if (c == null || c.IsEmpty()) --- 155,159 ---- } ! internal static string getMetaAsString(SupportClass.ListCollectionSupport c) { if (c == null || c.IsEmpty()) Index: FinderRenderer.cs =================================================================== RCS file: /cvsroot/nhibernate/NHibernateContrib/src/NHibernate.Tool.hbm2net/FinderRenderer.cs,v retrieving revision 1.1 retrieving revision 1.2 diff -C2 -d -r1.1 -r1.2 *** FinderRenderer.cs 30 Dec 2004 16:54:54 -0000 1.1 --- FinderRenderer.cs 1 Mar 2005 16:24:39 -0000 1.2 *************** *** 133,140 **** } ! private const String MT_FINDERMETHOD = "finder-method"; ! private const String MT_FOREIGNFINDERMETHOD = "foreign-finder-name"; ! private const String MT_FOREIGNFINDERFIELD = "foreign-finder-field"; ! private const String MT_FOREIGNJOINFIELD = "foreign-join-field"; --- 133,140 ---- } ! private const string MT_FINDERMETHOD = "finder-method"; ! private const string MT_FOREIGNFINDERMETHOD = "foreign-finder-name"; ! private const string MT_FOREIGNFINDERFIELD = "foreign-finder-field"; ! private const string MT_FOREIGNJOINFIELD = "foreign-join-field"; *************** *** 144,148 **** /// <exception cref=""> Exception /// </exception> ! public override void render(String savedToPackage, String savedToClass, ClassMapping classMapping, IDictionary class2classmap, StreamWriter mainwriter) { --- 144,148 ---- /// <exception cref=""> Exception /// </exception> ! public override void render(string savedToPackage, string savedToClass, ClassMapping classMapping, IDictionary class2classmap, StreamWriter mainwriter) { *************** *** 156,160 **** writer.WriteLine("/** Automatically generated Finder class for " + savedToClass + ".\n" + " * @author Hibernate FinderGenerator " + " **/"); ! String classScope = "public"; writer.Write(classScope + " class " + savedToClass); --- 156,160 ---- writer.WriteLine("/** Automatically generated Finder class for " + savedToClass + ".\n" + " * @author Hibernate FinderGenerator " + " **/"); ! string classScope = "public"; writer.Write(classScope + " class " + savedToClass); *************** *** 188,192 **** { // Find out of there is a system wide way to get sessions defined ! String sessionMethod = classMapping.getMetaAsString("session-method").Trim(); // fields --- 188,192 ---- { // Find out of there is a system wide way to get sessions defined ! string sessionMethod = classMapping.getMetaAsString("session-method").Trim(); // fields *************** *** 200,204 **** { ! String finderName = field.getMetaAsString(MT_FINDERMETHOD); if ("".Equals(sessionMethod)) --- 200,204 ---- { ! string finderName = field.getMetaAsString(MT_FINDERMETHOD); if ("".Equals(sessionMethod)) *************** *** 221,227 **** else if (field.getMeta(MT_FOREIGNFINDERMETHOD) != null) { ! String finderName = field.getMetaAsString(MT_FOREIGNFINDERMETHOD); ! String fieldName = field.getMetaAsString(MT_FOREIGNFINDERFIELD); ! String joinFieldName = field.getMetaAsString(MT_FOREIGNJOINFIELD); // Build the query --- 221,227 ---- else if (field.getMeta(MT_FOREIGNFINDERMETHOD) != null) { ! string finderName = field.getMetaAsString(MT_FOREIGNFINDERMETHOD); ! string fieldName = field.getMetaAsString(MT_FOREIGNFINDERFIELD); ! string joinFieldName = field.getMetaAsString(MT_FOREIGNJOINFIELD); // Build the query *************** *** 353,357 **** /// <returns> /// </returns> ! public static String getFieldAsObject(bool prependThis, FieldProperty field) { ClassName type = field.ClassType; --- 353,357 ---- /// <returns> /// </returns> ! public static string getFieldAsObject(bool prependThis, FieldProperty field) { ClassName type = field.ClassType; *************** *** 359,363 **** { //UPGRADE_TODO: Method 'java.util.Map.get' was converted to 'System.Collections.IDictionary.Item' which has a different behavior. 'ms-help://MS.VSCC.2003/commoner/redir/redirect.htm?keyword="jlca1073_javautilMapget_javalangObject"' ! String typeName = (String) primitiveToObject[type.Name]; typeName = "new " + typeName + "( "; typeName += (prependThis?"this.":""); --- 359,363 ---- { //UPGRADE_TODO: Method 'java.util.Map.get' was converted to 'System.Collections.IDictionary.Item' which has a different behavior. 'ms-help://MS.VSCC.2003/commoner/redir/redirect.htm?keyword="jlca1073_javautilMapget_javalangObject"' ! string typeName = (String) primitiveToObject[type.Name]; typeName = "new " + typeName + "( "; typeName += (prependThis?"this.":""); *************** *** 381,390 **** /// <returns> /// </returns> ! public static String getFieldAsHibernateType(bool prependThis, FieldProperty field) { ClassName type = field.ClassType; //UPGRADE_TODO: Method 'java.util.Map.get' was converted to 'System.Collections.IDictionary.Item' which has a different behavior. 'ms-help://MS.VSCC.2003/commoner/redir/redirect.htm?keyword="jlca1073_javautilMapget_javalangObject"' ! String hibTypeString = (String) hibType[type.Name]; ! if ((Object) hibTypeString != null) { return hibTypeString; --- 381,390 ---- /// <returns> /// </returns> ! public static string getFieldAsHibernateType(bool prependThis, FieldProperty field) { ClassName type = field.ClassType; //UPGRADE_TODO: Method 'java.util.Map.get' was converted to 'System.Collections.IDictionary.Item' which has a different behavior. 'ms-help://MS.VSCC.2003/commoner/redir/redirect.htm?keyword="jlca1073_javautilMapget_javalangObject"' ! string hibTypeString = (String) hibType[type.Name]; ! if ((object) hibTypeString != null) { return hibTypeString; Index: ClassName.cs =================================================================== RCS file: /cvsroot/nhibernate/NHibernateContrib/src/NHibernate.Tool.hbm2net/ClassName.cs,v retrieving revision 1.1 retrieving revision 1.2 diff -C2 -d -r1.1 -r1.2 *** ClassName.cs 30 Dec 2004 16:54:54 -0000 1.1 --- ClassName.cs 1 Mar 2005 16:24:39 -0000 1.2 *************** *** 15,19 **** public class ClassName { ! virtual public String FullyQualifiedName { get --- 15,19 ---- public class ClassName { ! virtual public string FullyQualifiedName { get *************** *** 27,31 **** /// java.util.Set -> "Set" /// </summary> ! virtual public String Name { get --- 27,31 ---- /// java.util.Set -> "Set" /// </summary> ! virtual public string Name { get *************** *** 41,45 **** /// <returns> /// </returns> ! virtual public String PackageName { get --- 41,45 ---- /// <returns> /// </returns> ! virtual public string PackageName { get *************** *** 65,69 **** get { ! String baseTypeName = StringHelper.Replace(fullyQualifiedName, "[]", ""); return PRIMITIVES.Contains(baseTypeName); } --- 65,69 ---- get { ! string baseTypeName = StringHelper.Replace(fullyQualifiedName, "[]", ""); return PRIMITIVES.Contains(baseTypeName); } *************** *** 73,84 **** internal static readonly SupportClass.SetSupport PRIMITIVES = new SupportClass.HashSetSupport(); ! public ClassName(String fqn) { initFullyQualifiedName(fqn); } ! private String fullyQualifiedName = null; ! private String name = null; ! private String packageName = null; /// <summary>Two ClassName are equals if their fullyQualifiedName are the same/equals! </summary> --- 73,84 ---- internal static readonly SupportClass.SetSupport PRIMITIVES = new SupportClass.HashSetSupport(); ! public ClassName(string fqn) { initFullyQualifiedName(fqn); } ! private string fullyQualifiedName = null; ! private string name = null; ! private string packageName = null; /// <summary>Two ClassName are equals if their fullyQualifiedName are the same/equals! </summary> *************** *** 101,105 **** public virtual bool inSamePackage(ClassName other) { ! return (Object) other.packageName == (Object) this.packageName || ((Object) other.packageName != null && other.packageName.Equals(this.packageName)); } --- 101,105 ---- public virtual bool inSamePackage(ClassName other) { ! return (object) other.packageName == (Object) this.packageName || ((Object) other.packageName != null && other.packageName.Equals(this.packageName)); } *************** *** 108,112 **** * Initialize the class fields with info from a fully qualified name. */ ! private void initFullyQualifiedName(String fqn) { this.fullyQualifiedName = fqn; --- 108,112 ---- * Initialize the class fields with info from a fully qualified name. */ ! private void initFullyQualifiedName(string fqn) { this.fullyQualifiedName = fqn; *************** *** 117,122 **** if ((Object) fqn != null) { ! ! int lastDot = fqn.LastIndexOf(","); if (lastDot < 0) { --- 117,121 ---- if ((Object) fqn != null) { ! int lastDot = fqn.LastIndexOf("."); if (lastDot < 0) { *************** *** 126,132 **** else { ! packageName = fqn.Substring(0, (lastDot) - (0)); ! name = packageName.Substring(packageName.LastIndexOf(".") + 1); ! packageName = packageName.Substring(0, (packageName.LastIndexOf(".")) - (0)); } } --- 125,130 ---- else { ! name = fqn.Substring( lastDot + 1 ); ! packageName = fqn.Substring(0, lastDot); } } *************** *** 144,148 **** } ! public override String ToString() { return FullyQualifiedName; --- 142,146 ---- } ! public override string ToString() { return FullyQualifiedName; Index: CodeGenerator.cs =================================================================== RCS file: /cvsroot/nhibernate/NHibernateContrib/src/NHibernate.Tool.hbm2net/CodeGenerator.cs,v retrieving revision 1.1 retrieving revision 1.2 diff -C2 -d -r1.1 -r1.2 *** CodeGenerator.cs 30 Dec 2004 16:54:54 -0000 1.1 --- CodeGenerator.cs 1 Mar 2005 16:24:39 -0000 1.2 *************** *** 22,25 **** --- 22,28 ---- internal static XmlNamespaceManager nsmgr; + private static ArrayList children; + private static MultiMap allMaps; + [STAThread] public static void Main(String[] args) *************** *** 28,31 **** --- 31,37 ---- nsmgr.AddNamespace("urn", "urn:nhibernate-mapping-2.0"); + children = new ArrayList(); + allMaps = new MultiMap(); + File.Delete("error-log.txt"); DOMConfigurator.Configure(new FileInfo("NHibernate.Tool.hbm2net.exe.config")); *************** *** 40,44 **** ArrayList mappingFiles = new ArrayList(); ! String outputDir = null; SupportClass.ListCollectionSupport generators = new SupportClass.ListCollectionSupport(); --- 46,50 ---- ArrayList mappingFiles = new ArrayList(); ! string outputDir = null; SupportClass.ListCollectionSupport generators = new SupportClass.ListCollectionSupport(); *************** *** 69,72 **** --- 75,83 ---- } } + else if ( args[i].IndexOf("*") > -1 ) + { + // Handle wildcards + mappingFiles.AddRange( GetFiles( args[ i ] ) ); + } else { *************** *** 99,103 **** XmlAttribute a = rootElement.Attributes["package"]; ! String pkg = null; if (a != null) { --- 110,114 ---- XmlAttribute a = rootElement.Attributes["package"]; ! string pkg = null; if (a != null) { *************** *** 105,116 **** } MappingElement me = new MappingElement(rootElement, null); ! IEnumerator classElements = rootElement.SelectNodes("urn:class", nsmgr).GetEnumerator(); MultiMap mm = MetaAttributeHelper.loadAndMergeMetaMap(rootElement, globalMetas); handleClass(pkg, me, classMappings, classElements, mm, false); ! classElements = rootElement.SelectNodes("urn:subclass", nsmgr).GetEnumerator(); handleClass(pkg, me, classMappings, classElements, mm, true); ! classElements = rootElement.SelectNodes("urn:joined-subclass", nsmgr).GetEnumerator(); handleClass(pkg, me, classMappings, classElements, mm, true); } --- 116,127 ---- } MappingElement me = new MappingElement(rootElement, null); ! IEnumerator classElements = rootElement.SelectNodes("class", nsmgr).GetEnumerator(); MultiMap mm = MetaAttributeHelper.loadAndMergeMetaMap(rootElement, globalMetas); handleClass(pkg, me, classMappings, classElements, mm, false); ! classElements = rootElement.SelectNodes("subclass", nsmgr).GetEnumerator(); handleClass(pkg, me, classMappings, classElements, mm, true); ! classElements = rootElement.SelectNodes("joined-subclass", nsmgr).GetEnumerator(); handleClass(pkg, me, classMappings, classElements, mm, true); } *************** *** 120,123 **** --- 131,138 ---- } } + + // Ok, pickup subclasses that we found before their superclasses + ProcessChildren( classMappings ); + // generate source files for (IEnumerator iterator = generators.GetEnumerator(); iterator.MoveNext(); ) *************** *** 134,138 **** } ! private static void handleClass(String classPackage, MappingElement me, Hashtable classMappings, IEnumerator classElements, MultiMap mm, bool extendz) { while (classElements.MoveNext()) --- 149,172 ---- } ! private static ICollection GetFiles( string fileSpec ) ! { ! int posn = fileSpec.LastIndexOf( '\\' ); ! string path = fileSpec.Substring( 0, posn ); ! string names = fileSpec.Substring( posn + 1 ); ! DirectoryInfo di = new DirectoryInfo( path ); ! ! FileInfo[] files = di.GetFiles( names ); ! ! ArrayList fileNames = new ArrayList( files.Length ); ! ! foreach ( FileInfo file in files ) ! { ! fileNames.Add( file.FullName ); ! } ! ! return fileNames; ! } ! ! private static void handleClass(string classPackage, MappingElement me, Hashtable classMappings, IEnumerator classElements, MultiMap mm, bool extendz) { while (classElements.MoveNext()) *************** *** 144,165 **** ClassMapping cmap = new ClassMapping(classPackage, clazz, me, mm); SupportClass.PutElement(classMappings, cmap.FullyQualifiedName, cmap); } else { ! String ex = (clazz.Attributes["extends"] == null?null:clazz.Attributes["extends"].Value); ! if ((Object) ex == null) { throw new MappingException("Missing extends attribute on <" + clazz.LocalName + " name=" + clazz.Attributes["name"].Value + ">"); } ! ClassMapping superclass = (ClassMapping) classMappings[ex]; if (superclass == null) { ! throw new MappingException("Cannot extend unmapped class " + ex); } ! ClassMapping subclassMapping = new ClassMapping(classPackage, me, superclass.ClassName, superclass, clazz, mm); ! superclass.addSubClass(subclassMapping); } } } } } \ No newline at end of file --- 178,259 ---- ClassMapping cmap = new ClassMapping(classPackage, clazz, me, mm); SupportClass.PutElement(classMappings, cmap.FullyQualifiedName, cmap); + SupportClass.PutElement(allMaps, cmap.FullyQualifiedName, cmap); } else { ! string ex = clazz.Attributes["extends"] == null ? null : clazz.Attributes["extends"].Value; ! if ((object) ex == null) { throw new MappingException("Missing extends attribute on <" + clazz.LocalName + " name=" + clazz.Attributes["name"].Value + ">"); } ! ClassMapping superclass = (ClassMapping) allMaps[ex]; if (superclass == null) { ! // Haven't seen the superclass yet, so record this and process at the end ! SubclassMapping orphan = new SubclassMapping(classPackage, me, ex, clazz, mm); ! children.Add( orphan ); } ! else ! { ! ClassMapping subclassMapping = new ClassMapping(classPackage, me, superclass.ClassName, superclass, clazz, mm); ! superclass.addSubClass(subclassMapping); ! SupportClass.PutElement(allMaps, subclassMapping.FullyQualifiedName, subclassMapping); ! } ! } ! } ! } ! ! /// <summary> ! /// Try to locate superclasses for any orphans we have ! /// </summary> ! private static void ProcessChildren( Hashtable classMappings ) ! { ! while ( FindParents( classMappings ) ) { } ! ! foreach( SubclassMapping child in children ) ! { ! if ( child.Orphaned ) ! { ! // Log that we had an orphan ! log.Warn( string.Format( "Cannot extend {0} child of unmapped class {1} ", child.Name, child.SuperClass ) ); } } } + + /// <summary> + /// Find parents for any orphans + /// </summary> + /// <returns></returns> + private static bool FindParents( Hashtable classMappings ) + { + if ( children.Count == 0 ) + { + // No parents to find + return false; + } + else + { + bool found = false; + + foreach( SubclassMapping child in children ) + { + if ( child.Orphaned ) + { + ClassMapping superclass = (ClassMapping) allMaps[ child.SuperClass ]; + if (superclass != null) + { + ClassMapping subclassMapping = new ClassMapping(child.ClassPackage, child.MappingElement, superclass.ClassName, superclass, child.Clazz, child.MultiMap); + superclass.addSubClass(subclassMapping); + // NB Can't remove it from the iterator, so record that we've found the parent. + child.Orphaned = false; + found = true; + } + } + } + + // Tell them if we found any + return found; + } + } } } \ No newline at end of file Index: NHibernate.Tool.hbm2net-1.1.csproj =================================================================== RCS file: /cvsroot/nhibernate/NHibernateContrib/src/NHibernate.Tool.hbm2net/NHibernate.Tool.hbm2net-1.1.csproj,v retrieving revision 1.1 retrieving revision 1.2 diff -C2 -d -r1.1 -r1.2 *** NHibernate.Tool.hbm2net-1.1.csproj 30 Dec 2004 16:54:54 -0000 1.1 --- NHibernate.Tool.hbm2net-1.1.csproj 1 Mar 2005 16:24:39 -0000 1.2 *************** *** 207,210 **** --- 207,215 ---- /> <File + RelPath = "SubclassMapping.cs" + SubType = "Code" + BuildAction = "Compile" + /> + <File RelPath = "SupportClass.cs" SubType = "Code" Index: Generator.cs =================================================================== RCS file: /cvsroot/nhibernate/NHibernateContrib/src/NHibernate.Tool.hbm2net/Generator.cs,v retrieving revision 1.1 retrieving revision 1.2 diff -C2 -d -r1.1 -r1.2 *** Generator.cs 30 Dec 2004 16:54:54 -0000 1.1 --- Generator.cs 1 Mar 2005 16:24:39 -0000 1.2 *************** *** 14,18 **** { private static readonly ILog log = LogManager.GetLogger(MethodBase.GetCurrentMethod().DeclaringType); ! private void InitBlock() { --- 14,18 ---- { private static readonly ILog log = LogManager.GetLogger(MethodBase.GetCurrentMethod().DeclaringType); ! private void InitBlock() { *************** *** 20,24 **** prefix = string.Empty; } ! virtual public String BaseDirName { get --- 20,24 ---- prefix = string.Empty; } ! virtual public string BaseDirName { get *************** *** 37,46 **** } ! private String rendererClass = "NHibernate.Tool.hbm2net.VelocityRenderer"; ! private String baseDirName = "generated"; ! private String packageName = null; ! private String suffix; ! private String prefix; ! private String extension = "cs"; private bool lowerFirstLetter = false; --- 37,46 ---- } ! private string rendererClass = "NHibernate.Tool.hbm2net.VelocityRenderer"; ! private string baseDirName = "generated"; ! private string packageName = null; ! private string suffix; ! private string prefix; ! private string extension = "cs"; private bool lowerFirstLetter = false; *************** *** 57,61 **** { InitBlock(); ! String value_Renamed = null; // set rendererClass field --- 57,61 ---- { InitBlock(); ! string value_Renamed = null; // set rendererClass field *************** *** 150,155 **** private void write(ClassMapping classMapping, IDictionary class2classmap, Renderer renderer) { ! String saveToPackage = renderer.getSaveToPackage(classMapping); ! String saveToClassName = renderer.getSaveToClassName(classMapping); FileInfo dir = this.getDir(saveToPackage); FileInfo file = new FileInfo(dir.FullName + "\\" + this.getFileName(saveToClassName)); --- 150,155 ---- private void write(ClassMapping classMapping, IDictionary class2classmap, Renderer renderer) { ! string saveToPackage = renderer.getSaveToPackage(classMapping); ! string saveToClassName = renderer.getSaveToClassName(classMapping); FileInfo dir = this.getDir(saveToPackage); FileInfo file = new FileInfo(dir.FullName + "\\" + this.getFileName(saveToClassName)); *************** *** 163,167 **** /// <summary> </summary> ! private String getFileName(String className) { return this.getName(className) + "." + this.extension; --- 163,167 ---- /// <summary> </summary> ! private string getFileName(string className) { return this.getName(className) + "." + this.extension; *************** *** 169,175 **** /// <summary> </summary> ! private String getName(String className) { ! String name = null; if (this.lowerFirstLetter) --- 169,175 ---- /// <summary> </summary> ! private string getName(string className) { ! string name = null; if (this.lowerFirstLetter) *************** *** 185,189 **** } ! private String getPackageName(String packageName) { if ((Object) this.packageName == null) --- 185,189 ---- } ! private string getPackageName(string packageName) { if ((Object) this.packageName == null) *************** *** 197,206 **** } /// <summary> </summary> ! private FileInfo getDir(String packageName) { FileInfo baseDir = new FileInfo(this.baseDirName); FileInfo dir = null; ! String p = getPackageName(packageName); dir = new FileInfo(baseDir.FullName + "\\" + p.Replace(StringHelper.Dot, Path.DirectorySeparatorChar)); --- 197,206 ---- } /// <summary> </summary> ! private FileInfo getDir(string packageName) { FileInfo baseDir = new FileInfo(this.baseDirName); FileInfo dir = null; ! string p = getPackageName(packageName); dir = new FileInfo(baseDir.FullName + "\\" + p.Replace(StringHelper.Dot, Path.DirectorySeparatorChar)); Index: BasicRenderer.cs =================================================================== RCS file: /cvsroot/nhibernate/NHibernateContrib/src/NHibernate.Tool.hbm2net/BasicRenderer.cs,v retrieving revision 1.1 retrieving revision 1.2 diff -C2 -d -r1.1 -r1.2 *** BasicRenderer.cs 30 Dec 2004 16:54:54 -0000 1.1 --- BasicRenderer.cs 1 Mar 2005 16:24:39 -0000 1.2 *************** *** 32,36 **** internal JavaTool javaTool; ! public override void render(System.String savedToPackage, System.String savedToClass, ClassMapping classMapping, System.Collections.IDictionary class2classmap, System.IO.StreamWriter mainwriter) { mainwriter.WriteLine("using System;"); --- 32,36 ---- internal JavaTool javaTool; ! public override void render(string savedToPackage, string savedToClass, ClassMapping classMapping, System.Collections.IDictionary class2classmap, System.IO.StreamWriter mainwriter) { mainwriter.WriteLine("using System;"); *************** *** 69,78 **** } ! System.String classScope = classMapping.Scope; ! System.String declarationType = classMapping.DeclarationType; //classMapping.addImport(typeof(System.Runtime.Serialization.ISerializable)); ! //String modifiers = classMapping.getModifiers(); if (classMapping.shouldBeAbstract() && (classScope.IndexOf("abstract") == - 1)) { --- 69,78 ---- } ! string classScope = classMapping.Scope; ! string declarationType = classMapping.DeclarationType; //classMapping.addImport(typeof(System.Runtime.Serialization.ISerializable)); ! //string modifiers = classMapping.getModifiers(); if (classMapping.shouldBeAbstract() && (classScope.IndexOf("abstract") == - 1)) { *************** *** 116,121 **** } ! System.String vetoSupport = makeSupportField("vetos", classMapping.AllFields); ! System.String changeSupport = makeSupportField("changes", classMapping.AllFields); int fieldTypes = doFieldAccessors(classMapping, class2classmap, propWriter, vetoSupport, changeSupport); --- 116,121 ---- } ! string vetoSupport = makeSupportField("vetos", classMapping.AllFields); ! string changeSupport = makeSupportField("changes", classMapping.AllFields); int fieldTypes = doFieldAccessors(classMapping, class2classmap, propWriter, vetoSupport, changeSupport); *************** *** 135,139 **** while (iter.MoveNext()) { ! System.String code = iter.Current.ToString(); propWriter.WriteLine(code); } --- 135,139 ---- while (iter.MoveNext()) { ! string code = iter.Current.ToString(); propWriter.WriteLine(code); } *************** *** 163,167 **** /// <param name="vetoSupport"></param> /// <param name="writer"></param> ! private void doSupportMethods(int fieldTypes, System.String vetoSupport, System.String changeSupport, System.IO.StringWriter writer) { if ((fieldTypes & CONSTRAINT) == CONSTRAINT) --- 163,167 ---- /// <param name="vetoSupport"></param> /// <param name="writer"></param> ! private void doSupportMethods(int fieldTypes, string vetoSupport, string changeSupport, System.IO.StringWriter writer) { if ((fieldTypes & CONSTRAINT) == CONSTRAINT) *************** *** 195,199 **** /// <param name="writer"> /// </param> ! private void doSupports(int fieldTypes, ClassMapping classMapping, System.String vetoSupport, System.String changeSupport, System.IO.StringWriter writer) { if ((fieldTypes & CONSTRAINT) == CONSTRAINT) --- 195,199 ---- /// <param name="writer"> /// </param> ! private void doSupports(int fieldTypes, ClassMapping classMapping, string vetoSupport, string changeSupport, System.IO.StringWriter writer) { if ((fieldTypes & CONSTRAINT) == CONSTRAINT) *************** *** 210,214 **** ! public virtual void doConstructors(System.String savedToClass, ClassMapping classMapping, System.Collections.IDictionary class2classmap, System.IO.StringWriter writer) { // full constructor --- 210,214 ---- ! public virtual void doConstructors(string savedToClass, ClassMapping classMapping, System.Collections.IDictionary class2classmap, System.IO.StringWriter writer) { // full constructor *************** *** 216,220 **** writer.WriteLine(" /// <summary>\n /// full constructor\n /// </summary>"); ! System.String fullCons = " public " + savedToClass + StringHelper.OpenParen; fullCons += javaTool.fieldsAsParameters(allFieldsForFullConstructor, classMapping, class2classmap); --- 216,220 ---- writer.WriteLine(" /// <summary>\n /// full constructor\n /// </summary>"); ! string fullCons = " public " + savedToClass + StringHelper.OpenParen; fullCons += javaTool.fieldsAsParameters(allFieldsForFullConstructor, classMapping, class2classmap); *************** *** 270,274 **** writer.WriteLine(" /// <summary>\n /// minimal constructor\n /// </summary>"); ! System.String minCons = " public " + savedToClass + "("; bool first = true; for (System.Collections.IEnumerator fields = allFieldsForMinimalConstructor.GetEnumerator(); fields.MoveNext(); ) --- 270,274 ---- writer.WriteLine(" /// <summary>\n /// minimal constructor\n /// </summary>"); ! string minCons = " public " + savedToClass + "("; bool first = true; for (System.Collections.IEnumerator fields = allFieldsForMinimalConstructor.GetEnumerator(); fields.MoveNext(); ) *************** *** 342,346 **** if (field.GeneratedAsProperty) { ! System.String fieldScope = getFieldScope(field, "scope-field", "private"); writer.WriteLine(" /// <summary>\n /// Holder for " + (field.Nullable && !field.Identifier?"nullable ":string.Empty) + (field.Identifier?"identifier":"persistent") + " field " + field.FieldName + "\n /// </summary>"); --- 342,346 ---- if (field.GeneratedAsProperty) { ! string fieldScope = getFieldScope(field, "scope-field", "private"); writer.WriteLine(" /// <summary>\n /// Holder for " + (field.Nullable && !field.Identifier?"nullable ":string.Empty) + (field.Identifier?"identifier":"persistent") + " field " + field.FieldName + "\n /// </summary>"); *************** *** 357,361 **** } ! public virtual void doEqualsAndHashCode(System.String savedToClass, ClassMapping classMapping, System.IO.StringWriter writer) { if (classMapping.mustImplementEquals()) --- 357,361 ---- } ! public virtual void doEqualsAndHashCode(string savedToClass, ClassMapping classMapping, System.IO.StringWriter writer) { if (classMapping.mustImplementEquals()) *************** *** 449,453 **** internal static System.Collections.IDictionary primitiveToObject; ! public virtual int doFieldAccessors(ClassMapping classMapping, System.Collections.IDictionary class2classmap, System.IO.StringWriter writer, System.String vetoSupport, System.String changeSupport) { int fieldTypes = ORDINARY; --- 449,453 ---- internal static System.Collections.IDictionary primitiveToObject; ! public virtual int doFieldAccessors(ClassMapping classMapping, System.Collections.IDictionary class2classmap, System.IO.StringWriter writer, string vetoSupport, string changeSupport) { int fieldTypes = ORDINARY; *************** *** 462,466 **** } ! private int doFields(ClassMapping classMapping, System.Collections.IDictionary class2classmap, System.IO.StringWriter writer, System.String vetoSupport, System.String changeSupport, int fieldTypes, SupportClass.ListCollectionSupport fieldz) { // field accessors --- 462,466 ---- } ! private int doFields(ClassMapping classMapping, System.Collections.IDictionary class2classmap, System.IO.StringWriter writer, string vetoSupport, string changeSupport, int fieldTypes, SupportClass.ListCollectionSupport fieldz) { // field accessors *************** *** 472,476 **** // getter ! System.String getAccessScope = getFieldScope(field, "scope-get", "public"); --- 472,476 ---- // getter ! string getAccessScope = getFieldScope(field, "scope-get", "public"); *************** *** 499,503 **** if (field.getMeta("beans-property-type") != null) { ! System.String beansPropertyType = field.getMetaAsString("beans-property-type").Trim().ToLower(); if (beansPropertyType.Equals("constraint")) { --- 499,503 ---- if (field.getMeta("beans-property-type") != null) { ! string beansPropertyType = field.getMetaAsString("beans-property-type").Trim().ToLower(); if (beansPropertyType.Equals("constraint")) { *************** *** 511,515 **** } } ! System.String setAccessScope = getFieldScope(field, "scope-set", "public"); writer.Write(" set"); writer.Write((fieldType & CONSTRAINT) == CONSTRAINT?" throws PropertyVetoException ":""); --- 511,515 ---- } } ! string setAccessScope = getFieldScope(field, "scope-set", "public"); writer.Write(" set"); writer.Write((fieldType & CONSTRAINT) == CONSTRAINT?" throws PropertyVetoException ":""); *************** *** 524,528 **** if ((fieldType & CONSTRAINT) == CONSTRAINT || (fieldType & BOUND) == BOUND) { ! writer.WriteLine(" Object oldValue = " + getFieldAsObject(true, field) + ";"); } if ((fieldType & CONSTRAINT) == CONSTRAINT) --- 524,528 ---- if ((fieldType & CONSTRAINT) == CONSTRAINT || (fieldType & BOUND) == BOUND) { ! writer.WriteLine(" object oldValue = " + getFieldAsObject(true, field) + ";"); } if ((fieldType & CONSTRAINT) == CONSTRAINT) *************** *** 551,555 **** ClassName foreignClass = field.getForeignClass(); ! String trueforeign = getTrueTypeName(foreignClass, class2classmap); classMapping.addImport(trueforeign); --- 551,555 ---- ClassName foreignClass = field.getForeignClass(); ! string trueforeign = getTrueTypeName(foreignClass, class2classmap); classMapping.addImport(trueforeign); *************** *** 570,574 **** } ! String addAccessScope = getFieldScope(field, "scope", "scope-add"); writer.println(" " + setAccessScope + " void add" + field.getAsSuffix() + StringHelper.OPEN + shortenType(trueforeign, classMapping.getImports()) + " a" + field.getName() + ") {"); writer.println(" this." + getterType + field.getAsSuffix() + "().add(a" + field.getName() + ");"); --- 570,574 ---- } ! string addAccessScope = getFieldScope(field, "scope", "scope-add"); writer.println(" " + setAccessScope + " void add" + field.getAsSuffix() + StringHelper.OPEN + shortenType(trueforeign, classMapping.getImports()) + " a" + field.getName() + ") {"); writer.println(" this." + getterType + field.getAsSuffix() + "().add(a" + field.getName() + ");"); *************** *** 591,601 **** } ! protected internal virtual System.String makeSupportField(System.String fieldName, SupportClass.ListCollectionSupport fieldList) { ! System.String suffix = ""; bool needSuffix = false; for (System.Collections.IEnumerator fields = fieldList.GetEnumerator(); fields.MoveNext(); ) { ! System.String name = ((FieldProperty) fields.Current).FieldName; if (name.Equals(fieldName)) needSuffix = true; --- 591,601 ---- } ! protected internal virtual string makeSupportField(string fieldName, SupportClass.ListCollectionSupport fieldList) { ! string suffix = ""; bool needSuffix = false; for (System.Collections.IEnumerator fields = fieldList.GetEnumerator(); fields.MoveNext(); ) { ! string name = ((FieldProperty) fields.Current).FieldName; if (name.Equals(fieldName)) needSuffix = true; *************** *** 605,614 **** } ! private System.String getFieldAsObject(bool prependThis, FieldProperty field) { ClassName type = field.ClassType; if (type != null && type.Primitive && !type.Array) { ! System.String typeName = (System.String) primitiveToObject[type.Name]; typeName = "new " + typeName + "( "; typeName += (prependThis?"this.":""); --- 605,614 ---- } ! private string getFieldAsObject(bool prependThis, FieldProperty field) { ClassName type = field.ClassType; if (type != null && type.Primitive && !type.Array) { ! string typeName = (System.String) primitiveToObject[type.Name]; typeName = "new " + typeName + "( "; typeName += (prependThis?"this.":""); Index: DOMRenderer.cs =================================================================== RCS file: /cvsroot/nhibernate/NHibernateContrib/src/NHibernate.Tool.hbm2net/DOMRenderer.cs,v retrieving revision 1.1 retrieving revision 1.2 diff -C2 -d -r1.1 -r1.2 *** DOMRenderer.cs 30 Dec 2004 16:54:54 -0000 1.1 --- DOMRenderer.cs 1 Mar 2005 16:24:39 -0000 1.2 *************** *** 10,14 **** public class DOMRenderer : AbstractRenderer { ! public override void render(String savedToPackage, String savedToClass, ClassMapping classMapping, IDictionary class2classmap, StreamWriter writer) { } --- 10,14 ---- public class DOMRenderer : AbstractRenderer { ! public override void render(string savedToPackage, string savedToClass, ClassMapping classMapping, IDictionary class2classmap, StreamWriter writer) { } Index: FieldProperty.cs =================================================================== RCS file: /cvsroot/nhibernate/NHibernateContrib/src/NHibernate.Tool.hbm2net/FieldProperty.cs,v retrieving revision 1.1 retrieving revision 1.2 diff -C2 -d -r1.1 -r1.2 *** FieldProperty.cs 30 Dec 2004 16:54:54 -0000 1.1 --- FieldProperty.cs 1 Mar 2005 16:24:39 -0000 1.2 *************** *** 7,12 **** namespace NHibernate.Tool.hbm2net { - - public class FieldProperty:MappingElement { --- 7,10 ---- *************** *** 29,33 **** } } ! virtual public String FieldName { get --- 27,31 ---- } } ! virtual public string FieldName { get *************** *** 37,41 **** } ! virtual public String AccessorName { get --- 35,39 ---- } ! virtual public string AccessorName { get *************** *** 45,57 **** } ! private String GetterType { get { ! return (FullyQualifiedTypeName.Equals("boolean"))?"is":"get"; } } ! virtual public String FullyQualifiedTypeName { get --- 43,55 ---- } ! private string GetterType { get { ! return (FullyQualifiedTypeName.Equals("boolean")) ? "is" : "get"; } } ! virtual public string FullyQualifiedTypeName { get *************** *** 135,139 **** /// <returns> String /// </returns> ! virtual public String GetterSignature { get --- 133,137 ---- /// <returns> String /// </returns> ! virtual public string GetterSignature { get *************** *** 172,176 **** } ! virtual public String FieldScope { get --- 170,174 ---- } ! virtual public string FieldScope { get *************** *** 180,184 **** } ! virtual public String PropertyGetScope { get --- 178,182 ---- } ! virtual public string PropertyGetScope { get *************** *** 188,192 **** } ! virtual public String PropertySetScope { get --- 186,190 ---- } ! virtual public string PropertySetScope { get *************** *** 198,205 **** /// <summary>the field name </summary> ! private String fieldName = null; /// <summary>the property name </summary> ! private String accessorName = null; /// <summary>true if this is part of an id </summary> --- 196,203 ---- /// <summary>the field name </summary> ! private string fieldName = null; /// <summary>the property name </summary> ! private string accessorName = null; /// <summary>true if this is part of an id </summary> *************** *** 215,236 **** private ClassName implementationClassName; ! private ClassMapping parentClass; ! public FieldProperty(Element element, MappingElement parent, String name, ClassName type, bool nullable, MultiMap metaattribs):base(element, parent) { initWith(name, type, type, nullable, id, false, null, null, metaattribs); } ! public FieldProperty(Element element, MappingElement parent, String name, ClassName type, bool nullable, bool id, bool generated, MultiMap metaattribs):base(element, parent) { initWith(name, type, type, nullable, id, generated, null, null, metaattribs); } ! public FieldProperty(Element element, MappingElement parent, String name, ClassName type, ClassName implementationClassName, bool nullable, ClassName foreignClass, SupportClass.SetSupport foreignKeys, MultiMap metaattribs):base(element, parent) { initWith(name, type, implementationClassName, nullable, id, false, foreignClass, foreignKeys, metaattribs); } ! protected internal virtual void initWith(String name, ClassName type, ClassName implementationClassName, bool nullable, bool id, bool generated, ClassName foreignClass, SupportClass.SetSupport foreignKeys, MultiMap metaattribs) { this.fieldName = name; --- 213,234 ---- private ClassName implementationClassName; ! private ClassMapping parentClass = null; ! public FieldProperty(Element element, MappingElement parent, string name, ClassName type, bool nullable, MultiMap metaattribs):base(element, parent) { initWith(name, type, type, nullable, id, false, null, null, metaattribs); } ! public FieldProperty(Element element, MappingElement parent, string name, ClassName type, bool nullable, bool id, bool generated, MultiMap metaattribs):base(element, parent) { initWith(name, type, type, nullable, id, generated, null, null, metaattribs); } ! public FieldProperty(Element element, MappingElement parent, string name, ClassName type, ClassName implementationClassName, bool nullable, ClassName foreignClass, SupportClass.SetSupport foreignKeys, MultiMap metaattribs):base(element, parent) { initWith(name, type, implementationClassName, nullable, id, false, foreignClass, foreignKeys, metaattribs); } ! protected internal virtual void initWith(string name, ClassName type, ClassName implementationClassName, bool nullable, bool id, bool generated, ClassName foreignClass, SupportClass.SetSupport foreignKeys, MultiMap metaattribs) { this.fieldName = name; *************** *** 254,258 **** /// <returns> /// </returns> ! private String beancapitalize(String fieldname) { if ((Object) fieldname == null || fieldname.Length == 0) --- 252,256 ---- /// <returns> /// </returns> ! private string beancapitalize(string fieldname) { if ((Object) fieldname == null || fieldname.Length == 0) *************** *** 270,279 **** } ! public override String ToString() { return FullyQualifiedTypeName + ":" + FieldName; } ! public virtual String getScope(String localScopeName, String defaultScope) { if ((Object) defaultScope == null) --- 268,277 ---- } ! public override string ToString() { return FullyQualifiedTypeName + ":" + FieldName; } ! public virtual string getScope(string localScopeName, string defaultScope) { if ((Object) defaultScope == null) Index: ClassMapping.cs =================================================================== RCS file: /cvsroot/nhibernate/NHibernateContrib/src/NHibernate.Tool.hbm2net/ClassMapping.cs,v retrieving revision 1.1 retrieving revision 1.2 diff -C2 -d -r1.1 -r1.2 *** ClassMapping.cs 30 Dec 2004 16:54:54 -0000 1.1 --- ClassMapping.cs 1 Mar 2005 16:24:39 -0000 1.2 *************** *** 15,31 **** namespace NHibernate.Tool.hbm2net { - - public class ClassMapping:MappingElement { private static readonly ILog log = LogManager.GetLogger(MethodBase.GetCurrentMethod().DeclaringType); ! private void InitBlock() { [...1237 lines suppressed...] ! public override String ToString() { return "ClassMapping: " + name.FullyQualifiedName; --- 1021,1025 ---- } ! public override string ToString() { return "ClassMapping: " + name.FullyQualifiedName; *************** *** 990,996 **** addImport(clazz.FullName); } - static ClassMapping() - { - } } } \ No newline at end of file --- 1035,1038 ---- Index: QueryBuilder.cs =================================================================== RCS file: /cvsroot/nhibernate/NHibernateContrib/src/NHibernate.Tool.hbm2net/QueryBuilder.cs,v retrieving revision 1.1 retrieving revision 1.2 diff -C2 -d -r1.1 -r1.2 *** QueryBuilder.cs 30 Dec 2004 16:54:54 -0000 1.1 --- QueryBuilder.cs 1 Mar 2005 16:24:39 -0000 1.2 *************** *** 34,38 **** /// <returns> The query in string form /// </returns> ! virtual public String Query { get --- 34,38 ---- /// <returns> The query in string form /// </returns> ! virtual public string Query { get *************** *** 69,73 **** for (int i = 0; i < criteria.Count; i++) { ! String thisCriteria = (String) criteria[i]; sb.Append(" " + thisCriteria + " "); //UPGRADE_TODO: The equivalent in .NET for method 'java.util.ArrayList.size' may return a different value. 'ms-help://MS.VSCC.2003/commoner/redir/redirect.htm?keyword="jlca1043"' --- 69,73 ---- for (int i = 0; i < criteria.Count; i++) { ! string thisCriteria = (String) criteria[i]; sb.Append(" " + thisCriteria + " "); //UPGRADE_TODO: The equivalent in .NET for method 'java.util.ArrayList.size' may return a different value. 'ms-help://MS.VSCC.2003/commoner/redir/redirect.htm?keyword="jlca1043"' *************** *** 92,100 **** } ! virtual public String ParamTypesAsString { get { ! String types = "new Type[] {"; // Always need the local class as an association type types += ("Hibernate.association(" + localClass.Name + ".class), "); --- 92,100 ---- } ! virtual public string ParamTypesAsString { get { ! string types = "new Type[] {"; // Always need the local class as an association type types += ("Hibernate.association(" + localClass.Name + ".class), "); *************** *** 102,106 **** for (int i = 0; i < criteriaParamTypes.Count; i++) { ! String s = (String) criteriaParamTypes[i]; types += s; //UPGRADE_TODO: The equivalent in .NET for method 'java.util.ArrayList.size' may return a different value. 'ms-help://MS.VSCC.2003/commoner/redir/redirect.htm?keyword="jlca1043"' --- 102,106 ---- for (int i = 0; i < criteriaParamTypes.Count; i++) { ! string s = (String) criteriaParamTypes[i]; types += s; //UPGRADE_TODO: The equivalent in .NET for method 'java.util.ArrayList.size' may return a different value. 'ms-help://MS.VSCC.2003/commoner/redir/redirect.htm?keyword="jlca1043"' *************** *** 123,131 **** } ! virtual public String ParamsAsString { get { ! String types = "new Object[] {"; // Always joining via the local class types += (localClass.Name.ToLower() + ", "); --- 123,131 ---- } ! virtual public string ParamsAsString { get { ! string types = "new Object[] {"; // Always joining via the local class types += (localClass.Name.ToLower() + ", "); *************** *** 133,137 **** for (int i = 0; i < params_Renamed.Count; i++) { ! String s = (String) params_Renamed[i]; types += s; //UPGRADE_TODO: The equivalent in .NET for method 'java.util.ArrayList.size' may return a different value. 'ms-help://MS.VSCC.2003/commoner/redir/redirect.htm?keyword="jlca1043"' --- 133,137 ---- for (int i = 0; i < params_Renamed.Count; i++) { ! string s = (String) params_Renamed[i]; types += s; //UPGRADE_TODO: The equivalent in .NET for method 'java.util.ArrayList.size' may return a different value. 'ms-help://MS.VSCC.2003/commoner/redir/redirect.htm?keyword="jlca1043"' *************** *** 146,153 **** } ! public const String CRITERIA_EQUALS = "="; ! public const String CRITERIA_GREATER_THAN = ">"; ! public const String CRITERIA_LESS_THAN = "<"; ! public const String CRITERIA_LIKE = "LIKE"; // List of strings that will later be put together to form the query --- 146,153 ---- } ! public const string CRITERIA_EQUALS = "="; ! public const string CRITERIA_GREATER_THAN = ">"; ! public const string CRITERIA_LESS_THAN = "<"; ! public const string CRITERIA_LIKE = "LIKE"; // List of strings that will later be put together to form the query *************** *** 170,174 **** private ClassMapping localClass = null; private ClassMapping foreignClass = null; ! private String joinFieldName = ""; public QueryBuilder() --- 170,174 ---- private ClassMapping localClass = null; private ClassMapping foreignClass = null; ! private string joinFieldName = ""; public QueryBuilder() *************** *** 177,181 **** } ! public virtual void setForeignClass(ClassName foreignClass, IDictionary classMappings, String joinFieldName) { //UPGRADE_TODO: Method 'java.util.Map.get' was converted to 'System.Collections.IDictionary.Item' which has a different behavior. 'ms-help://MS.VSCC.2003/commoner/redir/redirect.htm?keyword="jlca1073_javautilMapget_javalangObject"' --- 177,181 ---- } ! public virtual void setForeignClass(ClassName foreignClass, IDictionary classMappings, string joinFieldName) { //UPGRADE_TODO: Method 'java.util.Map.get' was converted to 'System.Collections.IDictionary.Item' which has a different behavior. 'ms-help://MS.VSCC.2003/commoner/redir/redirect.htm?keyword="jlca1073_javautilMapget_javalangObject"' *************** *** 185,191 **** } ! public virtual void addCritera(ClassMapping criteriaClass, FieldProperty field, String condition) { ! String newCritera = criteriaClass.Name.ToLower() + "." + field.FieldName + condition + "?"; //UPGRADE_TODO: The equivalent in .NET for method 'java.util.ArrayList.add' may return a different value. 'ms-help://MS.VSCC.2003/commoner/redir/redirect.htm?keyword="jlca1043"' params_Renamed.Add(FinderRenderer.getFieldAsObject(false, field)); --- 185,191 ---- } ! public virtual void addCritera(ClassMapping criteriaClass, FieldProperty field, string condition) { ! string newCritera = criteriaClass.Name.ToLower() + "." + field.FieldName + condition + "?"; //UPGRADE_TODO: The equivalent in .NET for method 'java.util.ArrayList.add' may return a different value. 'ms-help://MS.VSCC.2003/commoner/redir/redirect.htm?keyword="jlca1043"' params_Renamed.Add(FinderRenderer.getFieldAsObject(false, field)); Index: MappingElement.cs =================================================================== RCS file: /cvsroot/nhibernate/NHibernateContrib/src/NHibernate.Tool.hbm2net/MappingElement.cs,v retrieving revision 1.1 retrieving revision 1.2 diff -C2 -d -r1.1 -r1.2 *** MappingElement.cs 30 Dec 2004 16:54:54 -0000 1.1 --- MappingElement.cs 1 Mar 2005 16:24:39 -0000 1.2 *************** *** 71,75 **** /// <summary>Returns true if this element has the meta attribute </summary> ! public virtual bool hasMeta(String attribute) { return metaattribs.ContainsKey(attribute); --- 71,75 ---- /// <summary>Returns true if this element has the meta attribute </summary> ! public virtual bool hasMeta(string attribute) { return metaattribs.ContainsKey(attribute); *************** *** 77,81 **** /* Given a key, return the list of metaattribs. Can return null! */ ! public virtual SupportClass.ListCollectionSupport getMeta(String attribute) { return (SupportClass.ListCollectionSupport) metaattribs[attribute]; --- 77,81 ---- /* Given a key, return the list of metaattribs. Can return null! */ ! public virtual SupportClass.ListCollectionSupport getMeta(string attribute) { return (SupportClass.ListCollectionSupport) metaattribs[attribute]; *************** *** 87,91 **** /// <returns> String /// </returns> ! public virtual String getMetaAsString(String attribute) { SupportClass.ListCollectionSupport c = getMeta(attribute); --- 87,91 ---- /// <returns> String /// </returns> ! public virtual string getMetaAsString(string attribute) { SupportClass.ListCollectionSupport c = getMeta(attribute); *************** *** 94,108 **** } ! public virtual String getMetaAsString(String attribute, String seperator) { return MetaAttributeHelper.getMetaAsString(getMeta(attribute), seperator); } ! public virtual bool getMetaAsBool(String attribute) { return getMetaAsBool(attribute, false); } ! public virtual bool getMetaAsBool(String attribute, bool defaultValue) { SupportClass.ListCollectionSupport c = getMeta(attribute); --- 94,108 ---- } ! public virtual string getMetaAsString(string attribute, string seperator) { return MetaAttributeHelper.getMetaAsString(getMeta(attribute), seperator); } ! public virtual bool getMetaAsBool(string attribute) { return getMetaAsBool(attribute, false); } ! public virtual bool getMetaAsBool(string attribute, bool defaultValue) { SupportClass.ListCollectionSupport c = getMeta(attribute); Index: MethodSignatureBuilder.cs =================================================================== RCS file: /cvsroot/nhibernate/NHibernateContrib/src/NHibernate.Tool.hbm2net/MethodSignatureBuilder.cs,v retrieving revision 1.1 retrieving revision 1.2 diff -C2 -d -r1.1 -r1.2 *** MethodSignatureBuilder.cs 30 Dec 2004 16:54:54 -0000 1.1 --- MethodSignatureBuilder.cs 1 Mar 2005 16:24:39 -0000 1.2 *************** *** 21,25 **** throwsList = new ArrayList(); } ! virtual public String Name { get --- 21,25 ---- throwsList = new ArrayList(); } ! virtual... [truncated message content] |