<commit_before>[![Android Weekly](http://img.shields.io/badge/Android%20Weekly-%23129-2CB3E5.svg?style=flat)](http://androidweekly.net/issues/issue-129)
[![Android Arsenal](https://img.shields.io/badge/Android%20Arsenal-DBFlow-brightgreen.svg?style=flat)](https://android-arsenal.com/details/1/1134) [![Raizlabs Repository](http://img.shields.io/badge/Raizlabs%20Repository-1.1.4-blue.svg?style=flat)](https://github.com/Raizlabs/maven-releases)
DBFlow
======

A robust, powerful, and very simple ORM android database library with **annotation processing**.

The library eliminates the need for writing most SQL statements, writing ``ContentValues`` for every table, converting cursors into models, and so much more. 

Let DBFlow make SQL code _flow_ like a _steady_ stream so you can focus on your complex problem and not be hindered by repetitive code writing. 

This library is based on [Active Android](https://github.com/pardom/ActiveAndroid), [Schematic](https://github.com/SimonVT/schematic), [Ollie](https://github.com/pardom/ollie/), and [Sprinkles](https://github.com/emilsjolander/sprinkles), but takes the **best** of each while offering much more functionality and extensibility. 

What sets this library apart: **every** feature has been unit tested to ensure functionality, baked in support for **multiple** databases seamlessly, powerful and fluid builder logic in expressing SQL statements, **annotation processing** to enable blistering speed, ```ModelContainer``` classes that enable direct to database parsing for data such as JSON, and rich interface classes that enable powerful flexibility.

## Changelog

#### 1.1.4
  1. Fixed issue where ```Collate``` enum was not appending ```COLLATE``` to the SQL query
  2. Added the ability to chain ```Condition``` together using different separators. Just call ```separator()``` on a ```Condition``` used in a ````ConditionQueryBuilder```. 
  3. Added tests for ```Between``` and these fixes.

#### 1.1.3
  1. Fixes an issue with Boolean converter throwing a ```NullPointerException``` when a ```ModelContainer``` does not contain the field.
  2. Added null checks in the ```toModel()``` method of a ```ContainerAdapter``` definition class.
  3. We ```bindNull()``` and ```putNull()``` for missing foreign key fields in the ````$Adapter``` definition, previously this bug did not allow the removal of foreign key object fields.
  4. Added a  ```purgeQueue()``` and the ability to set the priority of the batches in the ```DBBatchSaveQueue```
  5. Added the ```Between``` method for SQLite statements
  6. Added  a method in ```Delete``` for clearing multiple tables

#### 1.1.2
  1. Added support for SQLite ```COLLATE``` in ```@Column``` and ```Condition``` classes
  2. Added support for ```DEFAULT``` values in column creation.
  3. Deprecated ```ResultReceiver``` to replace it with ```TransactionListenerAdapter``` which provides a base implementation of ```TransactionListener```. ```TransactionListener``` provides more callback methods to the state of a DB transaction. As a result ```ResultReceiver``` is no longer an interface, rather an abstract class. ***NOTE:*** ```BaseResultTransaction```'s ```TransactionListener``` must return true from ```hasResult(BaseResultTransaction, ResultClass)``` to have ```onResultReceived()``` called.
  4. ```FlowCursorList``` is more flexible by adding methods to clear the cache, dynamically enable/disable the cache, and set a custom ```Where``` for the cursor to use.

#### 1.1.1

Fixed an issue where ```TypeConverter``` for boolean values would incorrectly try to cast in ```bindLong``` to ```Boolean```

#### 1.1.0

Marks a large change in the library:
  1. All base package names "com.grosner.dbflow" are now "com.raizlabs.android.dbflow"
  2. The library will no longer be updated on Maven Central. For versions < 1.1, you can find it there, otherwise you will need to use the new "https://github.com/Raizlabs/maven-releases" repository. Also the group artifact has changed from ```com.github.agrosner``` to ```com.raizlabs.android```
  3. Significant changes to ```ModelAdapter```, inserts now reuse ```SQLiteStatement```for each table. ```save(ContentValues)``` has changed to ```bindToContentValues(ContentValues, ModelClass)``` 
  4. Support for backing up databases and ```pragma quick_check``` for maintaining DB integrity
  5. Multiline migration file query support. commands must be separated by ";"
  6. Bug fixes
  7. Added a postfix operator to ```Condition``` as ```postfix()```

#### 1.0.3

  1. Added ```JSONArrayModel```, which will operate on all items and backed by a ```JSONArray```
  2. ```@ContainerKey``` enables different key from a model container ```@Key``` field

#### 1.0.2
  1. Fixes issue in ```FlowCursorList``` that caused the cursor to reset everytime ```getItem(int)``` was called
  2. Fixes "DSC" to "DESC" for SQL orderby 


## Including in your project

### Gradle

Using the [apt plugin for gradle](https://bitbucket.org/hvisser/android-apt).

For 1.1+ (recommended), add this repo to your build.gradle:

```groovy

repositories {
  maven { url "https://raw.github.com/Raizlabs/maven-releases/master/releases" }
}

dependencies {
  apt 'com.raizlabs.android:DBFlow-Compiler:1.1.+'
  compile 'com.raizlabs.android:DBFlow-Core:1.1.+' 
  compile 'com.raizlabs.android:DBFlow:1.1.+'
}

```

### Eclipse

Not supported as google is no longer supporting it.

## Configuration

We need to configure the ```FlowManager``` properly. Instead of passing in a ```Context``` wherever it is used,
we hold onto the ```Application``` context instead and reference it. 

You will need to extend the ```Application``` class for proper configuration:

```java

public class ExampleApplication extends Application {

    @Override
    public void onCreate() {
        super.onCreate();
        FlowManager.init(this);
    }
<commit_msg>updated to 1.1.5<commit_after>[![Android Weekly](http://img.shields.io/badge/Android%20Weekly-%23129-2CB3E5.svg?style=flat)](http://androidweekly.net/issues/issue-129)
[![Android Arsenal](https://img.shields.io/badge/Android%20Arsenal-DBFlow-brightgreen.svg?style=flat)](https://android-arsenal.com/details/1/1134) [![Raizlabs Repository](http://img.shields.io/badge/Raizlabs%20Repository-1.1.5-blue.svg?style=flat)](https://github.com/Raizlabs/maven-releases)
DBFlow
======

A robust, powerful, and very simple ORM android database library with **annotation processing**.

The library eliminates the need for writing most SQL statements, writing ``ContentValues`` for every table, converting cursors into models, and so much more. 

Let DBFlow make SQL code _flow_ like a _steady_ stream so you can focus on your complex problem and not be hindered by repetitive code writing. 

This library is based on [Active Android](https://github.com/pardom/ActiveAndroid), [Schematic](https://github.com/SimonVT/schematic), [Ollie](https://github.com/pardom/ollie/), and [Sprinkles](https://github.com/emilsjolander/sprinkles), but takes the **best** of each while offering much more functionality and extensibility. 

What sets this library apart: **every** feature has been unit tested to ensure functionality, baked in support for **multiple** databases seamlessly, powerful and fluid builder logic in expressing SQL statements, **annotation processing** to enable blistering speed, ```ModelContainer``` classes that enable direct to database parsing for data such as JSON, and rich interface classes that enable powerful flexibility.

## Changelog

#### 1.1.5
  1. Fixed issue where using non-string primary queries caused a build error.
  2. Optimized loading foreign key objects from the DB by checking using the ```Cursor.isNull()``` method before calling a SELECT query
  3. Made ```FlowCursorList``` and ```FlowTableList``` more robust and flexible by enabling ```Queriable``` objects to be used to generate it's internal cursor. Added ```Condition...``` parameter to ```FlowTableList``` as well.
  4. Added two new methods to ```Queriable```: ```queryClose()``` will execute a query on the DB and close the ```Cursor``` if needed. ```getTable()``` simply returns the table that the query comes from.
  5. Made ```TransactionListenerAdapter``` both the class and the ```onResultReceived()``` method no longer abstract to make it useful in situations other than results.

#### 1.1.4
  1. Fixed issue where ```Collate``` enum was not appending ```COLLATE``` to the SQL query
  2. Added the ability to chain ```Condition``` together using different separators. Just call ```separator()``` on a ```Condition``` used in a ````ConditionQueryBuilder```. 
  3. Added tests for ```Between``` and these fixes.

#### 1.1.3
  1. Fixes an issue with Boolean converter throwing a ```NullPointerException``` when a ```ModelContainer``` does not contain the field.
  2. Added null checks in the ```toModel()``` method of a ```ContainerAdapter``` definition class.
  3. We ```bindNull()``` and ```putNull()``` for missing foreign key fields in the ````$Adapter``` definition, previously this bug did not allow the removal of foreign key object fields.
  4. Added a  ```purgeQueue()``` and the ability to set the priority of the batches in the ```DBBatchSaveQueue```
  5. Added the ```Between``` method for SQLite statements
  6. Added  a method in ```Delete``` for clearing multiple tables

#### 1.1.2
  1. Added support for SQLite ```COLLATE``` in ```@Column``` and ```Condition``` classes
  2. Added support for ```DEFAULT``` values in column creation.
  3. Deprecated ```ResultReceiver``` to replace it with ```TransactionListenerAdapter``` which provides a base implementation of ```TransactionListener```. ```TransactionListener``` provides more callback methods to the state of a DB transaction. As a result ```ResultReceiver``` is no longer an interface, rather an abstract class. ***NOTE:*** ```BaseResultTransaction```'s ```TransactionListener``` must return true from ```hasResult(BaseResultTransaction, ResultClass)``` to have ```onResultReceived()``` called.
  4. ```FlowCursorList``` is more flexible by adding methods to clear the cache, dynamically enable/disable the cache, and set a custom ```Where``` for the cursor to use.

#### 1.1.1

Fixed an issue where ```TypeConverter``` for boolean values would incorrectly try to cast in ```bindLong``` to ```Boolean```

#### 1.1.0

Marks a large change in the library:
  1. All base package names "com.grosner.dbflow" are now "com.raizlabs.android.dbflow"
  2. The library will no longer be updated on Maven Central. For versions < 1.1, you can find it there, otherwise you will need to use the new "https://github.com/Raizlabs/maven-releases" repository. Also the group artifact has changed from ```com.github.agrosner``` to ```com.raizlabs.android```
  3. Significant changes to ```ModelAdapter```, inserts now reuse ```SQLiteStatement```for each table. ```save(ContentValues)``` has changed to ```bindToContentValues(ContentValues, ModelClass)``` 
  4. Support for backing up databases and ```pragma quick_check``` for maintaining DB integrity
  5. Multiline migration file query support. commands must be separated by ";"
  6. Bug fixes
  7. Added a postfix operator to ```Condition``` as ```postfix()```

for older changes, from other xx.xx versions, check it out [here](https://github.com/Raizlabs/DBFlow/wiki)


## Including in your project

### Gradle

Using the [apt plugin for gradle](https://bitbucket.org/hvisser/android-apt).

For 1.1+ (recommended), add this repo to your build.gradle:

```groovy

repositories {
  maven { url "https://raw.github.com/Raizlabs/maven-releases/master/releases" }
}

dependencies {
  apt 'com.raizlabs.android:DBFlow-Compiler:1.1.5'
  compile 'com.raizlabs.android:DBFlow-Core:1.1.5' 
  compile 'com.raizlabs.android:DBFlow:1.1.5'
}

```

### Eclipse

Not supported as google is no longer supporting it.

## Configuration

We need to configure the ```FlowManager``` properly. Instead of passing in a ```Context``` wherever it is used,
we hold onto the ```Application``` context instead and reference it. 

You will need to extend the ```Application``` class for proper configuration:

```java

public class ExampleApplication extends Application {

    @Override
    public void onCreate() {
        super.onCreate();
        FlowManager.init(this);
    }

{'fraction_non_alphanumeric': 0.1325105553751218, 'fraction_numerical': 0.013316011692107827, 'mean_word_length': 4.915946205571566, 'pattern_counts': {'":': 0, '<': 5, '<?xml version=': 0, '>': 3, 'https://': 21, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 0, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '7159694', 'n_tokens_mistral': 3606, 'n_tokens_neox': 3391, 'n_words': 1395}