Hi,
This has been driving me crazy for hours so any help would be much appreciated. I have the following class:
Code:
public class Song
{
private String id;
private String[] artistNames;
...
}
with the following mapping:
Code:
<class name="com.test.Song" table="SONG">
<id name="id" column="id">
<generator class="assigned"/>
</id>
<array name="artistNames" table="SONG_ARTIST_NAMES" cascade="all">
<key column="song_id"/>
<index column="index"/>
<element column="value" type="string"/>
</array>
</class>
and I want to retrieve Songs which contain a specific artist name. I can do this with HQL using:
Code:
from Song where ? in elements(artistNames)
but I can't get it to work using Criterias.
I've tried various combinations of restrictions (like, IN and EQ) and joins but it always fails with an error. The errors are different depending on the type of Criteria I use but include "collection was not an association", "no value specified for parameter 1", and others.
The first error is noted in the advanced problems document where it says:
"Hibernate currently does not support joining a collection of components or other value types with Criteria."
Does this mean that Hibernate Criteria doesn't support querying collection properties of primitive types? Because that seems like a horrible limitation for such a basic functional requirement so I'm hoping my interpretation is wrong...
If not, how can I query the primitve collection in the example above using HIbernate's Criteria APIs?
Thanks in advance!