A criteria query with a filter (to the elements of a one-to-many relation) can initialize the persistent set with so that it returns not all items.
More detailed description: 1a. A Person bean is a simple entity 1b. A Person bean has multiple B Dog beans 2. Query A Person bean with a filter to B Dog 3a. The returns good result in the terms of A Person 3b. The set of returned A bean Person beans (which contains B Dog instances) does not contains every referenced B Dog item 4. After querying A items Person beans again with session.get() the returned A Person instances neither still does not have the full set (with every B Dog reference)
Expected behavior: 1. The Set of A Person instances should contain every referenced B item Dog bean . (I know it can not cannot be done with one query in general case) 2. If I query the same items with session.get() it shouldn't be affected by previous query and its set should contain every item. (I think this is the most serious problem) 3. The PersistentSet shouldn't marked with initialized=true, if its content can not be guaranteed that it contains every item.
Note: The set of the same query is different (and contains every item), if its PersistentSet is initialized in the same session by an other query. (e.g. with a previous session.get().toString())
For more detailed description please check the test case.
|