-1
    public List<ShoworderbybidId> queryTradesByBid(String bid) throws Exception {

  Session session=null;

  Transaction transaction=null;

  List<ShoworderbybidId> orders=new ArrayList<ShoworderbybidId>();

  try {

   session=HibernateSessionFactory.getSession();

   transaction=session.beginTransaction();

   Query query=session.createQuery("from Showorderbybid");// In this way, I could query all results from view Showorderbybid

   //Query query=session.createQuery("from Showorderbybid where bid = "+bid); //I try to use this code to find out the orders from a view(Showorderbybid) in my database. However, it failed. It said " Unknown column 'ru0001' (bid=ru0001) in 'where clause' "

   orders=(List<ShoworderbybidId>)query.list();

   transaction.commit();

  } catch (Exception e) {

   throw e;

  }finally{

   HibernateSessionFactory.closeSession();

  }

  return orders;

 }
4

1 回答 1

0

您可以使用条件来创建条件查询,但是您也可以使用您在代码中编写的内容,我认为“投标”列应该有问题,它的名称是否与 bean 中的名称相同?并给出你的错误跟踪。

于 2013-04-19T09:30:15.000 回答