Hibernate 不使用泛型是有原因的吗?如果这样做,它将为开发人员节省大量演员表。
示例休眠代码:
Customer aCustomer = (Customer) session.load(Customer.class, 1L);
...
Criteria criteria = session.createCriteria(Customer.class);
Customer aCustomer = (Customer) criteria.uniqueResult();
如果正确使用泛型,它将变成:
Customer aCustomer = session.load(Customer.class, 1L);
...
Criteria<Customer> criteria = session.createCriteria(Customer.class);
Customer aCustomer = criteria.uniqueResult();