-1

I am pretty new to hibernate was wondering if someone could help me out. I pretty much wrote the command how I would do it in SQL I tried a couple variations none worked was wondering if someone could point out how to do such a command in hibernate.

Query query = session.createQuery("from customer where customer_city = Harrison" 
            + " AND where customer_street = main" + " AND where customer_name = Hayes"); 
4

1 回答 1

0

我看到了一些可能导致问题的事情。首先,该where子句在 every 之后重复and。其次,您的 HQL 查询中有文字值,据我所知,这是不受支持的。通常,执行此类查询的代码如下所示:

String queryString
    = "from customer "
    + "where customer_city = ? "
    + "and customer_street = ? "
    + "and customer_name = ? ";
Query query = session.createQuery(queryString);
query.setString(0, "Harrison");
query.setString(1, "main");
query.setString(2, "Hayes");
List<Customer> customers = (List<Customer>) query.list();
于 2013-04-22T00:03:57.937 回答