In Hibernate, the java.util.Collection is used in PersistentCollectionType.copy(). And java.util.Collection has the method add().
On .Net side, ICollection doesn't have Add(), I think that's why it got changed to IList.
But IList is not the common base interface.
I made a dirty modification like this, the other way is override this Copy() method in NHibernate.Type.MapType:
public override object Copy( object original, object target, ISessionImplementor session, object owner, IDictionary copiedAlready )
{
object retResult = null;
if ( original == null )
{
return null;
}
if ( !NHibernateUtil.IsInitialized( original ) )
{
return target;
}
IType elemType = GetElementType( session.Factory );
if ( original is IList )
{
IList originalCopy = new ArrayList( (IList) original );
IList result = target == null ? (IList) Instantiate( session, session.Factory.GetCollectionPersister( role ) ) : (IList) target;
result.Clear();
foreach ( object obj in originalCopy )
{
result.Add( elemType.Copy( obj, null, session, owner, copiedAlready ) );
}
retResult = result;
}
else if (original is IDictionary)
{
IDictionary originalCopy = new Hashtable((IDictionary) original);
IDictionary result = target == null ? (IDictionary) Instantiate( session, session.Factory.GetCollectionPersister( role ) ) : (IDictionary) target;
result.Clear();
foreach ( object key in originalCopy.Keys )
{
object newObj = elemType.Copy(originalCopy[key], null, session, owner, copiedAlready );
result[key] = newObj;
}
retResult = result;
}
return retResult;
}
=========================
Hibernate 3 has depricate SaveOrUpdateCopy(), use Merg() instead. Is there any enhancement for Hibernate3 in changing this? I havn't got time to investigate yet. Anyone know about it already?
What is the plan for NHibernate to keep up to Hibernate 3.x?
|