Hello,
I am having trouble querying enumerated Map attributes using EclipseLink 2.1. Here is some detail regarding to mapping
@ElementCollection
@CollectionTable(name = "MAP_TABLE", joinColumns = @JoinColumn(name = "ME_ID"))
@MapKeyEnumerated(EnumType.STRING)
@MapKeyColumn(name = "KEY_NAME")
@Column(name = "KEY_VALUE")
private Map<MyCustomEnumType, String> mapAttr;
When I executed the following query, I don’t get any exception but there is no record being returned even though there are data in the database that fits the criteria
Query q = em.createQuery("select KEY(p) from myObject me join me.mapAttr p where KEY(p) = :param1");
q.setParameter("param1", MyCustomEnumType.enum1);
List l = q.getResultList();
System.out.println("Size:::" + l.size() + " --- Value::" + l.toString());
However, if I persist EnumType.ORDINAL instead EnumType.STRING in the @MapKeyEnumerated then the same query works fine - returns the right set of data back. I have tried to use name() method to make sure that a STRING value of enum would use inside the query but I have exceptions. Do you have any idea what I am missing here?
Thanks
Aysun