小型Java ORM框架 ActiveJDBC

jopen 12年前發布 | 28K 次閱讀 Java ORM Hibernate 持久層框架

ActiveJDBC 是一個快速和輕量級的 Java 的 ORM 小型框架,語法簡單易于理解,同時支持多數據庫鏈接。ActiveJDBC 的文檔(javadoc)非常完善。基于以下原則設計:

  • 慣例重于配置(無配置)
  • 擁有 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();
    }
}

項目主頁:http://www.baiduhome.net/lib/view/home/1328238451593

 本文由用戶 jopen 自行上傳分享,僅供網友學習交流。所有權歸原作者,若您的權利被侵害,請聯系管理員。
 轉載本站原創文章,請注明出處,并保留原始鏈接、圖片水印。
 本站是一個以用戶分享為主的開源技術平臺,歡迎各類分享!