examples.AdvancedExample Maven / Gradle / Ivy
Go to download
Show more of this group Show more artifacts with this name
Show all versions of sqlite Show documentation
Show all versions of sqlite Show documentation
SQLite module to Harium Database
The newest version!
package examples;
import com.harium.database.Table;
import com.harium.database.dao.OrmLiteBaseDAOImpl;
import com.harium.database.sqlite.module.SQLiteDatabaseModule;
import java.util.List;
public class AdvancedExample {
public static void main(String[] args) {
SQLiteDatabaseModule module = new SQLiteDatabaseModule("database.sqlite");
Table table = new Table(Pojo.class);
table.createColumn("id").id().typeLong();
table.createColumn("text");
table.register(module);
module.init(true);
OrmLiteBaseDAOImpl dao = (OrmLiteBaseDAOImpl) table.getDAO(Pojo.class);
Pojo pojo = new Pojo();
pojo.setText("My Text");
dao.create(pojo);
List pojos = dao.queryAll();
System.out.println(pojos.get(0).text);
}
static class Pojo {
long id;
String text;
public Long getId() {
return id;
}
public void setId(Long id) {
this.id = id;
}
public String getText() {
return text;
}
public void setText(String text) {
this.text = text;
}
}
}