Skip to content

Repository files navigation

objector

an simple tablestore api Document is http://objector.open.chenmin.org

Install for Maven

	<dependency>
<groupId>org.chenmin.open</groupId>
<artifactId>objector-ots</artifactId>
<version>0.2.4</version>
</dependency>

Useage

Config for Aliyun.com OpenTableStore

objector.properties in classpath

#Sign up in https://www.aliyun.com/product/ots
ALIYUN_ACCESS_KEY=XXXXXX
ALIYUN_SECRET_KEY=XXXXXX
TS_ENDPOINT=http://YYYY.cn-beijing.ots.aliyuncs.com
TS_INSTANCENAME=YYYY

Pojo with Annotation

@EntitypublicclassUserObjectimplementsSerializable {
@Key(index = true)
privateStringopenid;
@ColumnprivateStringpasswd;
publicStringgetOpenid() {
returnopenid;
}
publicvoidsetOpenid(Stringopenid) {
this.openid = openid;
}
publicStringgetPasswd() {
returnpasswd;
}
publicvoidsetPasswd(Stringpasswd) {
this.passwd = passwd;
}
}

CRUD for junit test

publicclassTestUserService {
privatestaticIStorestore;
/** * @throws java.lang.Exception */@BeforeClasspublicstaticvoidsetUpBeforeClass() throwsException {
store =StoreFactory.create();
UserObjectu = newUserObject();
if (!store.exsitTable(u)) {
store.createTable(u);
}
}
@Testpublicvoidtest() {
UserObjectuserObject = newUserObject();
Stringopenid = "chenmintest";
Stringpasswd = "12345678";
Stringpasswd2 = "12";
userObject.setOpenid(openid);
userObject.setPasswd(passwd);
assertTrue(store.save(userObject));
UserObjectt = newUserObject();
t.setOpenid(openid);
assertTrue(store.get(t));
assertEquals(t.getPasswd(), passwd);
UserObjectu = newUserObject();
u.setOpenid(openid);
u.setPasswd(passwd2);
assertTrue(store.update(u));
t = newUserObject();
t.setOpenid(openid);
assertTrue(store.get(t));
assertEquals(t.getPasswd(), passwd2);
t = newUserObject();
t.setOpenid(openid);
assertTrue(store.del(t));
assertEquals(t.getPasswd(),null);
}
}

About

an simple tablestore api

Resources

Code of conduct

Contributing

Stars

6 stars

Watchers

3 watching

Forks

Releases

Packages

Used by

Contributors

Languages