Hi all, I have a fairly simple Map HQL query that isn't work due to badly generated SQL. Here's the relevant part of the class I am trying to query.
Code:
public class Account {
...
@OneToMany(cascade = CascadeType.ALL)
//javax mapkey
@MapKey(name="propertyName")
private Map<String, AdditionalProperty> additionalProperties;
...
}
public class AdditionalProperty {
...
private String propertyName;
private String propertyValue;
...
}
//Querying with HQL of:
"FROM Account ac WHER ac.additionalProperties['someValue'],propertyValue = 'value'"
This gets through hibernate alright but it throughs an SQL error because the it doesn't join the AdditionalProperty class correctly. The sql it generates that is bad is as follows: (just including FROM clause on...)
Code:
"from Account account0_, Account_AdditionalProperty additional1_, AdditionalProperty additional2_ where account0_.id=additional1_.Account_id and additional1_.null = 'someValue' and additional1_.additionalProperties_id=additional2_.id and additional2_.propertyValue=?"
The wrong part of the sql is
"additional1_.null = 'someValue'". Obviously null is not a column name, and its not joined by the key anyways, but the account id, so whats it trying to do here?
Loading objects up works just fine and all the values are correct, but why can't I run this query? I can't see anything that I'm missing compared to the examples.
Thanks for the help!