-->
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.  [ 6 posts ] 
Author Message
 Post subject: id mapping type mismatch
PostPosted: Tue Jun 13, 2006 9:29 am 
Regular
Regular

Joined: Thu May 11, 2006 12:30 pm
Posts: 72
Need help with Hibernate? Read this first:
http://www.hibernate.org/ForumMailingli ... AskForHelp

Hibernate version: 1.0.2

Mapping documents:

<id name='ID' column='DBKEY'>
<generator class='assigned' />
</id>

--> in my table DBKEY is NUMBER 8

C# code:

// definition

private int m_id;
public int ID
{
get { return m_id; }
set { m_id = value; }
}

// code that generate error

MyClass myclass = new MyClass();
myclass.ID = int.Parse(txtNumber.Text);
myclass = (MyClass)this.m_session.Get(typeof(MyClass),myclass); // exception here!

--> i tried even defining ID as long but i got the same error

Full stack trace of any exception that occurs:
Message : identifier type mismatch
Parameter name: id

Stack trace :
in NHibernate.Engine.Key..ctor(Object id, IType identifierType, Object identifierSpace, Type clazz, Boolean isBatchLoadable)
in NHibernate.Engine.Key..ctor(Object id, IClassPersister p)
in NHibernate.Impl.SessionImpl.DoLoad(Type theClass, Object id, Object optionalObject, LockMode lockMode, Boolean checkDeleted)
in NHibernate.Impl.SessionImpl.DoLoadByClass(Type clazz, Object id, Boolean checkDeleted, Boolean allowProxyCreation)
in NHibernate.Impl.SessionImpl.Get(Type clazz, Object id)
in CUP.frmReservation.mtxtPatient_Leave(Object sender, EventArgs e) in C:\Documents and Settings\luke\Desktop\CUP\CUP\frmReservation.cs:riga 139
in System.Windows.Forms.Control.OnLeave(EventArgs e)
in System.Windows.Forms.Control.NotifyLeave()
in System.Windows.Forms.ContainerControl.UpdateFocusedControl()
in System.Windows.Forms.ContainerControl.AssignActiveControlInternal(Control value)
in System.Windows.Forms.ContainerControl.ActivateControlInternal(Control control, Boolean originator)
in System.Windows.Forms.ContainerControl.SetActiveControlInternal(Control value)
in System.Windows.Forms.ContainerControl.SetActiveControl(Control ctl)
in System.Windows.Forms.ContainerControl.set_ActiveControl(Control value)
in System.Windows.Forms.Control.Select(Boolean directed, Boolean forward)
in System.Windows.Forms.Control.SelectNextControl(Control ctl, Boolean forward, Boolean tabStopOnly, Boolean nested, Boolean wrap)
in System.Windows.Forms.Form.ProcessTabKey(Boolean forward)
in System.Windows.Forms.ContainerControl.ProcessDialogKey(Keys keyData)
in System.Windows.Forms.Form.ProcessDialogKey(Keys keyData)
in System.Windows.Forms.Control.ProcessDialogKey(Keys keyData)
in System.Windows.Forms.TextBoxBase.ProcessDialogKey(Keys keyData)
in System.Windows.Forms.Control.PreProcessMessage(Message& msg)
in System.Windows.Forms.Control.PreProcessControlMessageInternal(Control target, Message& msg)
in System.Windows.Forms.Application.ThreadContext.PreTranslateMessage(MSG& msg)
in System.Windows.Forms.Application.ThreadContext.System.Windows.Forms.UnsafeNativeMethods.IMsoComponent.FPreTranslateMessage(MSG& msg)
in System.Windows.Forms.Application.ComponentManager.System.Windows.Forms.UnsafeNativeMethods.IMsoComponentManager.FPushMessageLoop(Int32 dwComponentID, Int32 reason, Int32 pvLoopData)
in System.Windows.Forms.Application.ThreadContext.RunMessageLoopInner(Int32 reason, ApplicationContext context)
in System.Windows.Forms.Application.ThreadContext.RunMessageLoop(Int32 reason, ApplicationContext context)
in System.Windows.Forms.Form.ShowDialog(IWin32Window owner)
in CUP.frmMain.kbConfirm_Click(Object sender, EventArgs e) in C:\Documents and Settings\luke\Desktop\CUP\CUP\frmMain.cs:riga 469
in System.Windows.Forms.Control.OnClick(EventArgs e)
in ComponentFactory.Krypton.Toolkit.KryptonButton.OnClick(EventArgs e)
in ComponentFactory.Krypton.Toolkit.KryptonButton.OnButtonClick(Object sender, MouseEventArgs e)
in ComponentFactory.Krypton.Toolkit.ButtonController.OnClick(MouseEventArgs e)
in ComponentFactory.Krypton.Toolkit.ButtonController.MouseUp(Control c, Point pt, MouseButtons button)
in ComponentFactory.Krypton.Toolkit.ViewBase.MouseUp(Control c, Point pt, MouseButtons button)
in ComponentFactory.Krypton.Toolkit.ViewBase.MouseUp(Control c, Point pt, MouseButtons button)
in ComponentFactory.Krypton.Toolkit.ViewBase.MouseUp(Control c, Point pt, MouseButtons button)
in ComponentFactory.Krypton.Toolkit.ViewManager.MouseUp(MouseEventArgs e)
in ComponentFactory.Krypton.Toolkit.VisualControl.OnMouseUp(MouseEventArgs e)
in System.Windows.Forms.Control.WmMouseUp(Message& m, MouseButtons button, Int32 clicks)
in System.Windows.Forms.Control.WndProc(Message& m)
in System.Windows.Forms.Control.ControlNativeWindow.OnMessage(Message& m)
in System.Windows.Forms.Control.ControlNativeWindow.WndProc(Message& m)
in System.Windows.Forms.NativeWindow.DebuggableCallback(IntPtr hWnd, Int32 msg, IntPtr wparam, IntPtr lparam)
in System.Windows.Forms.UnsafeNativeMethods.DispatchMessageW(MSG& msg)
in System.Windows.Forms.Application.ComponentManager.System.Windows.Forms.UnsafeNativeMethods.IMsoComponentManager.FPushMessageLoop(Int32 dwComponentID, Int32 reason, Int32 pvLoopData)
in System.Windows.Forms.Application.ThreadContext.RunMessageLoopInner(Int32 reason, ApplicationContext context)
in System.Windows.Forms.Application.ThreadContext.RunMessageLoop(Int32 reason, ApplicationContext context)
in System.Windows.Forms.Application.Run(Form mainForm)
in CUP.Program.Main() in C:\Documents and Settings\luke\Desktop\CUP\CUP\Program.cs:riga 19
in System.AppDomain.nExecuteAssembly(Assembly assembly, String[] args)
in System.AppDomain.ExecuteAssembly(String assemblyFile, Evidence assemblySecurity, String[] args)
in Microsoft.VisualStudio.HostingProcess.HostProc.RunUsersAssembly()
in System.Threading.ThreadHelper.ThreadStart_Context(Object state)
in System.Threading.ExecutionContext.Run(ExecutionContext executionContext, ContextCallback callback, Object state)
in System.Threading.ThreadHelper.ThreadStart()

