Reflection: .java to .class, to get .class
- Class.forName(…)
- “ClassName”.class
- “object”.getClass(), this method is in class “Object”
Generic: <>–typeof
Dao optimization:
- New interface “BaseDao” and its implementing class “BaseDaoImpl”1234567public interface BaseDao<T> {void add(T t);void update(T t);void delete(T t);T findById(int id);List<T> findAll();}
|
|
- Let normal interface Dao to extends BaseDao, then I can delete repetitive methods in normal interface Dao file.
public interface CustomerDao extends BaseDao<Customer>{...} // here CustomerDao is a concrete interface
- Let normal class Dao to extends BaseDaoImpl, then I can delete repetitive methods in normal class Dao file. The normal class do not need to extends HibernateDaoSupport because it has been done in BaseDaoImpl.
public class CustomerDaoImpl extends BaseDaoImpl<Customer> implements CustomerDao{...}
here CustomerDaoImpl is a concrete class