Light weight alternative to Hibernate?

I have a single user java program that I would like to have store data in a light weight database such as Derby or Sqlite. I would like to use a data abstraction layer in my program. Hibernate appears to require a lot of configuration and is overkill for what I need. What are light weight alternatives to Hibernate?

92597 次浏览

它仍然需要 XML 配置,但是看一下 MyBatis (前身为 iBatis)

你可能想看看普利策(在 source ceforge 上)。一种更轻量级的持久性方法。还是你在考虑对尸体做报告?

如果使用注释,Hibernate 需要的配置接近于零。它甚至可以在类路径中自动发现映射 bean!我没有看到任何替代它从简单的 还有电源的观点。

It can also expose itself as JPA, which is (IMHO) even simpler.

Apache Commons DBUtils takes much of the repetitive gruntwork out of JDBC programming. It requires little configuration and is easy to learn. It is not an ORM framework (in the way that Hibernate and other frameworks mentioned here are) but it does automate mapping of SELECT columns to Java member fields as well as other repetitive JDBC programming tasks. It's certainly lightweight.

你可以看看 Ebean ORM。 - 没有会议 懒惰加载只是工作 - 使用和学习更简单的应用程式介面。

我的 奥姆利特库就是这样一个替代方案。它支持 MySQL、 Postgres、 Microsoft SQL Server、 H2、 Derby、 HSQLDB 和 Sqlite,并且可以很容易地扩展到其他网站。它使用注释来配置类、良好的 Spring 支持、灵活的查询构建器等。.

JOOQ 提供了一个流畅的 DSL,直接在 Java 中模拟 SQL,作为其主要目标的副作用,这些目标是:

  • 源代码生成
  • 完全支持标准 SQL,包括 SQL 语言特性,如 UNION、嵌套 SELECT、所有类型的 JOIN、别名(例如自连接)等
  • Wide support for non-standard SQL including UDT's, stored procedures, vendor-specific functions, etc.

阅读本文中关于 jOOQ 的内容: http://java.dzone.com/announcements/simple-and-intuitive-approach,或者直接访问网站: http://www.jooq.org

(免责声明,我为 jOOQ 背后的公司工作)

我可以提出阿帕奇帝国 -db。 http://incubator.apache.org/empire-db/

Apache Empire-db 是一个开源关系数据持久性组件,它允许独立于数据库供应商的动态查询定义以及安全简单的数据检索和更新。与大多数其他解决方案(如 Hibernate、 TopLink、 iBATIS 或 JPA 实现)相比,Empire-db 采取了一种截然不同的方法,特别关注 编译时安全、减少冗余和提高开发人员生产力。

举个例子:

// Define the query
DBCommand cmd = db.createCommand();
DBColumnExpr EMPLOYEE_FULLNAME= db.EMPLOYEES.LASTNAME.append(", ")
.append(db.EMPLOYEES.FIRSTNAME).as("FULL_NAME");
// Select required columns
cmd.select(db.EMPLOYEES.EMPLOYEE_ID, EMPLOYEE_FULLNAME);
cmd.select(db.EMPLOYEES.GENDER, db.EMPLOYEES.PHONE_NUMBER);
cmd.select(db.DEPARTMENTS.NAME.as("DEPARTMENT"));
cmd.select(db.DEPARTMENTS.BUSINESS_UNIT);
// Set Joins
cmd.join(db.EMPLOYEES.DEPARTMENT_ID, db.DEPARTMENTS.DEPARTMENT_ID);
// Set contraints and order
cmd.where(EMP.LASTNAME.length().isGreaterThan(0));
cmd.orderBy(EMP.LASTNAME);;

如果不是必须使用关系数据库,可以试试 db4o。

我创建了 索玛拉作为重量级 ORM 的替代品。它支持 CRUD,POJO 友好,易于使用、配置和理解。零配置使用是可能的。Www.sormula.org

I might be a bit late to the party, but I released ActiveJDBC in 2010, which is an ORM implementation of ActiveRecord pattern, is more than 10 times lighter than Hibernate in dependencies, at least twice as fast at run time, and requires zero configuration or annotations.

KiteFramework 也是一个非常轻量级的框架,它以最小的配置提供了几乎所有的 db 操作。

Http://deipakgarg.github.com/kite-orm/

披露: 我是这个项目的作者