Skip to content

Advanced features

IrlHenry edited this page May 24, 2017 · 4 revisions

Database helper



If you need to set-up database helper behavior, you can annotate main configuration class as @DBHelper passing in the argument class which implements DBExtraHelper as it is shown below.





Repository: queries and custom methods implementations



Lest look at default repository interface. It's absolutely empty, of course it provides basic functionality, but sometimes we need more. For this case, SQLightning provides queries and custom method implementations.



All methods annotated as @Query must returns Cursor object, it also may arguments annotated as @Alias in cases when sql-query uses method arguments in own body. Also methods annotated as @Query must be annotated as @Read or @Write to resolve which work mode of database provider use, but in most of queries like SELECT, INSERT, DELETE etc... those annotations may be omitted, because work mode will be recognized automatically.



Methods annotated as @Implementation don't have restrictions on the type of returned objects and the type and number of arguments, only thing you need is to specify in the body of the annotation the class which contains declaration and definition of method has the same return type, name, and arguments types (in the same order). To avoid mistakes, I highly recommend using a separate interface for these purposes.

Clone this wiki locally