]
Gail Badner resolved HHH-3178.
------------------------------
Assignee: Gail Badner
Resolution: Rejected
You are using <map ... inverse="true" ...> on a unidirectional
association. Using inverse="true" only makes sense for bidirectional
associations. You should be using the default or inverse="false".
In the future, please use the user forum (
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: