[
Date Prev][
Date Next][
Thread Prev][
Thread Next][
Date Index][
Thread Index]
[
List Home]
| 
Re: [eclipselink-users] Query with enum KEY
 | 
ENTRY will get the key and the value in a map entry... something like:
select ENTRY(p)  from myObject me....
Alay, Aysun wrote:
Hi Tom,
I am very new to Eclipse and JPA so what do you mean by "selecting ENTRY"?
Thanks,
aysun
-----Original Message-----
From: eclipselink-users-bounces@xxxxxxxxxxx [mailto:eclipselink-users-bounces@xxxxxxxxxxx] On Behalf Of Tom Ware
Sent: Wednesday, February 23, 2011 10:50 AM
To: EclipseLink User Discussions
Subject: Re: [eclipselink-users] Query with enum KEY
It appears as though this is a bug.  Please file a bug.
You may be able to work around this issue by either selecting ENTRY, or by using 
native sql.
-Tom
Alay, Aysun wrote:
Hi Tom,
Thanks for the reply.
Yes the SQL seems to be correct. The bind value is an Enum String and when I run SQL separately, It returns the right results. 
SELECT t0.NAME, t1.KEY_NAME FROM TABLE1 t0, MAP_TABLE t1 WHERE ((t1.KEY_NAME = ?) AND (t1.ME_ID = t0.ID))
	bind => [ENUM1]
This message is also printed but don't think it is related 
[EL Finest]: 2011-02-23 09:27:32.32--ServerSession(15232416)--Connection(32278793)--Thread(Thread[main,5,main])--Truncated incorrect DOUBLE value: ??:HY000 - null
Aysun
-----Original Message-----
From: eclipselink-users-bounces@xxxxxxxxxxx [mailto:eclipselink-users-bounces@xxxxxxxxxxx] On Behalf Of Tom Ware
Sent: Wednesday, February 23, 2011 9:22 AM
To: EclipseLink User Discussions
Subject: 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
_______________________________________________
eclipselink-users mailing list
eclipselink-users@xxxxxxxxxxx
https://dev.eclipse.org/mailman/listinfo/eclipselink-users
_______________________________________________
eclipselink-users mailing list
eclipselink-users@xxxxxxxxxxx
https://dev.eclipse.org/mailman/listinfo/eclipselink-users
_______________________________________________
eclipselink-users mailing list
eclipselink-users@xxxxxxxxxxx
https://dev.eclipse.org/mailman/listinfo/eclipselink-users
_______________________________________________
eclipselink-users mailing list
eclipselink-users@xxxxxxxxxxx
https://dev.eclipse.org/mailman/listinfo/eclipselink-users