11

I'm searching for free and simple DAO generator for java (it needs to create entities/bens from db tables/views and generate basic CRUD code). Currently, I`m using DAO4J which lacks some functionality like views mapping. I know that there are frameworks like Hibernate but I dont need such robust framework.

Some things this framework should have to do:

  • Generate CRUD operations with standard SQL queries and not compile-time typesafe queries
  • Doesn't have session concept like hibernate
  • Will not automatically close connection
  • JDBC Connection can be configured through code
Ivan Milosavljevic
  • 839
  • 1
  • 7
  • 19

6 Answers6

10

None of these are perfect matches, but both rock, in their own individual way:

  1. Spring Roo generates DAOs, Web Controllers and more for you.
  2. QueryDSL automatically creates Objects from your database tables and offers an Object-Oriented query syntax with compile-time safety.

But I'd say the winner is Spring Data. It offers a simple but powerful abstraction over many different underlying data store technologies and generates daos for you automatically. Here's a presentation of Spring Data JPA. Unfortunately Spring Data has not been released in final versions yet.

Sean Patrick Floyd
  • 292,901
  • 67
  • 465
  • 588
  • DeltaSpike (https://deltaspike.apache.org/) is an alternative by Apache, and a quick walk through can be seen at https://jaxenter.com/top-3-jpa-productivity-boosters-for-java-ee-developers-deltaspike-data-116136.html – Mahesh Sep 12 '17 at 05:45
  • @user3257644 I'd suggest you write that as an additional answer – Sean Patrick Floyd Sep 12 '17 at 15:27
7

If you just need a code generator without adherence to a framework, you should try Telosys Tools. It's a lightweight tool, it generates code from an existing database model.

See https://www.telosys.org

Some templates are specially designed for JDBC code generation, they are available on GitHub https://github.com/telosys-templates-v3

They offer code generation for DAO, DAO interfaces, POJO (beans), JUnit tests, etc

John T
  • 683
  • 8
  • 18
6

To add to duffymo's answer, MyBatis is good and you can use the MyBatis generator to generate data access code.

2

I wouldn't be much in favor of automatic generation.

I can recommend iBatis as a half step between JDBC and Hibernate.

duffymo
  • 305,152
  • 44
  • 369
  • 561
2

You can do this with Hibernate Tools. But I personally never tried it, I have only created entity classes by now.

Kai
  • 38,985
  • 14
  • 88
  • 103
  • The one thing I found with Hibernate, is that there can be a pretty steep learning curve once you get past the basic CRUD stuff. For me, the efficiency gains dropped pretty quickly once I got past initial prototyping. Sometimes it's easier just to use lead bullets. I now just use Spring JDBCTemplates. I think it provides a good mix of limiting boilerplate code while still allowing you to do complex queries. – BillMan Oct 29 '11 at 03:25
2

I would second iBatis. Other suggestion can be Spring JDBCTemplate. Since you are fine to adopt a framework, so why not go with Spring. It will also facilitate you with other great things.

Adeel Ansari
  • 39,541
  • 12
  • 93
  • 133