views:

150

answers:

6

Hi all,

I know hibernate but I wonder if there would be a lighter ORM engine for a read only database. I mean, I don't need some transactional queries or to update some records. On the other side, I need to handle some large list of records:

List<MyRecord> list= object.getMyRecords(); // list.size() > 1E7

Does such engine exist ? Many thanks,

Pierre

A: 

If you are looking for a lightweight ORM framework, look no further than OrmLite. It allows you to avoid most of the overhead of setting up more complicated ORM frameworks like Hibernate. The downside to this framework is that it does not support standard JPA annotations so it would not be easy to swap this ORM out for a different one later on.

I would suggest trying out OpenJPA which is a JPA standard compliant ORM framework maintained by the Apache foundation. It is one of Hibernate major competitors. It does have a bit more overhead to setup but it has the advantage of allowing you to swap it out in the future for a different JPA compliant framework (like Hibernate) if it no longer suits your needs.

Both of these frameworks are Open Source as well which is always a good reason for using them.

Gweebz
A: 

I searched lite ORM too for one project about a year ago. And tried a couple of them. I was a bit unsatisfied with all solutions because each of them was trying to move in certain direction.

Hibernate is a huge and it can be a source of extra troubles when you want just simple solution. Currently I am working on the one nice project it uses little custom layer over tables.

You can probably try to implement a little layer over your database with JDBC using some patterns like Active Record or Table Gateway, etc.

Any ORM solution just tries to be very unified and ads extra tails to your project. But you can create your own custom layer-less solution - this will especially work fine if you database have predefined set of tables and doesn't change it's structure too often.

Vladimir
A: 

To paraphrase PeterMmm above there is nothing lighter than no ORM at all. You may be looking for a nail while holding a hammer :-)

David T
A: 

Have a look at Ebeans which is a light ORM tool:

  • Reuses JPA Annotations (@Entity, @OneToMany ...) for mapping.
  • Uses a Session Less architecture (i.e. has a simpler API than JPA).
  • Supports immutable Value Object.
  • Allows to use ORM or Relational features
  • Claims to provide good large query support

Worth the look IMO.

Pascal Thivent
A: 

Spring's SimpleJDBCTemplate combined with result mappers worked marvels for me in read only scenarios, you don't get the unneeded overhead of hibernate, all your pseudo-ORM mapping is bundled together, it is a true win for such scenarios.

MahdeTo
+1  A: 

I think you should consider MyBatis (IBatis 3) ORM library. It fits the requirements from light-weight work to some heavy batch executions. So it'll fit your current needs very well and won't through you out of luck when you require some heavy-lifting work from your underlying ORM library.

nabeelalimemon