0

有人可以告诉我如何在hibernate的本地sql中发送参数在下面的代码中,我想输入contract_id作为参数。

  List list=session.createSQLQuery("select {b.*},{p.*},{t.*} from bidtool.bt_boiler_plates b,bidtool.bt_profile p,bidtool.bt_trade_lane t "
            + "where b.contract_id=p.contract_id AND p.contract_id=t.contract_id AND ")
                  .addEntity("b",Boiler_Plates.class)
                  .addEntity("p",BidToolProfiles.class)
                  .addEntity("t",BidToolTradeLanes.class).list();

您的帮助将不胜感激。谢谢

4

2 回答 2

0

尝试:

List list=session.createSQLQuery("select {b.*},{p.*},{t.*} from bidtool.bt_boiler_plates b,bidtool.bt_profile p,bidtool.bt_trade_lane t "
            + "where b.contract_id=p.contract_id AND p.contract_id=t.contract_id AND contract_id=:contractId")
                  .addEntity("b",Boiler_Plates.class)
                  .addEntity("p",BidToolProfiles.class)
                  .addEntity("t",BidToolTradeLanes.class)
                  .setParameter("contractId", contractId).list();
于 2012-05-29T20:11:21.563 回答
0

看看这个..

Query query = session.createSQLQuery("select {b.*},{p.*},{t.*} from bidtool.bt_boiler_plates b,bidtool.bt_profile p,bidtool.bt_trade_lane t "
        + "where b.contract_id=p.contract_id AND p.contract_id=t.contract_id AND contract_id=:ID")
              .addEntity("b",Boiler_Plates.class)
              .addEntity("p",BidToolProfiles.class)
              .addEntity("t",BidToolTradeLanes.class);

List list = query.setInteger("ID", 1234).list();       
于 2012-05-29T20:17:38.487 回答