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.  [ 1 post ] 
Author Message
 Post subject: MappingException when Update()-ing with select-before-update
PostPosted: Wed Aug 02, 2006 3:29 pm 
Beginner
Beginner

Joined: Wed Jul 05, 2006 12:45 pm
Posts: 21
Hello,

I am getting an exception when attempting to "Update()" an entity. This problem can be reproduced by "Update()"-ing an entity which contains a "many-to-one" property, but only when the "select-before-update" option is turned on (and performed).

The problem occurs during the "dirty checking", in the EntityType.GetIdentifier. This is because that method is called on a variable which is already a String identifier itself, in ManyToOneType.IsModified. And i believe that THIS is because the "old" and "current" parameters passed to this class by TypeFactory.FindModified are reversed ("x" and "y"), so that EntityType.GetIdentifier is attempting to resolve the id on the wrong variable.

Below is some information requested by your posting guidelines which seemed relevant:

Hibernate version:
1.2.0.Alpha1-debug

Full stack trace of any exception that occurs:
NHibernate.MappingException was unhandled by user code
Message="Unknown entity class: System.String"
Source="NHibernate"
StackTrace:
at NHibernate.Impl.SessionFactoryImpl.GetEntityPersister(Type theClass) in c:\net\nhibernate\nhibernate\src\NHibernate\Impl\SessionFactoryImpl.cs:line 563
at NHibernate.Impl.SessionImpl.GetClassPersister(Type theClass) in c:\net\nhibernate\nhibernate\src\NHibernate\Impl\SessionImpl.cs:line 3489
at NHibernate.Impl.SessionImpl.GetEntityPersister(Object obj) in c:\net\nhibernate\nhibernate\src\NHibernate\Impl\SessionImpl.cs:line 3497
at NHibernate.Impl.SessionImpl.GetEntityIdentifierIfNotUnsaved(Object obj) in c:\net\nhibernate\nhibernate\src\NHibernate\Impl\SessionImpl.cs:line 3613
at NHibernate.Type.EntityType.GetIdentifier(Object value, ISessionImplementor session) in c:\net\nhibernate\nhibernate\src\NHibernate\Type\EntityType.cs:line 60
at NHibernate.Type.ManyToOneType.IsModified(Object old, Object current, Boolean[] checkable, ISessionImplementor session) in c:\net\nhibernate\nhibernate\src\NHibernate\Type\ManyToOneType.cs:line 112
at NHibernate.Type.TypeFactory.FindModified(StandardProperty[] properties, Object[] x, Object[] y, Boolean[][] includeColumns, Boolean anyUninitializedProperties, ISessionImplementor session) in c:\net\nhibernate\nhibernate\src\NHibernate\Type\TypeFactory.cs:line 988
at NHibernate.Persister.Entity.AbstractEntityPersister.FindModified(Object[] old, Object[] current, Object obj, ISessionImplementor session) in c:\net\nhibernate\nhibernate\src\NHibernate\Persister\Entity\AbstractEntityPersister.cs:line 311
at NHibernate.Impl.SessionImpl.FlushEntity(Object obj, EntityEntry entry) in c:\net\nhibernate\nhibernate\src\NHibernate\Impl\SessionImpl.cs:line 3263
at NHibernate.Impl.SessionImpl.FlushEntities() in c:\net\nhibernate\nhibernate\src\NHibernate\Impl\SessionImpl.cs:line 3200
at NHibernate.Impl.SessionImpl.FlushEverything() in c:\net\nhibernate\nhibernate\src\NHibernate\Impl\SessionImpl.cs:line 2953
at NHibernate.Impl.SessionImpl.Flush() in c:\net\nhibernate\nhibernate\src\NHibernate\Impl\SessionImpl.cs:line 2929
at NHibernate.Transaction.AdoTransaction.Commit() in c:\net\nhibernate\nhibernate\src\NHibernate\Transaction\AdoTransaction.cs:line 141
at DFWHC.GroupOne.GoRes.business.DivisionFactory.UpdateDivision(Division division) in C:\Development\dfw_hospital\GroupOne\GoRes\library\business\DivisionFactory.cs:line 72
at EditDivision.Update(Object src, EventArgs args) in c:\Development\dfw_hospital\GroupOne\GoRes\website\user\employee\admin\EditDivision.aspx.cs:line 135
at System.Web.UI.WebControls.Button.OnClick(EventArgs e)
at System.Web.UI.WebControls.Button.RaisePostBackEvent(String eventArgument)
at System.Web.UI.WebControls.Button.System.Web.UI.IPostBackEventHandler.RaisePostBackEvent(String eventArgument)
at System.Web.UI.Page.RaisePostBackEvent(IPostBackEventHandler sourceControl, String eventArgument)
at System.Web.UI.Page.RaisePostBackEvent(NameValueCollection postData)
at System.Web.UI.Page.ProcessRequestMain(Boolean includeStagesBeforeAsyncPoint, Boolean includeStagesAfterAsyncPoint)

I think that I was able to solve the issue by making a small change in [iTypeFactory.FindModified()[/i], line 991. By reordering the parameters correctly in TypeFactory.FindModified (swapping "x" and "y" around), the framework now resolves the id of the correct (entity) variable. But I want to check on the forum if this is correct, and if I need to post a bug report in JIRA.

Thank you for looking into this.

Sincerely,

-Sasha Borodin


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

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.