views:

5463

answers:

12

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?

A: 

You might find Resin's Amber to be interestnig.

Josh
+10  A: 

It still requires XML configuration, but have a look at iBatis.

kgiannakakis
iBATIS is awesome!
Camilo Díaz
+2  A: 

Cayenne has served me well. Relatively easy to understand and to get it up and running. I find the reverse engineering part particularly charming. Configuration can be done with a GUI.

Bno
+1  A: 

You might want to take a look at prevayler (on sourceforge). A somewhat more lightweight approach to persistence. Or were you thinking about doing reporting against the DB?

Stephan Eggermont
+26  A: 

Hibernate requires next to zero configuration if you use annotations. It even can auto-discover mapped beans in the classpath! I don't see any alternative to it from both simplicity and power point of view.

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

Vladimir Dyuzhev
I don't have enough points to vote you up, but your answer is the best.
mattsidesinger
+3  A: 

iBatis is very lightweight. You can more easily define and control your SQL to object mapping.

Berlin Brown
+2  A: 

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.

christophergraz
+2  A: 

Look into using a Java DSL for SQL. Squill and SQL-DSL are examples.

Joshua
https://squill.dev.java.net/ is down?
Anders Rune Jensen
A: 

Hibernate works pretty well with Derby - it was very simple to migrate my Eclipse RCP application fromSQL Server to embedded Derby.

If you're using annotations the amount of configuration is in fact quite small.

muriloq
+1  A: 

You can have a look at Ebean ORM. - No sessions - lazy loading just works - Simpler API to use and learn.

Rob
... looks interesting!
vector
+3  A: 

... have to throw a vote for iBatis, though mind you it's not an ORM alternative as it is not trying to compete with likes of Hibernate. It's a bit different sort of an animal, but fits what you're looking for in terms of weight.

vector
+3  A: 

Thought I'd just add my $0.02 to this old post to talk about my ORMLite package which is a lightweight replacement for hibernate.

http://ormlite.sourceforge.net/

Supports MySQL, Postgres, Microsoft SQL Server, H2, Derby, HSQLDB, and Sqlite, and can be easily extended to others. Uses annotations to configure classes, good Spring support, flexible query builder, etc..

Gray