Skip to content

@BindDataSourceOptions

xcesco edited this page Apr 26, 2018 · 3 revisions

Used to define data-source options with annotation. There are two ways to customize data source creating: by code or by annotation. This annotation implements the second way. When data-source is created, usually at application startup, it is possible to define some features: if it is in-memory, if DDL log is enabled, the populator and the migration-version tasks and so on.

To configure data source with @BindDataSourceOptions just define data source as follows:

@BindDataSourceOptions(
  logEnabled = true, 
  populator = PersonPopulator.class, 
  cursorFactory = PersonCursorFactory.class, 
  databaseLifecycleHandler=PersonLifecycleHandler.class, 
  updateTasks = {
    @BindDataSourceUpdateTask(version = 2, task = PersonUpdateTask.class)
  })
@BindDataSource(daoSet = { DaoPerson.class }, fileName = "app.db")
public interface AppWithConfigDataSource {

}

And the code for creating data source will become

// create data source		
BindAppWithConfigDataSource ds=BindAppWithConfigDataSource.instance();

Attributes

  • cursorFactory: cursorFactory
  • databaseErrorHandler: databaseErrorHandler
  • databaseLifecycleHandler: databaseLifecycleHandler
  • inMemory: if true, generate database in memory.
  • logEnabled: Log enabled. This flag controls log that is not generated by annotation processor, but the log associated to database operation like open/close connnections, create tables and so on.
  • populator: is executed after database creation.
  • updateTasks: Allows to specify migration task between versions.

Table of Contents

Query definition

Features

Relations

Multithread supports

Modularization

Annotations for data convertion

Annotations for SQLite ORM

Annotations for shared preferences

Clone this wiki locally