我想使用 Hibernate 从数据库中检索特定记录。我想要做的在函数下面注释。
public List<Customer> showCustomer(long customerIdFromCustomerListPage)
throws Exception {
Session session = HibernateUtil.getSessionFactory().openSession();
Transaction transaction = null;
List<Customer> customerList = new ArrayList<Customer>();
try {
transaction = session.beginTransaction();
**//Select * from Customers where customerId="customerIdFromCustomerListPage"**
transaction.commit();
} catch (HibernateException e) {
transaction.rollback();
e.printStackTrace();
} finally {
session.close();
}
return customerList;
}