simplysoft/DBFlow
A blazing fast, powerful, and very simple ORM android database library that writes database code for you.
A robust, powerful, and very simple ORM android database library with annotation processing.
The library is built on speed, performance, and approachability. It not only eliminates most boiler-plate code for dealing with databases, but also provides a powerful and simple API to manage interactions.
Let DBFlow make SQL code flow like a steady stream so you can focus on writing
amazing apps.
What sets this library apart:
- Many, many unit tests on nearly every feature.
- Built on maximum performance using annotation processing, lazy-loading, and speed-tests here
- Built-in model caching for blazing-fast retrieval and very flexible customization.
- Powerful and fluid SQL-wrapping statements that mimic real SQLite queries
- Triggers, Views, Indexes, and many more SQLite features.
- Seamless multi-database support.
- Direct-to-database parsing for data such as JSON
- Flexibility in the API enabling you to override functionality to suit your needs.
ContentProvidergeneration using annotations- Content Observing using
Uri
Applications That Use DBFlow
If you wish to have your application featured here, please file an issue.
- Anonymous 1: An application that has over 1.5 million active installs
- Anonymous 2: An application that will have over 1 million active installs
- University of Oslo DHIS2 Android SDK
Changelog
2.2.1
- Fixed issue with
OrderBywhere theCOLLATEkeyword was not appended to the query. - Fixed conversion and inconsistency issues within a
ModelContaineradapter that have foreign keys and private fields. - Private primary keys now work with getter and setters, private fields within
ModelContaineradapters now generate compilable code.
2.2.0
- Fixed a bug where
new Select().from(myTable.class).byId(PrimaryKey)was incorrectly double-quoting columns. - Adds a primary key into the URI of a
FlowContentObserverfor single primary key tables. - Lazy loads
ModelAdapterandModelViewAdapterso subclassing a non-tableBaseModelnow
works without crashing/complaining. Just don't call the non-tables associatedModelmethods directly. - Bug fixes and Improvements
- Adds the
OrderByobject to aid inORDER BYqueries. AddedorderBy()methods in theFromclass
for easier access without needing to callwhere()first. AddsCollatesupport within this class. - Adds a
enableSelfRefreshes()for theFlowQueryListand souped up the documentation
with a "best practices" section. - Fixes bugs with the Getting Started section implementation.
OneToMany.Method.SAVEnow actually works oninsert,update, andsavemethods. - Adds a
OnProgressProcessChangeListenerto listen for the total progress while
looping through saving models in aProcessModelTransaction. - Escalated
convertToCacheableList()topublicand now can query to know if
aModelhas a valid caching id. Also some more public methods added toSqlUtils!
for older changes, from other xx.xx versions, check it out here
Usage Docs
For more detailed usage, check out these sections:
Tables and Database Properties
SQL Statements Using the Wrapper Classes
Screencasts
Listed here are tutorial screen casts for DBFlow. If more are created, they may go into the usage docs.
Including in your project
We need to include the apt plugin in our classpath to enable Annotation Processing:
buildscript {
repositories {
// required for this library, don't use mavenCentral()
jcenter()
}
dependencies {
'com.neenbedankt.gradle.plugins:android-apt:1.4'
}
}
Add the library to the project-level build.gradle, using the to enable Annotation Processing:
apply plugin: 'com.neenbedankt.android-apt'
dependencies {
apt 'com.raizlabs.android:DBFlow-Compiler:2.2.1'
compile "com.raizlabs.android:DBFlow-Core:2.2.1"
compile "com.raizlabs.android:DBFlow:2.2.1"
}
We only use reflection pretty much one time throughout the whole library, so this class is the only one needed.
Gotchas/Compatibility
For GSON and RetroFit compatibility check out #121.
Due to this library using a custom maven repo, to speed up build times when using this library,
you should run in --offline mode except for when updating dependencies. To enable
this setting in Android Studio, ensure the option is checked in:
Preferences->Build,Executor,Deployment->Build Tools->Gradle->Offline Work
Pull Requests
I welcome and encourage all pull requests. It usually will take me within 24-48 hours to respond to any issue or request. Here are some basic rules to follow to ensure timely addition of your request:
- Match coding style (braces, spacing, etc.) This is best achieved using CMD+Option+L (Reformat code) on Mac (not sure for Windows) with Android Studio defaults.
- If its a feature, bugfix, or anything please only change code to what you specify.
DO NOT do this: Ex: Title "Fixes Crash Related to Bug" includes other files that were changed without explanation or doesn't relate to the bug you fixed. Or another example is a non-descriptive title "Fixes Stuff". - Pull requests must be made against
developbranch. - Have fun!
