This content has been marked as final. Show 3 replies
Yes, this is a result of setting batch reading on the mapping. Batch reading is a performance option for use cases where the application will regularly iterate over results from queries and access each result in the same way - in an all or nothing type approach. If you are not going to access every country's state returned from queries, you will not want to use batch writing on the mapping level. It doesn't seem to make sense to use it for the case you have provided. Any query for say, every country in the world, accessing one of the returned country object's list of states will end up bringing in every country's list of states. Same with cities.
I'd recommend removing the batch reading setting from the mapping and setting it at the query level when useful, and is described in the documentation here:
The link http://docs.oracle.com/cd/E17904_01/web.1111/b32441/rlmapcfg.htm#CHDHBCEI shows how to set or unset this option on the mapping.
I'm not sure I understand. Triggering a 1:m results in 1 query to bring in all the children referenced by the relationship for the single parent. Batching allows that one query to bring in all children for all parent objects read in from the initial query. If you want to be selective on which children you bring back, you can query directly on the children, or requery to get only the parent objects you are going to use to iterate over to get the children (and set batch reading on the relationship).
In this case though, you probably don't need batch reading set on the country->state relationship, but might on the state->city relationship.