Hibernate: CRUD Generic DAO

后端 未结 5 1897
清酒与你
清酒与你 2020-12-02 06:46

My web application has got a lot of service tables/entities, such as payment_methods, tax_codes, province_codes, etc.

Each time

5条回答
  •  孤城傲影
    2020-12-02 07:17

    Do not write specific dao for each entity. You can implement one generic DAO that does 90% of work for all entities you need. You can extend it in cases you want specific treatment of certain entities.

    In project I am currently working on we have such DAO that wraps Hibernate session providing methods similar to those that you described. Moreover we are using ISearch API - the open source project hosted at google code and providing very convenient criteria building interface for Hibernate and JPA.

提交回复
热议问题