【问题标题】:Need a help to create hibernate query需要帮助来创建休眠查询
【发布时间】:2014-07-16 20:25:11
【问题描述】:

需要帮助来创建表是 jdwCustomerTlrdRef 的休眠查询,它应该采用所有 operation_spec = 客户名称。该方法应返回 sysId。

这是要查看的代码。请帮助我,我是这个休眠查询的新手。

公共 getCustomerTlrdRef(BigDecimal sysId) {

System.out.println("---- getAllCustomerTlrdRef " );

String query = "from JdwCustomerTlrdRef as jdwCustomerTlrdRef where jdwCustomerTlrdRef.operation_spec= '+customer_name+'";
Query q = getSessionFactory().getCurrentSession().createQuery(query);
List<JdwCustomerTlrdRef> customerTlrdRefSysId = q.list();

System.out.println(" List size: " + customerTlrdRefSysId.size());

return customerTlrdRefSysId;

}

【问题讨论】:

    标签: java sql hibernate


    【解决方案1】:

    这应该可行。

    String query = "from JdwCustomerTlrdRef jdwCustomerTlrdRef where jdwCustomerTlrdRef.operation_spec= '+ customer_name +'";
    

    否则,如果您想稍后在代码中传递参数,请按此方式进行。

    String query = "FROM JdwCustomerTlrdRef jdwCustomerTlrdRef WHERE jdwCustomerTlrdRef.operation_spec = :customer_name"
    

    然后在您的代码中,您可以通过这种方式传递参数。

    query.setParameter("customer_name", theCustomerNameParameter);

    【讨论】:

      猜你喜欢
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 2021-06-29
      • 2014-06-20
      • 1970-01-01
      • 1970-01-01
      相关资源
      最近更新 更多