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: Misleading exception when <property/> maps to System.O
PostPosted: Fri Sep 21, 2007 11:22 am 
Newbie

Joined: Fri Sep 21, 2007 10:46 am
Posts: 1
When a <property/> maps to a property of type System.Object, a MappingException is thrown with the message:

Quote:
"property mapping has wrong number of columns: SillyClass.UntypedPropertyConfusesMapping.SillyClass type: Object"


Reproduce with the following mapping/class snippets. I specificaly post this in vb.net because it is very easy to forget to include a type at the end of a property decleration.

SillyClass.vb:
Code:
Public Class SillyClass
    Private _good As Integer
    Private _bad As Integer
    Public Property Good() As Integer
        Get
            Return _good
        End Get
        Set(ByVal value As Integer)
            _good = value
        End Set
    End Property
    Public Property Bad() 'whoops, forget "As Integer"
        Get
            Return _bad
        End Get
        Set(ByVal value)
            _bad = value
        End Set
    End Property
End Class


SillyClass.hbm.xml:
Code:
<?xml version="1.0" encoding="utf-8" ?>
<hibernate-mapping
    xmlns="urn:nhibernate-mapping-2.2"
    assembly="UntypedPropertyConfusesMapping"
    namespace="UntypedPropertyConfusesMapping">
  <class name="SillyClass" table="SillyTable">
    <id name="Good" column="good">
      <generator class="assigned" />
    </id>
    <property name="Bad" column="bad" />
  </class>
</hibernate-mapping>


Based on the exception message, it is very difficult to determine the actual cause of the problem. A better exception might include:
- The property name, either from the mapping file or the class
- That the 'object' type is not valid.

Comments? Should I add this as a bug in JIRA? Thanks!

Nick


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.