I’m using NHibernate with C# and at compiling time it gives me this error:
{"Could not find a getter for property 'idOrder' in class 'FrancosPoS.DBMapping.ordPsf'"}
I have found this question, but I could not get how to use it for me:
Nhibernate – Could not find a getter for property
This is my mapping class:
<?xml version="1.0" encoding="utf-8"?>
<hibernate-mapping assembly="FrancosPoS" namespace="FrancosPoS.DBMapping" xmlns="urn:nhibernate-mapping-2.2">
<class name="ordPsf" table="ord_psf" lazy="true" >
<id name="idOrdPastaF">
<generator class="identity" />
<!--<column name="idOrdPastaF" sql-type="int(11)" not-null="true" />-->
</id>
<many-to-one insert="false" update="false" lazy="false" name="idOrder">
<column name="idOrder" sql-type="int(11)" not-null="true" />
</many-to-one>
<property name="idOrder">
<column name="idOrder" sql-type="int(11)" not-null="true" />
</property>
<many-to-one insert="false" update="false" lazy="false" name="idPastaF">
<column name="idPastaF" sql-type="int(11)" not-null="true" />
</many-to-one>
<property name="idPastaF">
<column name="idPastaF" sql-type="int(11)" not-null="true" />
</property>
.
.
.
<property name="obs">
<column name="obs" sql-type="varchar(50)" not-null="false" />
</property>
<property name="price">
<column name="price" sql-type="decimal(8,4)" not-null="true" />
</property>
</class>
</hibernate-mapping>
And this is my cs class:
namespace FrancosPoS.DBMapping {
public partial class ordPsf {
public ordPsf() { }
public virtual int idOrdPastaF { get; set; }
public virtual order order { get; set; }
public virtual pastaFeast pastaFeast { get; set; }
public virtual salad salad { get; set; }
public virtual onTheSide onTheSide { get; set; }
public virtual string obs { get; set; }
public virtual string price { get; set; }
}
}
My guess is that I’m doing the mapping wrong. By obvious reasons, I don’t want to have a idOrder get/set because I need to use the object. (Besides, I’m guessing that the same error will occur at the other ids after fixing this one)
I have found that the problem is with the < property > “conflicting” with the < many-to-one > relationship:
We don’t need to have this as the many-to-one will take care of the order object (and id).
Found by looking on how to map a many-to-one relationship: http://ajlopez.wordpress.com/2011/05/19/nhibernate-3-part-6-one-to-many-with-many-to-one/