ORMLite - ORM持久层框架


Public Domain
跨平台
Java

软件简介

ORMLite是一个轻量级的Java对象关系映射持久层框架。支持包括 MySQL、Postgres、Microsoft SQL
Server、H2、Derby、HSQLDB和Sqlite等在内的数据库。提供灵活的QueryBuilder来构建复杂的数据查询。强大的抽象DAO类,只需5行代码便能够自动生成SQL来创建和删除数据库表格。

示例代码:

public class AccountApp {

public static void main(String[] args) throws Exception {

// this uses h2 by default but change to match your database

String databaseUrl = “jdbc:h2:mem:account”;

// create a connection source to our database

ConnectionSource connectionSource = new JdbcConnectionSource(databaseUrl);

// instantiate the dao

AccountDaoImpl accountDao = new AccountDaoImpl(connectionSource);

// if you need to create the ‘accounts’ table make this call

TableUtils.createTable(connectionSource, Account.class);