Hi,
This question might be too elementary. Sorry if it is so. I seem to be having a problem when loading a bag. My mapping file has the following entries:
Code:
<class name="com.vortexengg.yantra.business.entity.Part, Yantra" table="part">
<id name="PartGkey" column="part_gkey">
<generator class="native" />
</id>
<property name="PartName" column="part_name" type="string" length="50"/>
<property name="PartQtyPerUnit" column="part_qty_per_unit" type="double" />
<bag name="PartComponents" table="part_components" cascade="save-update" lazy="false" >
<key column="comppart_part_gkey" />
<one-to-many class="com.vortexengg.yantra.business.entity.Component, Yantra" />
</bag>
<bag name="PartSteps" table="part_operations" cascade="save-update" lazy="false" >
<key column="partop_part_gkey" />
<one-to-many class="com.vortexengg.yantra.business.entity.Operation, Yantra" />
</bag>
<property name="PartAccessory" column="part_accessories" type="string" length="500" />
<many-to-one name="PartVendor" column="part_vendor" class="com.vortexengg.yantra.business.entity.Vendor, Yantra" />
<property name="PartGuidlines" column="part_guidelines" type="string" length="1000" />
<property name="PartQC" column="part_qc" type="string" length="1000" />
<property name="PartRemarks" column="part_remarks" type="string" length="1000" />
<property name="CreatedDate" column="created_date" type="Timestamp" not-null="true" />
<property name="CreatedUser" column="created_user" type="String" />
<property name="ModifiedDate" column="modified_date" type="Timestamp"/>
<property name="ModifiedUser" column="modified_user" type="String" />
</class>
I am using the folloing code to load all the rows for the given entity:
Code:
public IList GetAllRowsForEntity(string entityName) {
ISession session = null;
IList lst;
try {
session = GetSession();
IQuery qry = session.CreateQuery("from " + entityName);
lst = qry.List();
} catch (Exception exp) {
throw new CommonBizFailure (exp.Message, exp.InnerException, CommonEnums.ErrorLevelEnum.SEVERE);
} finally {
if(null!=session) {
session.Close();
}
}
return lst;
}
When the query is executed, I am getting the folloing error:
Code:
************* Exception Text **************
com.vortexengg.common.exceptions.CommonBizFailure: Could not execute query
could not initialize collection: [com.vortexengg.yantra.business.entity.Part.PartSteps#1] ---> NHibernate.ADOException: could not initialize collection: [com.vortexengg.yantra.business.entity.Part.PartSteps#1] ---> MySql.Data.MySqlClient.MySqlException: #42S22Unknown column 'partsteps0_.partop_part_gkey' in 'field list'
at MySql.Data.MySqlClient.PacketReader.CheckForError()
at MySql.Data.MySqlClient.PacketReader.ReadHeader()
at MySql.Data.MySqlClient.PacketReader.OpenPacket()
at MySql.Data.MySqlClient.NativeDriver.ReadResult(Int64& affectedRows, Int64& lastInsertId)
at MySql.Data.MySqlClient.CommandResult.ReadNextResult(Boolean isFirst)
at MySql.Data.MySqlClient.NativeDriver.SendQuery(Byte[] bytes, Int32 length, Boolean consume)
at MySql.Data.MySqlClient.MySqlCommand.GetNextResultSet(MySqlDataReader reader)
at MySql.Data.MySqlClient.MySqlDataReader.NextResult()
at MySql.Data.MySqlClient.MySqlCommand.ExecuteReader(CommandBehavior behavior)
at MySql.Data.MySqlClient.MySqlCommand.ExecuteReader()
at MySql.Data.MySqlClient.MySqlCommand.System.Data.IDbCommand.ExecuteReader()
at NHibernate.Impl.BatcherImpl.ExecuteReader(IDbCommand cmd)
at NHibernate.Loader.Loader.GetResultSet(IDbCommand st, RowSelection selection, ISessionImplementor session)
at NHibernate.Loader.Loader.DoQuery(ISessionImplementor session, QueryParameters queryParameters, Object optionalObject, Object optionalId, Object[] optionalCollectionKeys, Boolean returnProxies)
at NHibernate.Loader.Loader.DoQueryAndInitializeNonLazyCollections(ISessionImplementor session, QueryParameters queryParameters, Object optionalObject, Object optionalId, Object[] optionalCollectionKeys, Boolean returnProxies)
at NHibernate.Loader.OneToManyLoader.Initialize(Object id, ISessionImplementor session)
at NHibernate.Collection.AbstractCollectionPersister.Initialize(Object key, ISessionImplementor session)
--- End of inner exception stack trace ---
at NHibernate.Collection.AbstractCollectionPersister.Initialize(Object key, ISessionImplementor session)
at NHibernate.Impl.SessionImpl.InitializeCollection(PersistentCollection collection, Boolean writing)
at NHibernate.Collection.PersistentCollection.ForceInitialization()
at NHibernate.Impl.SessionImpl.InitializeNonLazyCollections()
at NHibernate.Loader.Loader.DoQueryAndInitializeNonLazyCollections(ISessionImplementor session, QueryParameters queryParameters, Object optionalObject, Object optionalId, Object[] optionalCollectionKeys, Boolean returnProxies)
at NHibernate.Loader.Loader.List(ISessionImplementor session, QueryParameters queryParameters, ISet querySpaces, IType[] resultTypes)
at NHibernate.Hql.QueryTranslator.List(ISessionImplementor session, QueryParameters queryParameters)
at NHibernate.Impl.SessionImpl.Find(String query, QueryParameters parameters)
--- End of inner exception stack trace ---
at com.vortexengg.common.database.HibernateApi.GetAllRowsForEntity(String entityName) in c:\Venki\MyProjects\MS.NET\Common\Common\database\HibernateApi.cs:line 119
at com.vortexengg.common.business.managers.impl.CommonEntityManager.FindAllRowsForEntityAsValueObject(String EntityName) in c:\Venki\MyProjects\MS.NET\Common\Common\managers\impl\CommonEntityManager.cs:line 59
at com.vortexengg.common.delegates.EntityDelegate.GetAllRowsForEntityAsValueObject(IRequest inRequest) in c:\Venki\MyProjects\MS.NET\Common\Common\delegates\EntityDelegate.cs:line 38
at com.vortexengg.common.ui.BaseListForm.PopulateRows() in c:\Venki\MyProjects\MS.NET\Common\Common\forms\list\BaseListForm.cs:line 317
at com.vortexengg.common.ui.BaseListForm.PopulateGrid() in c:\Venki\MyProjects\MS.NET\Common\Common\forms\list\BaseListForm.cs:line 375
at com.vortexengg.common.ui.BaseListForm.Show() in c:\Venki\MyProjects\MS.NET\Common\Common\forms\list\BaseListForm.cs:line 405
at com.vortexengg.yantra.presentation.MainForm.MasterParts_Clicked(Object sender, EventArgs e) in c:\Venki\MyProjects\MS.NET\Yantra\Yantra\ui\MainForm.cs:line 155
at System.Windows.Forms.MenuItem.OnClick(EventArgs e)
at System.Windows.Forms.MenuItem.ShortcutClick()
at System.Windows.Forms.Menu.ProcessCmdKey(Message& msg, Keys keyData)
at System.Windows.Forms.Form.ProcessCmdKey(Message& msg, Keys keyData)
at System.Windows.Forms.Control.ProcessCmdKey(Message& msg, Keys keyData)
at System.Windows.Forms.Control.PreProcessMessage(Message& msg)
at System.Windows.Forms.ThreadContext.System.Windows.Forms.UnsafeNativeMethods+IMsoComponent.FPreTranslateMessage(MSG& msg)
I know I am missing something here. I just dont know what!!!
I am using MySQL 5.0. and .NET framework is 1.1, and NHibernate release is 1.0.
Any help is fully appreciated.