[hibernate-issues] [Hibernate-JIRA] Commented: (HHH-3178) Disappearing values for a managed Map

Peter Aarestad (JIRA) noreply at atlassian.com
Fri Mar 14 16:18:33 EDT 2008


    [ http://opensource.atlassian.com/projects/hibernate/browse/HHH-3178?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel#action_29809 ] 

Peter Aarestad commented on HHH-3178:
-------------------------------------

For what it's worth, this IS a bidirectional association, so using "inverse='true'" is appropriate.

> Disappearing values for a managed Map
> -------------------------------------
>
>                 Key: HHH-3178
>                 URL: http://opensource.atlassian.com/projects/hibernate/browse/HHH-3178
>             Project: Hibernate3
>          Issue Type: Bug
>    Affects Versions: 3.2.6
>         Environment: Hibernate 3.2.6, Microsoft SQL Server 2005
>            Reporter: Peter Aarestad
>            Assignee: Gail Badner
>
> My mapping looks like this (obfuscated but functionally equivalent):
> {code}
> <hibernate-mapping package="foo.bar.blah">
>     <class name="PaperTypes" table="PaperTypes" lazy="false">
>         <id name="paperTypeId" column="paperTypeID">
>             <generator class="native" />
>         </id>
>        <!-- other properties -->
>         
>         <map name="weightsAvailable" table="PaperWeightsAvailable" 
>         	inverse="true" lazy="false" 
>         	cascade="all-delete-orphan">
>         	<key column="fk_paperTypeID" />
>         	<map-key-many-to-many class="PaperWeight" column="fk_paperWeightID" />
>         	<one-to-many class="PaperWeightsAvailable" />
>         </map>
>     </class>
> </hibernate-mapping>
> {code}
> For at least one version of the PaperTypes object, I'm getting an issue where, when you examine the "weightsAvailable" Map, you see that it is paired correctly with a PaperWeightsAvailable object, but get() comes back null. So this code dies:
> {code}
> // 'map' is the Hibernate map
> Map<Integer, Set<Integer>> deflated = new Hashtable<Integer, Set<Integer>>();
> Set<PaperWeight> keys = new TreeSet<PaperWeight>(workingMap.keySet());
> for (PaperWeight pw : keys) {
> 	    Set<Integer> set = new TreeSet<Integer>();
> 		// This is where it dies: workingMap.get(pw) should NEVER come back null, but it does sometimes...
> 		for (PaperSizes ps : workingMap.get(pw).getSizesAvailable()) {
> 			set.add(ps.getPaperSizeId());
> 		}
> 		deflated.put(pw.getPaperWeightId(), set);
> }
> {code}
> I worked around this bug by creating a new HashMap based on the Hibernate map:
> {code}
> Map<PaperWeight, PaperWeightsAvailable> workingMap = new HashMap<PaperWeight, PaperWeightsAvailable>(map);
> {code}
> but that should not be necssarily obviouisly.

-- 
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