11

I need a super light weight persistence layer for a java app I'm writing. I need it to be a stand alone app and so far I've played with Ammentos & Persistence4J. I like them both (especially Ammentos) but I cannot find much on it on the web and I'm looking for some thoughts on these two or any other persistence layers that you think would be easy to deploy with a mysql db.

I've only used hibernate in the past so I'm looking for an alternative that just allows me to do simple saves and retrievals. Support for any complex queries is not needed.

Nefsu
  • 418
  • 1
  • 5
  • 16

4 Answers4

12

All of these tools are very lightweight wrappers for JDBC, without adding any ORM / ActiveRecord features:

These tools add a couple of additional features related to ORM / ActiveRecord models and are thus a bit less lightweight:

These ones also feature a fluent API for typesafe SQL construction:

Lukas Eder
  • 211,314
  • 129
  • 689
  • 1,509
6

Don't forget OrmLite.

Make sure you need an ORM at all, though.

Edit to respond to comment

For simple Java projects (a rarity these days) I often don't bother with ORM, but still use Commons BeanUtils' RowSetDynaClass sometimes. This wraps query results and allows copying to domain objects using normal BeanUtils copyProperties-type methods.

Dave Newton
  • 158,873
  • 26
  • 254
  • 302
  • +1 - If you don't have objects to map to, you don't need ORM. – duffymo Jan 09 '12 at 23:16
  • Dave, I'm trying to use an ORM because I already have a number of business objects and I would like to abstract the persistence/lookups without having to manage the sql code behind it. Also, I'm not doing any bulk inserts so it seems like a viable approach. I've never heard of OrmLite but I'll look into it. Have you used it and if you have do you have any thoughts on it? – Nefsu Jan 09 '12 at 23:18
  • @Nefsu I've only used it in Android; it was fine. Updated answer with another option covering non-ORM solution with domain models. – Dave Newton Jan 09 '12 at 23:25
  • Thanks for the suggestions, Dave. I don't see a scenario where I don't use an ORM right now but I'll check out the BeanUtils persistence class some time. – Nefsu Jan 09 '12 at 23:44
3

Spring's SimpleJdbcTemplate is as lightweight as it gets. You can use SQL without all the boilerplate. You don't need the full Spring machinery, either - just use what you need.

If SimpleJdbcTemplate is too light for you, try iBatis. It's an intermediate step between JDBC and Hibernate.

duffymo
  • 305,152
  • 44
  • 369
  • 561
  • +1; used on my last two Spring projects--it's drop-dead easy. (And great for legacy DBs that have tons of SQL already written, and would make Hibernate cry like a dropped baby.) – Dave Newton Jan 09 '12 at 23:27
  • Yes, I've used it too duffymo. But if I recall correctly JdbcTemplate doesn't really support ORM. – Nefsu Jan 09 '12 at 23:38
  • No, it does not. SimpleJdbcTemplate is for folks who still want to work with SQL. You can load results into whatever you want with RowMapper. ORM is way oversold. You don't need it, especially for a couple of objects. – duffymo Jan 09 '12 at 23:44
0

I designed sormula specifically to be a lightweight ORM. It is CRUD-ready and POJO-friendly. You don't write any DAO's. Zero-configuration, zero-annotation is possible.

Jeff Miller
  • 1,424
  • 1
  • 10
  • 19