【发布时间】:2012-04-18 14:26:24
【问题描述】:
我有一张桌子是 | 客户 ID |客户姓名 |客户国家|。
如何编写 HQL 查询来检索与 CustomerName 和 CustomerCountry 的组合对应的 CustomerId?
这是我的 CustomerDaoImpl:
@Repository
public class CustomerDaoImpl implements CustomerDao {
@Autowired(required=true)
private SessionFactory sessionFactory;
public Customer getCTID(String customerName, String customerCountry) {
return (Customer)
this.sessionFactory.getCurrentSession().createQuery(/* Some query that gets CTID corresponding to customerName and customerCountry*/);
}
}
我想使用此 CustomerId 并将其插入到我的 DeliveryTable 中以进行新的交付。我将 DTO 用于输入交付信息的表单,并且我将使用 DeliveryService 创建新交付,该交付使用 CustomerService 通过 CusomerDAO 检索 CustomerId。
感谢您的帮助, D
【问题讨论】:
-
这是一个非常基本的查询。你试过什么?你读过docs.jboss.org/hibernate/core/3.6/reference/en-US/html_single/…吗?
标签: java database spring hibernate hql