Skip Headers

# Consider how Conforming Affects Database Results

Previous

Next

When conforming is used on a `ReadAllQuery`, the database result is first queried. If the unit of work has not yet committed any changes to the database, this result will not reflect the unit of work changes. The database results are then conformed in memory using the following criteria:

- Registered new objects that conform to the query are added.

- Modified existing objects that no longer conform are removed.

- Modified existing objects that conform are added.

- Deleted objects are removed.

Note: If new objects are not explicitly registered, they are not conformed. Also, if removed object are not explicitly deleted, they are not conformed.

If the query uses ordering, ordering of conformed results is not maintained and conformed instances are added to the front of the result. To apply ordering, store the result in memory using `Collections` method `sort`, or a `TreeSet` result collection class. When using conforming on a `ReadObjectQuery`, first query the unit of work for a conforming object: if the conforming object is found, it is returned and the database access is avoided; if the conforming object is not found, the database is queried. If the unit of work has not yet committed any changes to the database, this result does not reflect the unit of work changes. The database results are then conformed in memory using the following criteria:

- If the database result no longer conforms, null is returned.

- If the database result has been deleted, null is returned.

Note: If the database result returns multiple results, only the first result is considered, because it is an instance of the `ReadObjectQuery` and only a single result is expected. If the first result no longer conforms, null is returned, even if there were potential valid conforming results. If you expect the query to return multiple results, use a `ReadObjectQuery`.