My database structure looks something like this:
Person
Id
Name
FieldA
FieldB
Phone
Id
Number
PersonPhone
PhoneId
PersonId
IsDefault
My NHibernate mappings for the Person and Phone objects are straight forward, its the PersonPhone I'm having difficult with. I want to have a collection of PersonPhone objects as a property of Person which will allow me to have the Phone number of a person and be able to tell which is the "default" or primary phone number for a person.
ideally Id like my PersonPhone object to look like this:
public class PersonPhone
{
public virtual Person Person { get; set; }
public virtual Phone Phone { get; set; }
public virtual bool IsDefault { get; set; }
}
so far my NHibernate mapping for this table looks like the following:
<class name="PersonPhone" table="PersonPhone">
<composite-id>
<key-property name="Person" column="PersonId" />
<key-property name="Phone" column="PhoneId" />
</composite-id>
<property name="IsDefault" column="IsDefault"/>
</class>
but when NHibernate compiles my mappings I get an error saying:
Could not compile the mapping document: MyApp.Entities.PersonPhone.hbm.xml. NHibernate.MappingException : Could not determine type for: MyApp.Entities.Person, MyApp.Entities, Version=1.0.0.0, Culture=neutral, PublicKeyToken=null, for columns: NHibernate.Mapping.Column(PersonId)
Any ideas on how this should be mapped?