Skip to content
Advertisement

How to create a generic DAO for CRUD methods

I’m trying to create a generic DAO for the basic CRUD methods so that I can reuse the code, but I really have no clue how to start.

I already have a DAO for every class, and they work perfectly.

I read lots of tutorial, and downloaded projects, but I can’t adapt (or understand) it to my program.

Here is my class:

JavaScript

This is my GenericDAO that is not working

JavaScript

My Class.hbm.xml:

JavaScript

This is my HibernateUtil:

JavaScript

And my hibernate.cfg.xml:

JavaScript

I’d appreciate if someone could explain how to make it work.

Advertisement

Answer

Solution by duffymo

Use the Spring Boot CrudRepository: spring.io/guides/gs/accessing-data-jpa

User contributions licensed under: CC BY-SA
4 People found this is helpful
Advertisement