OK, so I thought I'd simplify this and ran the petclinic sample. After adding a single Owner and three Pets the same issue exists when calling /pets/1
Code:
DEBUG org.apache.tiles.impl.BasicTilesContainer - Render request recieved for definition 'pets/show'
DEBUG org.hibernate.loader.Loader - loading collection: [com.springsource.petclinic.domain.Owner.pets#1]
DEBUG org.hibernate.jdbc.AbstractBatcher - about to open PreparedStatement (open PreparedStatements: 0, globally: 0)
DEBUG org.hibernate.jdbc.ConnectionManager - opening JDBC connection
DEBUG org.hibernate.SQL - select pets0_.owner as owner1_1_, pets0_.id as id1_, pets0_.id as id2_0_, pets0_.name as name2_0_, pets0_.owner as owner2_0_, pets0_.send_reminders as send3_2_0_, pets0_.type as type2_0_, pets0_.version as version2_0_, pets0_.weight as weight2_0_ from pet pets0_ where pets0_.owner=?
DEBUG org.hibernate.jdbc.AbstractBatcher - about to open ResultSet (open ResultSets: 0, globally: 0)
DEBUG org.hibernate.loader.Loader - result set contains (possibly empty) collection: [com.springsource.petclinic.domain.Owner.pets#1]
DEBUG org.hibernate.loader.Loader - result row: EntityKey[com.springsource.petclinic.domain.Pet#1]
DEBUG org.hibernate.loader.Loader - found row of collection: [com.springsource.petclinic.domain.Owner.pets#1]
DEBUG org.hibernate.loader.Loader - result row: EntityKey[com.springsource.petclinic.domain.Pet#2]
DEBUG org.hibernate.loader.Loader - found row of collection: [com.springsource.petclinic.domain.Owner.pets#1]
DEBUG org.hibernate.loader.Loader - result row: EntityKey[com.springsource.petclinic.domain.Pet#3]
DEBUG org.hibernate.loader.Loader - found row of collection: [com.springsource.petclinic.domain.Owner.pets#1]
This is fine if you only have three pets, but I have hundreds of thousands of planets. Colour me confused.