@Relation and @Query

If you use @Relation, it is a good idea to add the @Transaction annotation to any related @Query. That ensures that the initial query that populates the POJO, plus the query (or queries) necessary to resolve the @Relation, are all performed inside a transaction and therefore will have consistency.

By default, @Transaction logic is not applied to @Query methods returning POJOs with @Relation, and it is possible that you would wind up with inconsistent results, if the database was modified while the @Query was being processed. Unfortunately, this has been deemed as “working as intended”.

This is why the @Query methods on StuffStore that return CategoryTuple or CategoryShadow also have the @Transaction annotation.


Prev Table of Contents Next

This book is licensed under the Creative Commons Attribution-ShareAlike 4.0 International license.