Step 1. Add the JitPack repository to your build file
Add it in your root settings.gradle at the end of repositories:
dependencyResolutionManagement {
repositoriesMode.set(RepositoriesMode.FAIL_ON_PROJECT_REPOS)
repositories {
mavenCentral()
maven { url 'https://jitpack.io' }
}
}
Add it in your settings.gradle.kts at the end of repositories:
dependencyResolutionManagement {
repositoriesMode.set(RepositoriesMode.FAIL_ON_PROJECT_REPOS)
repositories {
mavenCentral()
maven { url = uri("https://jitpack.io") }
}
}
Add to pom.xml
<repositories>
<repository>
<id>jitpack.io</id>
<url>https://jitpack.io</url>
</repository>
</repositories>
Add it in your build.sbt at the end of resolvers:
resolvers += "jitpack" at "https://jitpack.io"
Add it in your project.clj at the end of repositories:
:repositories [["jitpack" "https://jitpack.io"]]
Step 2. Add the dependency
dependencies {
implementation 'com.github.oobest:cursorhelper:1.7'
}
dependencies {
implementation("com.github.oobest:cursorhelper:1.7")
}
<dependency>
<groupId>com.github.oobest</groupId>
<artifactId>cursorhelper</artifactId>
<version>1.7</version>
</dependency>
libraryDependencies += "com.github.oobest" % "cursorhelper" % "1.7"
:dependencies [[com.github.oobest/cursorhelper "1.7"]]
通过输入SQL和相关参数,查找,删除,更新。
allprojects {
repositories {
jcenter()
maven { url "https://jitpack.io" }
}
}
implementation 'com.github.oobest.CursorHelper:cursorhandler:v1.6'
annotationProcessor 'com.github.oobest.CursorHelper:db_annotation_compiler:v1.6'
@AptCursorWrapper
public class Customer {
@Cols("id")
protected int id;
@Cols("name")
protected String name;
@Cols("address")
protected String address;
@Cols("phone")
protected String phone;
//setter getter ...
}
//"SELECT id, name, address, phone From customers WHERE id = ?"
// 注意数据库返回得Cursor中,列字段要与注释中的字符串一致
Customer user = new BeanHandler<>(Customer.class).handle(cursor);
//"SELECT id, name, address, phone From customers"
// 注意数据库返回得Cursor中,列字段要与注释中的字符串一致
Customer user = new BeanListHandler<>(Customer.class).handle(cursor);
//"SELECT count(name) From customers WHERE name = ?"
// 只支持Integer,Long,Double,Float,String
Customer user = new new ScalarHandler<>(Long.class).handle(cursor);