ActiveJDBC 是一个快速和轻量级的 Java 的 ORM 小型框架,语法简单易于理解,同时支持多数据库链接。ActiveJDBC 的文档非常完善。基于以下原则设计:
- 惯例重于配置(无配置)
- 拥有 SQL 知识就足够了
- 轻量级而且直观的代码
- 无会话
- 无持久层管理
- 无 proxying
下面是一个简单的 Model 类:
public class Main {
public static void main(String[] args) {
new DB("corporation").open("com.mysql.jdbc.Driver", "jdbc:mysql://localhost/test",
"root", "p@ssw0rd");
new DB("university").open("oracle.jdbc.driver.OracleDriver",
"jdbc:oracle:thin:@localhost:1521:xe",
"activejdbc", "activejdbc");
Employee.deleteAll();
Student.deleteAll();
Employee.createIt("first_name", "John", "last_name", "Doe");
Employee.createIt("first_name", "Jane", "last_name", "Smith");
Student.createIt("first_name", "Mike", "last_name", "Myers");
Student.createIt("first_name", "Steven", "last_name", "Spielberg");
System.out.println("*** Employees ***");
Employee.findAll().dump();
System.out.println("*** Students ***");
Student.findAll().dump();
new DB("corporation").close();
new DB("university").close();
}
}
- 1.
- 2.
- 3.
- 4.
- 5.
- 6.
- 7.
- 8.
- 9.
- 10.
- 11.
- 12.
- 13.
- 14.
- 15.
- 16.
- 17.
- 18.
- 19.
- 20.
- 21.
- 22.
- 23.
- 24.
- 25.
- 26.
【编辑推荐】