It's my first post here and I'm not sure if it's a correct forum to ask... if not, please forgive me...
I have found a problem I cannot solve by myself.
I've created an Entity - Employee that has Map<String, String> phoneNumbers
Code: Select all
//...
@ElementCollection
@CollectionTable(name="EMP_PHONE")
@MapKeyColumn(name="PHONE_TYPE")
@Column(name="PHONE_NUM")
private Map<String, String> phoneNumbers;
//...
I'm trying with JPQL query:
Code: Select all
Query q = em.createQuery("Select NEW entities.Phone(VALUE(p), KEY(p)) from Employee e JOIN e.phoneNumbers p");
I have tried to:Local Exception Stack:
Exception [EclipseLink-6168] (Eclipse Persistence Services - 2.5.1.v20130918-f2b9fc5): org.eclipse.persistence.exceptions.QueryException
Exception Description: Query failed to prepare, unexpected error occurred: [java.lang.ClassCastException: org.eclipse.persistence.mappings.DirectToFieldMapping cannot be cast to
org.eclipse.persistence.mappings.CollectionMapping].
Internal Exception: java.lang.ClassCastException: org.eclipse.persistence.mappings.DirectToFieldMapping cannot be cast to org.eclipse.persistence.mappings.CollectionMapping
- * not use construct expression - works OK, got a List of Object[]
* use construct with VALUE(p) and other Sstring - works OK, got a List of Phone
* use construct with KEY(p) and other String - not working
- *Use different provider - is it worth trying?
*Use Queries - to be done soon
Could anyone give me a hint how to get a list of new objects created from map key and map value?