Hello,
I am using Hibernate 3.2 CR2.
I have the following mappings:
Code:
<hibernate-mapping>
<class name="TestParent" table="TESTPARENT">
<id name="id" column="ID">
<generator class="native"/>
</id>
<list name="children" lazy="extra">
<key column="PARENT_ID" />
<list-index column="id"/>
<one-to-many class="TestChild" />
</list>
</class>
</hibernate-mapping>
Code:
<hibernate-mapping>
<class name="TestChild" table="TESTCHILD">
<id name="id" column="ID">
<generator class="native"/>
</id>
<many-to-one name="parent" column="id" class="TestParent" />
</class>
</hibernate-mapping>
When I get the size of the children by:
Code:
System.out.println(parent.getChildren().size());
the following query is issued:
Code:
select max(id) + 1 from TESTCHILD where PARENT_ID =?
This assumes a sequential id column with no deleted rows. I expect a count(id) query.
Strangely, if I map the same class with annotations, a count(id) query is issued, but the collection will not be extra lazy as I mentioned in the annotations forum:
http://forum.hibernate.org/viewtopic.php?t=959249