Update of /cvsroot/nhibernate/nhibernate/src/NHibernate/Cfg
In directory sc8-pr-cvs1.sourceforge.net:/tmp/cvs-serv1460/src/NHibernate/Cfg
Modified Files:
Binder.cs Configuration.cs Mappings.cs
Log Message:
Ported property-ref attribute implementation from Hibernate 2.1
Index: Mappings.cs
===================================================================
RCS file: /cvsroot/nhibernate/nhibernate/src/NHibernate/Cfg/Mappings.cs,v
retrieving revision 1.13
retrieving revision 1.14
diff -C2 -d -r1.13 -r1.14
*** Mappings.cs 21 Mar 2005 11:31:35 -0000 1.13
--- Mappings.cs 26 Mar 2005 13:24:36 -0000 1.14
***************
*** 31,35 ****
private INamingStrategy namingStrategy;
! private class UniquePropertyReference
{
public System.Type ReferencedClass;
--- 31,35 ----
private INamingStrategy namingStrategy;
! internal class UniquePropertyReference
{
public System.Type ReferencedClass;
Index: Binder.cs
===================================================================
RCS file: /cvsroot/nhibernate/nhibernate/src/NHibernate/Cfg/Binder.cs,v
retrieving revision 1.42
retrieving revision 1.43
diff -C2 -d -r1.42 -r1.43
*** Binder.cs 21 Mar 2005 11:31:35 -0000 1.42
--- Binder.cs 26 Mar 2005 13:24:36 -0000 1.43
***************
*** 80,84 ****
catch ( Exception cnfe )
{
! throw new MappingException( "persistent class not found", cnfe );
}
--- 80,84 ----
catch ( Exception cnfe )
{
! throw new MappingException( "persistent class " + className + " not found", cnfe );
}
Index: Configuration.cs
===================================================================
RCS file: /cvsroot/nhibernate/nhibernate/src/NHibernate/Cfg/Configuration.cs,v
retrieving revision 1.35
retrieving revision 1.36
diff -C2 -d -r1.35 -r1.36
*** Configuration.cs 15 Mar 2005 14:06:30 -0000 1.35
--- Configuration.cs 26 Mar 2005 13:24:36 -0000 1.36
***************
*** 716,721 ****
secondPasses.Clear();
! //TODO: Somehow add the newly created foreign keys to the internal collection
log.Info( "processing foreign key constraints" );
--- 716,744 ----
secondPasses.Clear();
! log.Info("processing one-to-one association property references");
+ foreach( Mappings.UniquePropertyReference upr in propertyReferences )
+ {
+ PersistentClass clazz = GetClassMapping( upr.ReferencedClass );
+ if ( clazz == null ) throw new MappingException( "property-ref to unmapped class: " + upr.ReferencedClass.Name );
+ bool found = false;
+
+ foreach( NHibernate.Mapping.Property prop in clazz.PropertyCollection )
+ {
+ if ( upr.PropertyName.Equals( prop.Name ) )
+ {
+ ( (SimpleValue) prop.Value ).IsUnique = true;
+ found = true;
+ break;
+ }
+ }
+ if (!found) throw new MappingException(
+ "property-ref not found: " + upr.PropertyName +
+ " in class: " + upr.ReferencedClass.Name
+ );
+ }
+
+ //TODO: Somehow add the newly created foreign keys to the internal collection
+
log.Info( "processing foreign key constraints" );
|