From: Paul H. <pha...@us...> - 2005-03-08 16:26:25
|
Update of /cvsroot/nhibernate/nhibernate/src/NHibernate/Collection In directory sc8-pr-cvs1.sourceforge.net:/tmp/cvs-serv16302/nhibernate/src/NHibernate/Collection Modified Files: AbstractCollectionPersister.cs BasicCollectionPersister.cs OneToManyPersister.cs Log Message: Bug fixing collection persister - aiming at 2.1 Loader features Index: OneToManyPersister.cs =================================================================== RCS file: /cvsroot/nhibernate/nhibernate/src/NHibernate/Collection/OneToManyPersister.cs,v retrieving revision 1.1 retrieving revision 1.2 diff -C2 -d -r1.1 -r1.2 *** OneToManyPersister.cs 1 Mar 2005 16:24:44 -0000 1.1 --- OneToManyPersister.cs 8 Mar 2005 16:26:12 -0000 1.2 *************** *** 39,44 **** protected override SqlString GenerateDeleteString( ) { ! SqlUpdateBuilder update = new SqlUpdateBuilder( factory ); ! update.SetTableName( QualifiedTableName ) .AddColumns( KeyColumnNames, "null" ) .SetIdentityColumn( KeyColumnNames, KeyType ); --- 39,44 ---- protected override SqlString GenerateDeleteString( ) { ! SqlUpdateBuilder update = new SqlUpdateBuilder( factory ) ! .SetTableName( QualifiedTableName ) .AddColumns( KeyColumnNames, "null" ) .SetIdentityColumn( KeyColumnNames, KeyType ); *************** *** 236,240 **** { // Super impl will ignore suffix for collection columns! ! return SelectFragment( alias ).Append( StringHelper.CommaSpace ); } else --- 236,241 ---- { // Super impl will ignore suffix for collection columns! ! //return SelectFragment( alias ).Append( StringHelper.CommaSpace ); ! return SelectFragment( alias ); } else *************** *** 252,259 **** 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 ) { --- 253,259 ---- protected override ICollectionInitializer CreateCollectionInitializer( ISessionFactoryImplementor factory ) { ! Loader.Loader nonbatchLoader = new OneToManyLoader( this, factory ); ! /* if ( batchSize > 1 ) { *************** *** 271,275 **** */ ! return null; } --- 271,276 ---- */ ! // Don't worry about batching for now ! return nonbatchLoader as ICollectionInitializer; } Index: BasicCollectionPersister.cs =================================================================== RCS file: /cvsroot/nhibernate/nhibernate/src/NHibernate/Collection/BasicCollectionPersister.cs,v retrieving revision 1.1 retrieving revision 1.2 diff -C2 -d -r1.1 -r1.2 *** BasicCollectionPersister.cs 1 Mar 2005 16:24:44 -0000 1.1 --- BasicCollectionPersister.cs 8 Mar 2005 16:26:12 -0000 1.2 *************** *** 34,65 **** /// <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 ) --- 34,60 ---- /// <summary> ! /// Generate the SQL DELETE that deletes all rows /// </summary> /// <returns></returns> protected override SqlString GenerateDeleteString( ) { ! SqlDeleteBuilder delete = new SqlDeleteBuilder( factory ) ! .SetTableName( QualifiedTableName ) ! .SetIdentityColumn( KeyColumnNames, KeyType ); ! if( HasWhere ) { ! delete.AddWhereFragment( Where ); } return delete.ToSqlString(); } /// <summary> ! /// Generate the SQL INSERT that creates a new row /// </summary> /// <returns></returns> protected override SqlString GenerateInsertRowString( ) { ! SqlInsertBuilder insert = new SqlInsertBuilder( factory ) ! .SetTableName( QualifiedTableName ) .AddColumn( KeyColumnNames, KeyType ); if( HasIndex ) *************** *** 77,87 **** /// <summary> ! /// /// </summary> /// <returns></returns> protected override SqlString GenerateUpdateRowString( ) { ! SqlUpdateBuilder update = new SqlUpdateBuilder( factory ); ! update.SetTableName( QualifiedTableName ) .AddColumns( ElementColumnNames, ElementType ); if( HasIdentifier ) --- 72,82 ---- /// <summary> ! /// Generate the SQL UPDATE that updates a row /// </summary> /// <returns></returns> protected override SqlString GenerateUpdateRowString( ) { ! SqlUpdateBuilder update = new SqlUpdateBuilder( factory ) ! .SetTableName( QualifiedTableName ) .AddColumns( ElementColumnNames, ElementType ); if( HasIdentifier ) *************** *** 99,103 **** /// <summary> ! /// /// </summary> /// <returns></returns> --- 94,98 ---- /// <summary> ! /// Generate the SQL DELETE that deletes a particular row /// </summary> /// <returns></returns> *************** *** 204,210 **** { // Don't worry about batching for now ! // TODO: Uncomment when we implement CollectionLoader ! //return (ICollectionInitializer) new CollectionLoader( this, factory ); ! return null; } --- 199,203 ---- { // Don't worry about batching for now ! return new CollectionLoader( this, factory ) as ICollectionInitializer; } *************** *** 242,246 **** public override SqlString SelectFragment( string alias, string suffix, bool includeCollectionColumns ) { ! return includeCollectionColumns ? SelectFragment( alias ) : null; } } --- 235,240 ---- public override SqlString SelectFragment( string alias, string suffix, bool includeCollectionColumns ) { ! // TODO: Changed from Null to SqlString( string.Empty ) as per Java ! return includeCollectionColumns ? SelectFragment( alias ) : new SqlString( string.Empty ) ; } } Index: AbstractCollectionPersister.cs =================================================================== RCS file: /cvsroot/nhibernate/nhibernate/src/NHibernate/Collection/AbstractCollectionPersister.cs,v retrieving revision 1.1 retrieving revision 1.2 diff -C2 -d -r1.1 -r1.2 *** AbstractCollectionPersister.cs 1 Mar 2005 16:24:44 -0000 1.1 --- AbstractCollectionPersister.cs 8 Mar 2005 16:26:12 -0000 1.2 *************** *** 111,117 **** keyType = collection.Key.Type; ! int span = collection.Key.ColumnSpan; ! keyColumnNames = new string[span]; ! string[ ] keyAliases = new string[span]; int k = 0; foreach( Column col in collection.Key.ColumnCollection ) --- 111,117 ---- keyType = collection.Key.Type; ! int keySpan = collection.Key.ColumnSpan; ! keyColumnNames = new string[ keySpan ]; ! string[ ] keyAliases = new string[ keySpan ]; int k = 0; foreach( Column col in collection.Key.ColumnCollection ) *************** *** 153,158 **** qualifiedTableName = table.GetQualifiedName( dialect, factory.DefaultSchema ); ! string[ ] aliases = new string[span]; ! elementColumnNames = new string[span]; int j = 0; foreach( Column col in iter ) --- 153,158 ---- qualifiedTableName = table.GetQualifiedName( dialect, factory.DefaultSchema ); ! string[ ] aliases = new string[ elementSpan ]; ! elementColumnNames = new string[ elementSpan ]; int j = 0; foreach( Column col in iter ) *************** *** 1240,1250 **** try { ! initializer.Initialize( key, null, owner, session ); } ! catch ( Exception ) { // TODO: Improve the exception info, original java shown below // throw convert( sqle, "could not initialize collection: " + MessageHelper.infoString(this, key) ); ! throw new ArgumentException( "could not initialize collection: " ); } } --- 1240,1250 ---- try { ! initializer.Initialize( key, session ); } ! catch ( Exception e ) { // TODO: Improve the exception info, original java shown below // throw convert( sqle, "could not initialize collection: " + MessageHelper.infoString(this, key) ); ! throw new Exception( "could not initialize collection: ", e ); } } |