PersistentMap.keySet seems to produce a set containing values rather than keys.

Description

I have a persistent Map defined as follows:

@Entity
public class Task {
[snip]
@OneToMany(mappedBy="task")
@MapKey(name="actor")
private Map<Long, TaskCC> ccs = new HashMap<Long, TaskCC>();
}

where

@Entity
public class TaskCC {
@Id
@GeneratedValue
private Long id;

@ManyToOne(fetch=FetchType.LAZY)
private Task task;

@ManyToOne(fetch=FetchType.LAZY)
@AccessType("field")
private Actor actor;
}

and actor is an independent entity (i.e., no associations to Task or TaskCC) with a Long id field.

We have some code that does something like:
ids = new HashSet<Long>(bug.getCcs().keySet());

But the ids set seems to contain the Actors rather than the Actor IDs.

Let me know if the above is not sufficient and/or you want me to create a simplified test case for this.

Environment

Also Hibernate EntityManager 3.4.0 if that is relevant.

Activity

Show:
rufus hamade
July 21, 2010, 3:58 PM

oops, formatting screwy. A lot of the stuff in the description is supposed to be code fragments. Here's the improved version with appropriate markup:

I have a persistent Map defined as follows:

where

and actor is an independent entity (i.e., no associations to Task or TaskCC) with a Long id field.

We have some code that does something like:

But the ids set seems to contain the Actors rather than the Actor IDs.

(p.s., the JIRA wiki code formatting is not very good )

Gail Badner
July 21, 2010, 9:38 PM

Is this still an issue in 3.5.3?

rufus hamade
July 23, 2010, 2:09 PM

Unfortunately, I've changed my code so it doesn't try to do this any more. Using a persistent Map was overkill for my current purposes anyway; I was just using it to ensure each actor was in the list only once. I'll see if I can get a test case running and test it out with the latest Hibernate. It may take me a while though as I am pressed for time at the moment. (Though aren't we all)

Brett Meyer
November 27, 2013, 11:37 PM

no response

Rejected

Assignee

Unassigned

Reporter

rufus hamade

Fix versions

None

Labels

None

backPortable

None

Suitable for new contributors

None

Requires Release Note

None

Pull Request

None

backportDecision

None

Components

Affects versions

Priority

Major
Configure