【发布时间】:2015-06-06 06:26:06
【问题描述】:
我正在使用带有 Hibernate 的 spring mvc。我使用 Hibernate 编写插入,但我找不到从我的数据库中写入搜索数据的方法。我在下面的示例中插入了一个我喜欢的过程。如何使用 SessionFactory Autowired 对象编写选择?
我想用 Hibernate 做select * from employee where username='hesh'。
@Repository
public class EmployeeDaoImpl implements EmployeeDAO{
@Autowired
private SessionFactory sessionFactory;
@Override
public void AddEmployee(Employee employee) throws ClassNotFoundException, SQLException {
this.sessionFactory.getCurrentSession().save(employee);
}}
【问题讨论】:
标签: hibernate