Hi colleagues,
I have an Entity with a property of type map, like so:
Code:
@org.hibernate.annotations.CollectionOfElements
@JoinTable(name="E_CUSTOM_ATTR", joinColumns={@JoinColumn(name="E_ID")})
@org.hibernate.annotations.MapKey(columns=@Column(name="NAME", nullable=false))
@Column(name="VALUE", nullable=false)
private Map<String, String> customAttribute;
I know (and value) that I can write a HQL query for instances of my Entity with a givenValue under a specificKey in the map, e.g.
Code:
from Entity entity where entity.customAttribute['specificKey'] = :givenValue
My question is: Is there a way to write a HQL report query that selects values under a specificKey without returning the instantiated entity?
In other words, I would like to write a HQL query that works like
Code:
select customAttribute['specificKey'] from Entity where ...
but this is not supported by HQL.
I know that I can use a SQL query for that
Code:
select custom.VALUE from E_CUSTOM_ATTR custom, ENTITY entity where custom.E_ID = entity.ID and custom.NAME='specificKey'
but I am required to use HQL.
Thanks,
ace130