-->
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: NHibernate.MappingException: Repated column in mapping...
PostPosted: Wed Feb 01, 2006 11:58 pm 
Newbie

Joined: Tue Jan 17, 2006 5:14 pm
Posts: 4
The application throws the error on Windows Server 2003 SP1, but not on Windows XP SP2.

Also to note: version 0.9 works just fine...

I would appreciate some help on this...

Thanks!

Hibernate version: 1.0.0 & 1.0.2

Mapping documents:

<?xml version="1.0" encoding="utf-8" ?>
<hibernate-mapping xmlns="urn:nhibernate-mapping-2.0">

<class name="MVCDemo.OrderDetails, MVCDemo" table="OrderDetails">
<id name="OrderID" column="OrderId" type="integer">
<generator class="assigned" />
</id>
<property name="ProductID" column="ProductID" type="integer"/>
<property name="UnitPrice" column="UnitPrice" type="Decimal"/>
<property name="Quantity" column="Quantity" type="integer"/>
<property name="Discount" column="Discount" type="Double"/>

<many-to-one name="Product" class="MVCDemo.Products, MVCDemo" column="ProductID" />
</class>

</hibernate-mapping>
Code between sessionFactory.openSession() and session.close():

public Employees authEmployee(string strUserID, string strPWD)
{
ArrayList alEmp = new ArrayList();
NHibernateHelper nhHelp = new NHibernateHelper();
Configuration cfg = nhHelp.getConfiguration();

ISessionFactory factory = cfg.BuildSessionFactory();
ISession session = factory.OpenSession();
ITransaction transaction = session.BeginTransaction();

session = factory.OpenSession();

// Employees emp = (Employees)session.Load(typeof(Employees), strUserID);
Employees emp = new Employees();
alEmp = (ArrayList)session.CreateCriteria(typeof(Employees))
.Add(Expression.Eq("UserID", strUserID))
.Add(Expression.Eq("Password", strPWD))
.List();

session.Flush();
session.Close();

return emp = (Employees)alEmp[0];
}

Full stack trace of any exception that occurs:

MappingException: Repated column in mapping for class MVCDemo.OrderDetails should be mapped with insert="false" update="false": ProductID]
NHibernate.Persister.AbstractEntityPersister.CheckColumnDuplication(ISet distinctColumns, ICollection columns) +217
NHibernate.Persister.EntityPersister..ctor(PersistentClass model, ISessionFactoryImplementor factory) +2957
NHibernate.Persister.PersisterFactory.CreateClassPersister(PersistentClass model, ISessionFactoryImplementor factory) +59
NHibernate.Impl.SessionFactoryImpl..ctor(Configuration cfg, Settings settings) +537
NHibernate.Cfg.Configuration.BuildSessionFactory() +90
MVCDemo.EmployeesDaoHImpl.authEmployee(String strUserID, String strPWD) in C:\DemoWebs\MVCDemo\Persistence\Implementations\EmployeesDaoHImpl.cs:44
MVCDemo.EmployeesFacadeImpl.authEmployee(String strUserID, String strPWD) in C:\DemoWebs\MVCDemo\Services\Implementations\EmployeesFacadeImpl.cs:43
MVCDemo.Login.Page_Load(Object sender, EventArgs e) in C:\DemoWebs\MVCDemo\Login.aspx.cs:56
System.Web.UI.Control.OnLoad(EventArgs e) +67
System.Web.UI.Control.LoadRecursive() +35
System.Web.UI.Page.ProcessRequestMain() +750


Name and version of the database you are using: MS SQL Server 2000

The generated SQL (show_sql=true):

Debug level Hibernate log excerpt:


Top
 Profile  
 
 Post subject: Remove the property ProductID
PostPosted: Thu Feb 02, 2006 1:09 am 
Regular
Regular

Joined: Tue Jan 03, 2006 7:21 am
Posts: 85
I think you can remove the property definition for ProductID as this is already used in the relationship. Then this should work.

Anytime you need ProductID you can always get it by OrderDetails.Product.ProductID


Top
 Profile  
 
 Post subject: Remove the property ProductID
PostPosted: Thu Feb 02, 2006 1:56 am 
Regular
Regular

Joined: Tue Jan 03, 2006 7:21 am
Posts: 85
I think you can remove the property definition for ProductID as this is already used in the relationship. Then this should work.

Anytime you need ProductID you can always get it by OrderDetails.Product.ProductID


Top
 Profile  
 
 Post subject: Remove the property ProductID
PostPosted: Thu Feb 02, 2006 2:02 am 
Regular
Regular

Joined: Tue Jan 03, 2006 7:21 am
Posts: 85
I think you can remove the property definition for ProductID as this is already used in the relationship. Then this should work.

Anytime you need ProductID you can always get it by OrderDetails.Product.ProductID


Top
 Profile  
 
 Post subject:
PostPosted: Thu Feb 02, 2006 11:35 pm 
Newbie

Joined: Tue Jan 17, 2006 5:14 pm
Posts: 4
I remove the property ProductID. Still throws the exception???

It only throws the exception on the Windows Server 2003.

Thanks!


Top
 Profile  
 
 Post subject:
PostPosted: Fri Feb 03, 2006 3:48 am 
Contributor
Contributor

Joined: Wed May 11, 2005 4:59 pm
Posts: 1766
Location: Prague, Czech Republic
If the exception thrown is exactly the same, then you may be hitting a bug where Visual Studio does not recompile the assembly if the only change is in an embedded resource. Try "Rebuild" command in Visual Studio.

If not, please post details about the exception that occurs on Windows Server 2003.


Top
 Profile  
 
 Post subject:
PostPosted: Sat Feb 04, 2006 2:50 pm 
Newbie

Joined: Tue Jan 17, 2006 5:14 pm
Posts: 4
That did it!

Thanks for all your help...


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.