Take the 2-minute tour ×

We have POCO, something like:

public class Person
    public Guid PersonID { get; set; }

    public string FirstName { get; set; }

    public string LastName { get; set; }

    public DateTime DateOfBirth { get; set; }

    public string   Version {get; set; }

And the corresponding hbm file as

<hibernate-mapping xmlns="urn:nhibernate-mapping-2.2" assembly="NHibernate.FirstAttempt"  namespace="NHibernate.FirstAttempt.Entity" >
  <class name="Person" lazy="false">
    <id name="PersonID">
      <generator class="guid" />
    <property name="FirstName"  />
    <property name="LastName"     />
    <property name="DateOfBirth"  />

If you look closely, we have a Version property, for which there is no column in the database ? We just want nHibernate to ignore this property and that's the reason we did not put the property in the mapping file. But instead it started throwing error.

Is there a way around this ?

share|improve this question
add comment

1 Answer

up vote 8 down vote accepted

You should make all members virtual and not map the property you want to ignore.

share|improve this answer
Thanks it works for me –  Sanket Naik Apr 29 '11 at 10:26
Was just wondering, is there a way out in case you don't want to make the members virtual ? –  Sanket Naik Apr 29 '11 at 10:37
Yes, you have to disable lazy loading by default. Then only collection properties need be virtual, IIRC. –  Andy Apr 29 '11 at 12:43
@SanketNaik NHibernate uses Castle DynamicProxy internally and requires proxied class members to be virtual in order to intercept them. –  Marc Climent Feb 4 at 9:42
add comment

Your Answer


