-->
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.  [ 2 posts ] 
Author Message
 Post subject: NHibernate's generated proxy error
PostPosted: Mon Apr 02, 2007 6:41 am 
Newbie

Joined: Sat Sep 23, 2006 7:43 pm
Posts: 2
Hello,

We're having some problems with the proxies NHibernate generates.

All our mapped entities inherit from a generic class DomainEntity<T>:
Code:
    public abstract class DomainEntity<T>
    {
        private T _id = default(T);
        public virtual T Id
        {
            get { return _id; }
            set { _id = value; }
        }

        public abstract String Label { get; }

        /// <summary>
        /// Equals
        /// </summary>
        /// <param name="other"></param>
        /// <returns></returns>
        public override bool Equals(object other)
        {
            if (this == other)
                return true;
            if (!GetType().Equals(other.GetType()))
                return false;

            DomainEntity<T> otherAsDomain = other as DomainEntity<T>;

            if (otherAsDomain == null)
                return false;
            if (otherAsDomain.Id == null)
                return false;
            if (Id == null)
                return false;

            if ((Id.Equals(default(T))) || (otherAsDomain.Id.Equals(default(T))))
                return false;

            return _id.Equals(otherAsDomain.Id);
        }

        /// <summary>
        /// GetHashCode
        /// </summary>
        /// <returns></returns>
        public override int GetHashCode()
        {
            unchecked
            {
                int result;
                result = Id.GetHashCode();
                result = 29 * result;
                return result;
            }
        }
    }



We're getting some errors like this:

[ArgumentException: No se puede resolver el método Int32 GetHashCode() porque el tipo declarativo del identificador de método M2.Domain.DomainEntity`1[T] es genérico. Proporcione explícitamente el tipo declarativo a GetMethodFromHandle. ]
System.Reflection.MethodBase.GetMethodFromHandle(RuntimeMethodHandle handle) +2336241
CProxyTypePostalAddressEntityDomain_INHibernateProxy_ISerializable2.GetHashCode() +61
System.ComponentModel.WeakKeyComparer.System.Collections.IEqualityComparer.GetHashCode(Object obj) +28
System.Collections.Hashtable.GetHash(Object key) +16
System.Collections.Hashtable.get_Item(Object key) +67
System.ComponentModel.TypeDescriptor.NodeFor(Object instance, Boolean createDelegator) +46
System.ComponentModel.TypeDescriptor.NodeFor(Object instance) +27
System.ComponentModel.TypeDescriptor.GetDescriptor(Object component, Boolean noCustomTypeDesc) +247
System.ComponentModel.TypeDescriptor.GetPropertiesImpl(Object component, Attribute[] attributes, Boolean noCustomTypeDesc, Boolean noAttributes) +132
System.ComponentModel.TypeDescriptor.GetProperties(Object component, Boolean noCustomTypeDesc) +36
System.ComponentModel.TypeDescriptor.GetProperties(Object component) +27
System.Web.UI.DataBinder.GetPropertyValue(Object container, String propName) +150
System.Web.UI.DataBinder.GetPropertyValue(Object container, String propName, String format) +32
System.Web.UI.WebControls.ListControl.PerformDataBinding(IEnumerable dataSource) +460
System.Web.UI.WebControls.ListControl.OnDataBinding(EventArgs e) +79
System.Web.UI.WebControls.ListControl.PerformSelect() +32
System.Web.UI.WebControls.BaseDataBoundControl.DataBind() +99
Customer_Edit.InitializeModel() in c:\Proyectos\M2\bss\trunk\dotnet\src\M2.Web.Backoffice\Customer\Edit.aspx.cs:227
Spring.Web.UI.Page.OnInit(EventArgs e) +81
System.Web.UI.Control.InitRecursive(Control namingContainer) +459
System.Web.UI.Page.ProcessRequestMain(Boolean includeStagesBeforeAsyncPoint, Boolean includeStagesAfterAsyncPoint) +1742

(The message says in spanish that the "Int32 GetHashCode()" cannot be resolved because the declaring type is generic, and that it should be resolved by passing the declarative type to GetMethodFromHandle).


Top
 Profile  
 
 Post subject:
PostPosted: Mon Apr 02, 2007 7:03 am 
Contributor
Contributor

Joined: Wed May 11, 2005 4:59 pm
Posts: 1766
Location: Prague, Czech Republic
Please submit this to JIRA with a test case.


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