Querying @BasicMap values?

View: New views
4 Messages — Rating Filter:   Alert me  

Querying @BasicMap values?

by Ari Heino :: Rate this Message:

Reply to Author | View Threaded | Show Only this Message

Hi!

Tried to search answer for this one and found none yet.

So... I would need to find entity that has a certain value inside the hashmap defined with @BasicMap . How would that kind of query look like in eclipselink QL?

Would i just input hashmap with wanted key-value into query as a query parameter or would I need to use sql joins or what?

Entity in question:

@Entity
@Table(name = "CONTAINER_METADATA", uniqueConstraints = { @UniqueConstraint(columnNames = { "name" }) })
public class Container
    implements Serializable {

    @Id
    @GeneratedValue
    private Long id;
    @Basic
    private String name;

    @BasicMap(fetch = FetchType.EAGER, keyColumn = @Column(name = "MAPKEY", length = 256, unique = true), valueColumn = @Column(name = "MAPVALUE", length = 3999))
    @CollectionTable(name = "CONTAINER_ARBITRARY_METADATA", primaryKeyJoinColumns = { @PrimaryKeyJoinColumn(name = "CONTAINER_ID") })
    private Map<String, String> metadatas;

  .... getters and setters
}

Re: Querying @BasicMap values?

by Ari Heino :: Rate this Message:

Reply to Author | View Threaded | Show Only this Message

Ah, finally found response (related to collections, not maps) that propably solves my issue as well:

http://www.nabble.com/questiona-about-JPQL-and-Collections-td21706323.html

Re: Querying @BasicMap values?

by Ari Heino :: Rate this Message:

Reply to Author | View Threaded | Show Only this Message


Ari Heino wrote:
Ah, finally found response (related to collections, not maps) that propably solves my issue as well:

http://www.nabble.com/questiona-about-JPQL-and-Collections-td21706323.html
Well, that did not help at all, maps being different than lists/sets.

So, any help with creating a query to BasicMap would still be greatly appriciated.

Re: Querying @BasicMap values?

by Ari Heino :: Rate this Message:

Reply to Author | View Threaded | Show Only this Message

Well, using milestone 9 JPA 2.0 release of EclipseLink helped.

Map queries are supported with it and working nicely.