Skip to content

Gopinathp/storm-gen

 
 

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

96 Commits
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

storm-gen

Simple ORM for Android SQLite

Community

Use the issue tracker to report bugs or request enhancements, and StackOverflow with tag storm-gen for assistance. Join the storm-gen G+ community for project news and feature discussion.

Setup

  1. Download storm-api.jar from the latest release and add to your Android project's libs folder so it will be on the project's build path.
  2. Download storm-apt.jar from the latest release and add to your annotation factory classpath (in Eclipse, project properties | Java Compiler > Annotation Processing > Factory Path). Also check the box to enable annotation processing.

Basic Usage

  1. Create a new class that extends com.turbomanage.storm.DatabaseHelper (it's in the storm-api jar).
  2. Add @Database and supply a database name and version example
  3. Override getUpgradeStrategy() to choose one of the available strategies (DROP_CREATE for new projects)
  4. Create a POJO class you want to persist to the database
  5. Make sure it has a field of type long named "id" or annotated with @Id
  6. Add the @Entity annotation to the class example

You'll see 3 generated classes under .apt_generated (you might need to unfilter hidden resources in your IDE to see it):

  • a DbFactory class
  • a Dao class
  • a Table class

You can use the DAO like this:

PersonDao dao = new PersonDao(getContext());
long id = dao.insert(new Person());
Person person = dao.get(id);

For more info, see the unit tests and the resources on the project home page.

Integration

The lib is available on Maven Central. Add the android-apt plugin and stORM dependencies to build.gradle. Log4j and javax.persistence are needed if you use the JPA @Entity annotation instead of stORM's @Entity.

// top-level build.gradle

buildscript {
    repositories {
        mavenCentral()
     }
    dependencies {
        classpath 'com.android.tools.build:gradle:0.10.+'
        classpath 'com.neenbedankt.gradle.plugins:android-apt:1.2'
    }
}

// app module build.gradle

apply plugin: 'android'
apply plugin: 'android-apt'

...

dependencies {
        apt 'com.turbomanage.storm:storm-impl:0.98'
        compile 'com.android.support:appcompat-v7:19.1.0'
        compile 'log4j:log4j:1.2.17'
        compile 'javax.persistence:persistence-api:1.0'
        compile 'com.turbomanage.storm:storm-api:0.98'
}

About

Redbus hotfix for Simple ORM for Android SQLite

Resources

License

Stars

Watchers

Forks

Packages

No packages published