Suppose you have the following mappings based on database with tableA and tableB:
Code:
<class name="A" table="tableA">
<set name="mySet">
<key column="A.id"/>
<one-to-many class="B"/>
</set>
</class>
<class name="B" table="tableB">
<discriminator column="type"/>
<subclass name="B2" discriminator-value="B2"/>
<subclass name="B3" discriminator-value="B3"/>
</class>
When you call a.getMySet() you get objects of the appropriate type - either B2 or B3.
Specifying B2 on the one-to-many doesn't change the nature of the join (that's controlled by the key). Instead it incorrectly asks for instances of B2 to be created where tableB can contain either B2 or B3. So I suggest keeping you one-to-many as class B.
If you want to load A with instances of only B2 or B3 try this:
Code:
String query =
"from A a join fetch a.mySet b where a.id = :id and b.type = :type";
new HashSet(
sess.createQuery(query).
setInt("id", 1).
setString("type", "B2").
list());