Deriving Class from Generic T

前端 未结 2 1989
南方客
南方客 2020-12-15 10:57

I have a parameterized hibernate dao that performs basic crud operations, and when parameterized is used as a delegate to fulfil basic crud operations for a given dao.

2条回答
  •  攒了一身酷
    2020-12-15 11:18

    You could have the Class passed as a constructor argument.

    public class HibernateDao  implements GenericDao {
    
        private final Class type;
    
        public HibernateDao(Class type) {
            this.type = type;
        }
    
        // ....
    
    }
    

提交回复
热议问题