Spring Generic Dao class name

后端 未结 3 1371
时光说笑
时光说笑 2020-12-04 00:30

I have configured a custom generic service DAO for my spring / hibernate project - the idea being that I can reuse it easily from my controllers.

It essentially look

3条回答
  •  北海茫月
    2020-12-04 01:14

    It's better to define a specific class for Address service

    public class AddressService extends DefaultService
    { public String getClassName(){ return "Address"; } }

    where

    public String getClassName();
    

    is an abstract method declared in DefaultService, and used (like your method className()) in your data access logic.

    Using this approach, you will be able to add specific data access logic (example, getUsersByAddress)

提交回复
热议问题