castor
  1. castor
  2. CASTOR-1915

Integer as Map key is displayed as String

    Details

    • Type: Bug Bug
    • Status: Closed Closed
    • Priority: Major Major
    • Resolution: Won't Fix
    • Affects Version/s: 1.1
    • Fix Version/s: 1.1.2
    • Component/s: XML
    • Labels:
      None
    • Environment:
      Linux 2.6.9-22.0.2.ELsmp,

      java version "1.5.0_06"
      Java(TM) 2 Runtime Environment, Standard Edition (build 1.5.0_06-b05)
      Java HotSpot(TM) Server VM (build 1.5.0_06-b05, mixed mode)

    • Testcase included:
      yes
    • Number of attachments :
      1

      Description

      A field with type int or Integer is assigned as the key for Map in mapping, but when retrieving the value using int as the key from this map, the returned value is null. After interating through the entry set of the map, the class of the key is displayed as java.lang.String, which is supposed to be java.lang.Integer.

        Activity

        Hide
        Werner Guttmann added a comment -

        It looks like I still do not understand your intentions. The instructions at http://castor.org/how-to-map-a-hashtable.html clearly show how to map a collection with type 'map' or 'hashtable'. What exactly is it that you require to be different from that basic setup ?

        Show
        Werner Guttmann added a comment - It looks like I still do not understand your intentions. The instructions at http://castor.org/how-to-map-a-hashtable.html clearly show how to map a collection with type 'map' or 'hashtable'. What exactly is it that you require to be different from that basic setup ?
        Hide
        Werner Guttmann added a comment -

        Any feedback ?

        Show
        Werner Guttmann added a comment - Any feedback ?
        Hide
        Ma, Xuan added a comment -

        I am sorry, I am busy these days, and I will give my feed back in a few days. Thanks for your patience.

        Show
        Ma, Xuan added a comment - I am sorry, I am busy these days, and I will give my feed back in a few days. Thanks for your patience.
        Hide
        Ma, Xuan added a comment -

        For my example

        xml:

        <parent>
        <child id="1"/>
        <child id="2"/>
        </parent>

        I wanna get he following result, there is a map in class Parent, in this map, the value is the Child class represented by the <child> node, and the key is the id of this child node. For above example,

        1 -> Child class with ID equals to 1
        2 -> Child class with ID equals to 2

        While in the howto, an extra node is added, like below:

        <parent>
        <MyChild id="1">
        <child id="1"/>
        </MyChild>
        <MyChild id="1">
        <child id="2"/>
        </MyChild>
        </parent>

        This is not what I want.

        Am I missing something ??

        Show
        Ma, Xuan added a comment - For my example xml: <parent> <child id="1"/> <child id="2"/> </parent> I wanna get he following result, there is a map in class Parent, in this map, the value is the Child class represented by the <child> node, and the key is the id of this child node. For above example, 1 -> Child class with ID equals to 1 2 -> Child class with ID equals to 2 While in the howto, an extra node is added, like below: <parent> <MyChild id="1"> <child id="1"/> </MyChild> <MyChild id="1"> <child id="2"/> </MyChild> </parent> This is not what I want. Am I missing something ??
        Hide
        Werner Guttmann added a comment -

        I don't think that's actually possible, as in a mapping for a map, you have to provide a MapItem instance (unless you accept default values). Have a look at

        http://svn.castor.codehaus.org/browse/castor/castor/trunk/xmlctf/tests/MasterTestSuite/mapping/collections/Maps

        for several samples related to mapping maps.

        Show
        Werner Guttmann added a comment - I don't think that's actually possible, as in a mapping for a map, you have to provide a MapItem instance (unless you accept default values). Have a look at http://svn.castor.codehaus.org/browse/castor/castor/trunk/xmlctf/tests/MasterTestSuite/mapping/collections/Maps for several samples related to mapping maps.

          People

          • Assignee:
            Werner Guttmann
            Reporter:
            Ma, Xuan
          • Votes:
            0 Vote for this issue
            Watchers:
            0 Start watching this issue

            Dates

            • Created:
              Updated:
              Resolved:

              Time Tracking

              Estimated:
              Original Estimate - 1 hour
              1h
              Remaining:
              Remaining Estimate - 1 hour
              1h
              Logged:
              Time Spent - Not Specified
              Not Specified