Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Super light weight java persistence layer needed [closed]

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.

like image 640
Nefsu Avatar asked Jan 09 '12 23:01

Nefsu


People also ask

What is Java persistence layer?

In Java servers, persistence layer is also known as the repository layer. This layer is responsible for data persistence and is used by the business layer to access the cache and database. In terms of functionality, it is fine to write the persistence layer code in the service class.

What is JPA and why we use JPA?

JPA stands for Java Persistence API (Application Programming Interface). It was initially released on 11 May 2006. It is a Java specification that gives some functionality and standard to ORM tools. It is used to examine, control, and persist data between Java objects and relational databases.

What is persistence in Java with example?

Persistence, in computer science, is a noun describing data that outlives the process that created it. Java persistence could be defined as storing anything to any level of persistence using the Java programming language, but obviously this would be too broad a definition to cover in a single book.

When JPA was created?

JPA and Hibernate Developed by Gavin King and first released in early 2002, Hibernate is an ORM library for Java. King developed Hibernate as an alternative to entity beans for persistence.


3 Answers

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

  • JdbcTemplate
  • Apache DbUtils
  • JDBI
  • sql2o
  • persism

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

  • ActiveJDBC
  • MyBatis
  • EBean

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

  • jOOQ
  • JaQu
  • iciql
like image 189
Lukas Eder Avatar answered Oct 05 '22 00:10

Lukas Eder


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.

like image 26
Dave Newton Avatar answered Oct 05 '22 01:10

Dave Newton


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.

like image 41
duffymo Avatar answered Oct 04 '22 23:10

duffymo