[hibernate-issues] [Hibernate-JIRA] Commented: (HHH-2235) Support for null map-keys in <map> mappings

Igor Lobanov (JIRA) noreply at atlassian.com
Mon Nov 13 08:32:04 EST 2006


    [ http://opensource.atlassian.com/projects/hibernate/browse/HHH-2235?page=comments#action_25252 ] 

Igor Lobanov commented on HHH-2235:
-----------------------------------

What about example, given in section 6.3.3 (Bidirectional associations with indexed collections) of the Hibernate manual?

<class name="Parent">
    <id name="id" column="parent_id"/>
    ....
    <map name="children" inverse="true">
        <key column="parent_id"/>
        <map-key column="name" type="string"/>
        <one-to-many class="Child"/>
    </map>
</class>

Column 'name' is not a primary key. It is just regular database column. It is not required to be null by anything but AbstractCollectionPersister#readIndex(...) implementation. What if I want to add support for children without name?

> Support for null map-keys in <map> mappings
> -------------------------------------------
>
>          Key: HHH-2235
>          URL: http://opensource.atlassian.com/projects/hibernate/browse/HHH-2235
>      Project: Hibernate3
>         Type: Bug

>   Components: core
>     Versions: 3.2.0.ga
>     Reporter: Igor Lobanov
>     Priority: Minor

>
>
> I'm not sure if I should file it as a bug.
> Hibernate requires index column for <map> mappings to be not null. This is required by the code in AbstractCollectionPersister#readIndex(...), which raises exception if index column is null. However, when I override collection persister and force readIndex method to return null, everything seems to work fine. Hibernate allows me to work with maps using null value as a key. Though I havn't tested it extensivly yet.
> What is the reason for disallowing null values as a keys? If there are possible complicated error conditions, then this issue is a feature request for null-values support for <map> mappings. If there are no errors possible, then constraining such behavior is probably wrong. 

-- 
This message is automatically generated by JIRA.
-
If you think it was sent incorrectly contact one of the administrators:
   http://opensource.atlassian.com/projects/hibernate/secure/Administrators.jspa
-
For more information on JIRA, see:
   http://www.atlassian.com/software/jira




More information about the hibernate-issues mailing list