Alternatives to hibernate

41,370

Solution 1

Here you can find an extensive list of Java ORMs and persistence solutions. Not all of the follows Hibernate/JPAs approach, some of them are quite easy by design.

Of course there are solutions not listed on that site, i.e. Spring JDBC with templates, etc.. And this is my personal choice for projects that require fast, easy to build JDBC access and are already using Spring.

In general, for me at least, it's a little bit to early to say Hibernate is bad and it grown to big. It serves it's purpose quite well, but grown to fit to many shoes. My personal opinion is that it will stay as it is, but NoSQL solutions will probably give birth to a new breed of Java data mapping solutions, like Spring Data. There is a need to create a simple approach to interact with application data, but I don't believe there is a consensus on how to get there... yet.

Solution 2

The presenter makes a good case that some frameworks are overly complicated. The vast number of ORM libraries seems to be an indicator that a good solution is elusive.

Github, bitbucket, source forge have hundreds of ORM projects. Wikipedia has a good list too.

I invented sormula as a lightweight alternative to complicated frameworks like JPA. See sormula site for a list of features and examples.

It also contains a package that implements the active record pattern for those that like that approach but is not required.

Solution 3

If you want control over the used SQL and remain close to JDBC in general, you may be interested in MyBatis, which let's you write your own queries and provides a framework for "automatically" mapping ResultSets to POJOs based on XML- or annotation-based metadata.

A select would look like this in XML:

<select id="selectUsers" parameterType="int" resultType="my.User">
 select id, username, password
 from users
 where id = #{id}
</select>

This would be mapped to a user like this:

<resultMap id="userResultMap" type="my.User">
   <id property="id" column="id" />
   <result property="username" column="user_name"/>
   <result property="password" column="hashed_password"/>
</resultMap>

With the properties being Bean properties in the POJO my.User

Share:
41,370
dov.amir
Author by

dov.amir

JAVA fullstack developer GitHub https://github.com/DovAmir Tech blog http://opensourceinsights.blogspot.co.il Linkedin http://www.linkedin.com/in/dovamir

Updated on September 16, 2020

Comments