Skip to main content

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index] [List Home]
Re: [eclipselink-users] Query with enum KEY

Hi,

Try setting persistence property eclipselink.logging.level=FINER and inspect the SQL. Is the SQL what you expect? If you run it separately do you get the results you expect?

-Tom

Alay, Aysun wrote:
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


------------------------------------------------------------------------

_______________________________________________
eclipselink-users mailing list
eclipselink-users@xxxxxxxxxxx
https://dev.eclipse.org/mailman/listinfo/eclipselink-users


Back to the top