Hello all,
I am quite new with Hibernate, I have really tried to look for information on the following issue in documentation and books, but I could not find any definitive information regarding this... So if any of you could help, it would really be appreciated !
Problem: I cannot manage to perform a criteria based query on a simple collection (Set<String>)
Hibernate version: 3.2.6.ga 
Database version: MySQL 5.0.67
I have this simple (simplified for the forum of course) Member class :
Code:
public class Member {
  private Long rowId;
  private Set<String> gids = new HashSet<String>();
  
  public Long getRowId() { return rowId; }
  public void setRowId(Long rowId) { this.rowId = rowId; }
  public Set<String> getGids() {
    return gids;
  }
  public void setGids(Set<String> gids) {
    this.gids = gids;
  }
}
and its hbm file
Code:
  <class name="org.company.project.Member" table="MEMBER">
      <id name="rowId" column="rowId">
        <generator class="native"/>
      </id>
      <set name="gids" table="MEMBER_GIDS">
        <key column="rowId"/>
        <element type="string" column="gid" length="64" not-null="true"/>
      </set>
  </class>
My first attempts following example of the book "Java Persistence with Hibernate" were as follows : 
Test 1 : Code:
List<Member> mbrList = session.createCriteria(Member.class)
                               .add(Restrictions.eq("gids.gid", "1234"));
Throws an exception :
Code:
org.hibernate.QueryException: could not resolve property: gids.gid of: com.jalios.jcms.dbmember.DBMember
   at org.hibernate.persister.entity.AbstractPropertyMapping.propertyException(AbstractPropertyMapping.java:44)
which is quite normal since gids is not a Set of hibernate entity, just a simple Set of String...
Test 2 : Code:
List<Member> mbrList = session.createCriteria(Member.class)
                               .createCriteria("gids").add(Restrictions.eq("gid", "1234"))
throws this exception :
Code:
org.hibernate.MappingException: collection was not an association: com.jalios.jcms.dbmember.DBMember.gids
   at org.hibernate.type.CollectionType.getAssociatedEntityName(CollectionType.java:447)
indicating that the collection is not an association, but I could not add a <one-to-many> relationship in the hbm for a set of String...
I have found these two posts which I think are related to my question, but they seem to indicate this is not possible... :
Could someone please tell me if this is possible with Hibernate, and if so, help me find the appropriate configuration/querycode to use ?
If this is not possible, what workaround can i use ?
Thanks for your help !