<p>Is it possible to reach the individual columns of table2 using HQL with a configuration like this?</p>

<pre><code>&lt;hibernate-mapping&gt;
  &lt;class table="table1"&gt;
    &lt;set name="table2" table="table2" lazy="true" cascade="all"&gt;
      &lt;key column="result_id"/&gt;
      &lt;many-to-many column="group_id"/&gt;
    &lt;/set&gt;
  &lt;/class&gt;
&lt;/hibernate-mapping&gt;
</code></pre>

[{'answer_id': 75272, 'author': 'sblundy', 'author_id': 4893, 'author_profile': 'https://Stackoverflow.com/users/4893', 'pm_score': 1, 'selected': False, 'text': '<p>They\'re just properties of table1\'s table2 property.</p>\n\n<pre><code>select t1.table2.property1, t1.table2.property2, ... from table1 as t1\n</code></pre>\n\n<p>You might have to join, like so</p>\n\n<pre><code>select t2.property1, t2.property2, ... \n    from table1 as t1\n    inner join t1.table2 as t2\n</code></pre>\n\n<p>Here\'s the relevant part of the <a href="http://www.hibernate.org/hib_docs/reference/en/html/queryhql.html#queryhql-select" rel="nofollow noreferrer">hibernate doc</a>.</p>\n'}, {'answer_id': 75402, 'author': 'Mike Desjardins', 'author_id': 10466, 'author_profile': 'https://Stackoverflow.com/users/10466', 'pm_score': 1, 'selected': False, 'text': "<p>You can query on them, but you can't make it part of the where clause.  E.g.,</p>\n\n<pre><code>select t1.table2.x from table1 as t1\n</code></pre>\n\n<p>would work, but</p>\n\n<pre><code>select t1 from table1 as t1 where t1.table2.x = foo\n</code></pre>\n\n<p>would not.</p>\n"}, {'answer_id': 76181, 'author': 'Michael', 'author_id': 13379, 'author_profile': 'https://Stackoverflow.com/users/13379', 'pm_score': 0, 'selected': False, 'text': '<p>Let\'s say table2 has a column "<code>color varchar(128)</code>" and this column is properly mapped to Hibernate.</p>\n\n<p>You should be able to do something like this:</p>\n\n<pre><code>from table1 where table2.color = \'red\'\n</code></pre>\n\n<p>This will return all <code>table1</code> rows that are linked to a <code>table2</code> row whose <code>color</code> column is \'red\'.  Note that in your Hibernate mapping, your <code>set</code> has the same name as the table it references.  The above query uses the name of the <em>set</em>, <strong>not</strong> the name of the table.</p>\n'}]
['https://Stackoverflow.com/questions/75245', 'https://Stackoverflow.com', 'https://Stackoverflow.com/users/-1/']