Having a bit of trouble using entities as map keys. Maybe I'm being stupid but can anyone explain the following?
====
mappping
====
Code:
@OneToMany(cascade = CascadeType.ALL)
@JoinColumn(name = "course_id", nullable = false)
@ForeignKey(name = "course_tee_sets_courses_fk")
@MapKey(name = "teeType")
private Map<TeeType, CourseTeeSet> courseTees;
====
test
====
Code:
Course course = dao.loadCourse(1);
// setComplete();
Iterator<TeeType> types = course.getCourseTees().keySet().iterator();
while(types.hasNext())
{
TeeType type = types.next();
if(type.equals(TeeType.MEDAL))
{
System.out.println(type.getName() + "::" + type.equals(TeeType.MEDAL));
System.out.println(type.hashCode() + "::" + TeeType.MEDAL.hashCode());
System.out.println(type.hashCode() == TeeType.MEDAL.hashCode());
System.out.println(type.equals(TeeType.MEDAL));
System.out.println("HAS KEY::" + course.getCourseTees().containsKey(TeeType.MEDAL)); /*RETURNS FALSE*/
}
}
====
output
====
Code:
Medal::true
74219223::74219223
true
true
HAS KEY::false