Name and version of the database you are using:Oracle 10g


Top
 Profile  
 
 Post subject:
PostPosted: Tue Jun 13, 2006 10:12 am 
Expert
Expert

Joined: Fri May 13, 2005 5:56 pm
Posts: 308
Location: Santa Barbara, California, USA
hmmm, i'm not even sure your code would work because you're trying to assign an NH persistent object to an object that you are using in to instantiate itself???

assuming you could, you can't load the class by sending the class as a param, you have to send the class.ID as the param:

Code:
myclass = (MyClass)this.m_session.Get(typeof(MyClass),myclass);


becomes:

Code:
myclass = (MyClass)this.m_session.Get(typeof(MyClass),myclass.ID);


-devon


Top
 Profile  
 
 Post subject: the same
PostPosted: Tue Jun 13, 2006 10:23 am 
Regular
Regular

Joined: Thu May 11, 2006 12:30 pm
Posts: 72
sorry duplicated


Last edited by berets on Tue Jun 13, 2006 10:25 am, edited 1 time in total.

Top
 Profile  
 
 Post subject: the same
PostPosted: Tue Jun 13, 2006 10:24 am 
Regular
Regular

Joined: Thu May 11, 2006 12:30 pm
Posts: 72
i'd already tried but i got this exception

{"could not load: [MyNamespace.MyClass#615]"}

