Question

I have the class structure like this:

Class A {

    private HashMap<\String, B> someFieldMap = // Retrieves some map

    //getter for someFieldMap

    //setter for someFieldMap

}

B is a custom class with the following structure.

class B {

    private String type;
    private String value;

    //getters and setters for the above fields

}

Now, I'm trying to write a HQL to retrieve the value in class B

select value(fieldMap) from A a join a.someFieldMap fieldMap
where index(fieldMap) = 'xyz' //index(fieldMap) will give me the Key of the map.

value(fieldMap) gives me the entire object of instance B. so it will give me the whole object whose type is B.

I want to select b.value and b.type through the select clause.

I tried (value(fieldMap)).value, (value(fieldMap)).getValue() but it doesn't work. I tried to search this up but couldn't find anything.

Was it helpful?

Solution

Try this:

SELECT fieldMap.value, fieldMap.type
FROM A a join a.someFieldMap fieldMap
WHERE index(fieldMap) = 'xyz'
Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top