-->
These old forums are deprecated now and set to read-only. We are waiting for you on our new forums!
More modern, Discourse-based and with GitHub/Google/Twitter authentication built-in.

All times are UTC - 5 hours [ DST ]



Forum locked This topic is locked, you cannot edit posts or make further replies.  [ 7 posts ] 
Author Message
 Post subject: Multiple Bags
PostPosted: Sun Dec 11, 2005 12:44 pm 
Newbie

Joined: Wed Dec 07, 2005 12:32 am
Posts: 11
Location: Chennai, India
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.


Top
 Profile  
 
 Post subject:
PostPosted: Sun Dec 11, 2005 10:49 pm 
Beginner
Beginner

Joined: Mon Aug 15, 2005 11:09 pm
Posts: 23
The part mapping looks right from what I can see. Just make sure your part_operations and partop_part_gkey mapping/table is correct. Does it work without the PartSteps bag?


Top
 Profile  
 
 Post subject:
PostPosted: Mon Dec 12, 2005 12:32 am 
Newbie

Joined: Wed Dec 07, 2005 12:32 am
Posts: 11
Location: Chennai, India
without the PartSteps and PartComponents, it works fine.


Top
 Profile  
 
 Post subject:
PostPosted: Mon Dec 12, 2005 10:27 am 
Contributor
Contributor

Joined: Thu May 12, 2005 9:45 am
Posts: 593
Location: nhibernate.org
Are you sure that the table "part_operations" contains the column "partop_part_gkey"?

_________________
Pierre Henri Kuaté.
Get NHibernate in Action Now!


Top
 Profile  
 
 Post subject:
PostPosted: Mon Dec 12, 2005 1:02 pm 
Expert
Expert

Joined: Fri May 13, 2005 11:13 am
Posts: 292
Location: Rochester, NY
If you have confirmed your mapping, have you tried extracting the generated SQL from the NH application log and running it directly in MySQL? I'm not a MySQL user; perhaps MySQL has some sort of profiler that would allow you to watch this happen from the "inside" as it were.


Top
 Profile  
 
 Post subject:
PostPosted: Mon Dec 12, 2005 1:24 pm 
Newbie

Joined: Wed Dec 07, 2005 12:32 am
Posts: 11
Location: Chennai, India
Quote:
Are you sure that the table "part_operations" contains the column "partop_part_gkey"?

Yes, it has both partop_part_gkey and partop_op_gkey. Similarly, for part_components has comppart_part_gkey and comppart_comp_gkey.

_________________
Thanks & Regards,
~Venki


Top
 Profile  
 
 Post subject:
PostPosted: Tue Dec 13, 2005 1:55 pm 
Newbie

Joined: Wed Dec 07, 2005 12:32 am
Posts: 11
Location: Chennai, India
Ok...Here is somthing very very dumb that I did...Instead of defining the column as many-to-many, I have defined it as one-to-many.

Sigh...:(

Anyways, thanks for all your posts...

_________________
Thanks & Regards,
~Venki


Top
 Profile  
 
Display posts from previous:  Sort by  
Forum locked This topic is locked, you cannot edit posts or make further replies.  [ 7 posts ] 

All times are UTC - 5 hours [ DST ]


You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum

Search for:
© Copyright 2014, Red Hat Inc. All rights reserved. JBoss and Hibernate are registered trademarks and servicemarks of Red Hat, Inc.