615 is the value i've entered from textbox


Stack trace :

    in System.Number.StringToNumber(String str, NumberStyles options, NumberBuffer& number, NumberFormatInfo info, Boolean parseDecimal)
    in System.Number.ParseInt32(String s, NumberStyles style, NumberFormatInfo info)
    in System.String.System.IConvertible.ToInt32(IFormatProvider provider)
    in System.Convert.ToInt32(Object value)
    in NHibernate.Type.Int32Type.Get(IDataReader rs, Int32 index)
    in NHibernate.Type.NullableType.NullSafeGet(IDataReader rs, String name)
    in NHibernate.Type.NullableType.NullSafeGet(IDataReader rs, String[] names, ISessionImplementor session, Object owner)
    in NHibernate.Type.AbstractType.Hydrate(IDataReader rs, String[] names, ISessionImplementor session, Object owner)
    in NHibernate.Loader.Loader.Hydrate(IDataReader rs, Object id, Object obj, ILoadable persister, ISessionImplementor session, String[][] suffixedPropertyColumns)
    in NHibernate.Loader.Loader.LoadFromResultSet(IDataReader rs, Int32 i, Object obj, Key key, String suffix, LockMode lockMode, ILoadable rootPersister, ISessionImplementor session)
    in NHibernate.Loader.Loader.InstanceNotYetLoaded(IDataReader dr, Int32 i, ILoadable persister, String suffix, Key key, LockMode lockMode, Key optionalObjectKey, Object optionalObject, IList hydratedObjects, ISessionImplementor session)
    in NHibernate.Loader.Loader.GetRow(IDataReader rs, ILoadable[] persisters, String[] suffixes, Key[] keys, Object optionalObject, Key optionalObjectKey, LockMode[] lockModes, IList hydratedObjects, ISessionImplementor session)
    in NHibernate.Loader.Loader.GetRowFromResultSet(IDataReader resultSet, ISessionImplementor session, QueryParameters queryParameters, IList hydratedObjects, Object optionalObject, Object optionalId, Key[] keys, Boolean returnProxies)
    in NHibernate.Loader.Loader.DoQuery(ISessionImplementor session, QueryParameters queryParameters, Object optionalObject, Object optionalId, Object[] optionalCollectionKeys, Boolean returnProxies)
    in NHibernate.Loader.Loader.DoQueryAndInitializeNonLazyCollections(ISessionImplementor session, QueryParameters queryParameters, Object optionalObject, Object optionalId, Object[] optionalCollectionKeys, Boolean returnProxies)
    in NHibernate.Loader.Loader.LoadEntity(ISessionImplementor session, Object[] values, IType[] types, Object optionalObject, Object optionalID)
    in NHibernate.Loader.Loader.LoadEntity(ISessionImplementor session, Object id, IType identifierType, Object optionalObject, Object optionalIdentifier)
    in NHibernate.Loader.EntityLoader.Load(ISessionImplementor session, Object id, Object optionalObject, Object optionalId)
    in NHibernate.Loader.EntityLoader.Load(ISessionImplementor session, Object id, Object optionalObject)
    in NHibernate.Persister.EntityPersister.Load(Object id, Object optionalObject, LockMode lockMode, ISessionImplementor session)


---

now i changed my C# code :

Code:
MyClass parmClass = new MyClass();
            parmClass.ID = int.Parse(txtValue.Text);
            MyClass myclass = (MyClass)this.m_session.Get(typeof(MyClass),parmClass.ID);


Top
 Profile  
 
 Post subject:
PostPosted: Tue Jun 13, 2006 10:33 am 
Expert
Expert

Joined: Fri May 13, 2005 5:56 pm
Posts: 308
Location: Santa Barbara, California, USA
try running the generated SQL in your Oracle Query Tool to see if the SQL returns data.


Top
 Profile  
 
 Post subject: the same
PostPosted: Tue Jun 13, 2006 11:09 am 
Regular
Regular

Joined: Thu May 11, 2006 12:30 pm
Posts: 72
sorry was a misconfigured property...=)

thanks a lot


Top
 Profile  
 
Display posts from previous:  Sort by  
Forum locked This topic is locked, you cannot edit posts or make further replies.  [ 6 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.