Need help with Hibernate? Read this first:
http://www.hibernate.org/ForumMailingli ... AskForHelp
Hibernate version:
NHibernate 1.0
Mapping documents:
<?xml version="1.0" encoding="utf-8" ?>
<hibernate-mapping xmlns="urn:nhibernate-mapping-2.0">
<class name="Jas.SalesLeads.BusinessRules.Branch,Jas.SalesLeads.BusinessRules" table="tbBranch">
<id name="BranchId" column="BranchId" type="String">
<generator class="assigned"/>
</id>
<timestamp column="Timestamp" name="Timestamp"/>
<property column="BranchName" type="String" name="BranchName" not-null="true"/>
<many-to-one name="Area" column="AreaId" not-null="true" class="Jas.SalesLeads.BusinessRules.Area, Jas.SalesLeads.BusinessRules" />
<bag name="UserRoleBranchManagers" table="tbRelBranchManagers">
<key column="BranchId" />
<many-to-many column="UserRoleId" class="Jas.SalesLeads.BusinessRules.UserRoles.IUserRole, Jas.SalesLeads.BusinessRules"/>
</bag>
</class>
</hibernate-mapping>
<?xml version="1.0" encoding="utf-8" ?>
<hibernate-mapping xmlns="urn:nhibernate-mapping-2.0">
<class name="Jas.SalesLeads.BusinessRules.SalesLeadItem,Jas.SalesLeads.BusinessRules" table="tbSalesLeadItem">
<id name="SalesLeadId" column="SalesLeadId" type="Int64">
<generator class="identity">
</generator>
</id>
<timestamp column="Timestamp" name="Timestamp"/>
<property column="InsertDateTime" type="DateTime" name="InsertDateTime"/>
<property column="Shipper" type="String" name="Shipper" not-null="true"/>
<property column="ShipperPIC" type="String" name="ShipperPIC" not-null="true"/>
<property column="ShipperLocation" type="String" name="ShipperLocation" not-null="true"/>
<property column="ShipperPhone" type="String" name="ShipperPhone" not-null="true"/>
<property column="Consignee" type="String" name="Consignee" not-null="true"/>
<property column="ConsigneeLocation" type="String" name="ConsigneeLocation" not-null="true"/>
<property column="ConsigneePIC" type="String" name="ConsigneePIC" not-null="true"/>
<property column="ConsigneePhone" type="String" name="ConsigneePhone" not-null="true"/>
<property column="LastStatusChange" type="DateTime" name="LastStatusChange" not-null="true" />
<property column="OriginOfGoods" type="String" name="OriginOfGoods" not-null="true" />
<property column="DestinationOfGoods" type="String" name="DestinationOfGoods" not-null="true" />
<property column="Broker" type="String" name="Broker" not-null="true" />
<property column="Commodity" type="String" name="Commodity" not-null="true" />
<property column="TrafficVolume" type="String" name="TrafficVolume" not-null="true" />
<property column="Service" type="String" name="Service" not-null="true" />
<property column="Notes" type="String" name="Notes" not-null="true" />
<many-to-one name="Status" column="StatusId" class="Jas.SalesLeads.BusinessRules.SalesLeadStatus, Jas.SalesLeads.BusinessRules" />
<many-to-one name="BranchFrom" column="BranchFrom" class="Jas.SalesLeads.BusinessRules.Branch, Jas.SalesLeads.BusinessRules" />
<many-to-one name="InsertBy" column="InsertBy" class="Jas.SalesLeads.BusinessRules.User, Jas.SalesLeads.BusinessRules" />
<many-to-one name="UserInCharge" column="UserInCharge" class="Jas.SalesLeads.BusinessRules.User, Jas.SalesLeads.BusinessRules" />
<many-to-one name="CountryTo" column="CountryTo" class="Jas.SalesLeads.BusinessRules.AppCountry, Jas.SalesLeads.BusinessRules" />
<many-to-one name="CompanyTo" column="CompanyTo" class="Jas.SalesLeads.BusinessRules.Company, Jas.SalesLeads.BusinessRules" />
<many-to-one name="OfficeTo" column="OfficeTo" class="Jas.SalesLeads.BusinessRules.Office, Jas.SalesLeads.BusinessRules" />
<many-to-one name="RecipientGroup" column="RecipientGroup" class="Jas.SalesLeads.BusinessRules.RecipientGroup, Jas.SalesLeads.BusinessRules" />
<many-to-one name="Ratio" column="Ratio" class="Jas.SalesLeads.BusinessRules.ShipmentRatio, Jas.SalesLeads.BusinessRules" not-null="true" />
<many-to-one name="Frequency" column="Frequency" class="Jas.SalesLeads.BusinessRules.ShipmentFrequency, Jas.SalesLeads.BusinessRules" not-null="true" />
<bag name="SalesLeadRemarks" table="tbSalesLeadRemark" inverse="true" cascade="delete">
<key column="SalesLeadId" />
<one-to-many class="Jas.SalesLeads.BusinessRules.SalesLeadRemark, Jas.SalesLeads.BusinessRules"/>
</bag>
<bag name="SalesLeadHistoryItems" table="tbSalesLeadHistoryItems" inverse="true" cascade="delete">
<key column="SalesLeadId" />
<one-to-many class="Jas.SalesLeads.BusinessRules.SalesLeadHistoryItem, Jas.SalesLeads.BusinessRules"/>
</bag>
</class>
</hibernate-mapping>
<?xml version="1.0" encoding="utf-8" ?>
<hibernate-mapping xmlns="urn:nhibernate-mapping-2.0">
<class name="Jas.SalesLeads.BusinessRules.Area,Jas.SalesLeads.BusinessRules" table="tbArea">
<id name="AreaId" column="AreaId" type="String">
<generator class="assigned"/>
</id>
<timestamp column="Timestamp" name="Timestamp"/>
<property column="AreaName" type="String" name="AreaName" not-null="true"/>
<bag name="Branches" table="tbBranch" inverse="true">
<key column="AreaId" />
<one-to-many class="Jas.SalesLeads.BusinessRules.Branch, Jas.SalesLeads.BusinessRules"/>
</bag>
<bag name="UserRoleAreaManagers" table="tbRelAreaManagers">
<key column="AreaId" />
<many-to-many column="UserRoleId" class="Jas.SalesLeads.BusinessRules.UserRoles.IUserRole, Jas.SalesLeads.BusinessRules"/>
</bag>
<bag name="UserRoleSalesCoordinators" table="tbRelSalesCoordinators">
<key column="AreaId" />
<many-to-many column="UserRoleId" class="Jas.SalesLeads.BusinessRules.UserRoles.IUserRole, Jas.SalesLeads.BusinessRules"/>
</bag>
</class>
</hibernate-mapping>
Code between sessionFactory.openSession() and session.close():
Full stack trace of any exception that occurs:
[QueryException: could not resolve property:BranchFrom.Area of :Jas.SalesLeads.BusinessRules.SalesLeadItem]
Jas.SalesLeads.BusinessRules.Filters.SalesLeadItem_AreaManager.AddCriterion() in c:\intranet\salesleads\businessrules\filters\salesleaditem_areamanager.cs:51
Jas.SalesLeads.BusinessRules.Filters.RoleFilterCollection.ComposeCriteria(User obUser) in C:\Intranet\SalesLeads\BusinessRules\Filters\RoleFilterCollection.cs:67
Jas.SalesLeads.BusinessRules.SalesLeadItem.StandardFilters(User obUser, ICriteria obCriteria) in c:\intranet\salesleads\businessrules\salesleaditem.cs:841
[TargetInvocationException: Eccezione generata dalla destinazione di una chiamata.]
System.Reflection.RuntimeMethodInfo.InternalInvoke(Object obj, BindingFlags invokeAttr, Binder binder, Object[] parameters, CultureInfo culture, Boolean isBinderDefault, Assembly caller, Boolean verifyAccess) +0
System.Reflection.RuntimeMethodInfo.InternalInvoke(Object obj, BindingFlags invokeAttr, Binder binder, Object[] parameters, CultureInfo culture, Boolean verifyAccess) +317
System.Reflection.RuntimeMethodInfo.Invoke(Object obj, BindingFlags invokeAttr, Binder binder, Object[] parameters, CultureInfo culture) +23
System.Reflection.MethodBase.Invoke(Object obj, Object[] parameters) +14
Jas.Com.BusinessFacade.HibernateCriteriaAdapter..ctor(IUser obUser, Boolean bnIsPaged, Type obType) in c:\intranet\common\businessfacade\hibernatecriteriaadapter.cs:52
Jas.Com.WebControls.JasObjectPager.Initialize(Type obType) in c:\intranet\common\webcontrols\jasobjectpager\jasobjectpager.cs:52
Jas.SalesLeads.WebUI.AspPages.SalesLeadsList.InitializeLists() in c:\intranet\salesleads\salesleads_webui\asppages\salesleadslist.aspx.cs:101
Jas.SalesLeads.WebUI.AspPages.SalesLeadsList.Page_Load(Object sender, EventArgs e) in c:\intranet\salesleads\salesleads_webui\asppages\salesleadslist.aspx.cs:70
System.Web.UI.Control.OnLoad(EventArgs e)
System.Web.UI.Control.LoadRecursive()
System.Web.UI.Page.ProcessRequestMain()
Name and version of the database you are using:
MSSQL Server 2000
The generated SQL (show_sql=true):
Debug level Hibernate log excerpt:
NHibernate.QueryException: could not resolve property:BranchFrom.Area of :Jas.SalesLeads.BusinessRules.SalesLeadItem
-----------------
Basically when i try to create a Criterion tha links an object refenced inside my class i get an error . It looks like Hibernate when using Criterias does not understand that Area (Type Area) is a property of BranchForm (type Branch) the mapping is right since i used it for months ..i am just now switchuing from HQL to Criterias and finding this prolem
Expression.In("BranchFrom.Area", list);