I'm new to Hibernate, and am using it in a GWT environment.
I've got a class Article which has a field Category_Ids which is a collection of Integers:
Code:
Set<Integer> category_ids = new HashSet<Integer>();
I've got a postgres database with a table category_article (category_id integer, article_id integer)
My Article.hbm.xml file contains the following mapping:
Code:
<class name="....Article" table="article"
schema="public" lazy="false">
<id name="uid" type="int">
<column name="uid" />
<generator class="native" />
</id>
....
....
<set name="category_Ids" table="category_article"
lazy="false">
<key column="Article_Id" />
<element column="Category_Id" type="int" />
</set>
</class>
1 problem, 1 question:
Problem: When attempting to load an Article, I an error that boils down to "Caused by: org.postgresql.util.PSQLException: ERROR: column category_i0_.article_id does not exist"
Articles load fine when I don't map the category_Ids property.
Question: Once I get this problem solved, how can I query the Articles to find all Articles where the Category_Ids set contains a given element? In straight SQL "SELECT Article.Id FROM Articles INNER JOIN category_article on Article.Id = category_article.article_id WHERE category_article.category_id = ?"
I'm tearing the little hair I have left trying to understand this and get it working. Any help would be appreciated.