From: Steve E. (JIRA) <no...@at...> - 2006-05-24 13:51:04
|
[ http://opensource.atlassian.com/projects/hibernate/browse/HHH-1776?page=all ] Steve Ebersole closed HHH-1776: ------------------------------- Resolution: Rejected Assign To: Steve Ebersole You actually have the collection mapped incorrectly. You attempt to use the primary key of the collection elements as the list index. list-index refers to the index or position of the elements within the list, which in fact must be sequential. lazy=extra is intended for *huge* collections. Across such data sets, a "select max(...)" query will be much faster that a "select count(...)" query. That, coupled with the fact mentioned above, is why the max() query is used instead of the count() query > Extra Lazy collection, wrong size > --------------------------------- > > Key: HHH-1776 > URL: http://opensource.atlassian.com/projects/hibernate/browse/HHH-1776 > Project: Hibernate3 > Type: Bug > Versions: 3.2.0.cr2 > Environment: HSQLDB 1.8.0.4 > Reporter: Ecmel Ercan > Assignee: Steve Ebersole > > > I have the following mappings: > <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> > <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: > System.out.println(parent.getChildren().size()); > the following query is issued: > 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 -- This message is automatically generated by JIRA. - If you think it was sent incorrectly contact one of the administrators: http://opensource.atlassian.com/projects/hibernate/secure/Administrators.jspa - For more information on JIRA, see: http://www.atlassian.com/software/jira |