From table a其中tabel为表对应的类

解决方案 »

  1.   

    select 'a' from table1 as t  其中'a'为一个普通的字符串而不是列名
      

  2.   

    没看懂,直接打出'a' 为什么还要用表?
    写 select 'a' 不就行了,好像用不到表
      

  3.   

    还要显示别的列,select 'a',field1 from table1
      

  4.   

    为什么还要用Hibernate呢?既然写成了那个样子,干吗还要用O/R mapping工具呢?
      

  5.   

    select cust.name.firstName from Customer as cust这里只取name的属性,但注意Customer是一个PO类!
    就是说你可以把table1映射到一个PO类,原理一样的啦!!
      

  6.   

    同意  kill8108(日月)
    select cust.name.firstName, company.companyName from Customer as cust, Company as company
      

  7.   

    >>>就是说你可以把table1映射到一个PO类,原理一样的啦!!Query也不一定需要返回持久对象或映射到一个PO类的,你可以这么做Session s = factory.openSession();
    Transaction tx=null;
    try {
    tx = s.beginTransaction();
    List auctions = s.createQuery(
    "select 'a', item.description from AuctionItem item "
    )
    .setMaxResults(100)
    .list(); Iterator iter = auctions.iterator();
    while ( iter.hasNext() ) {

    Object[] olist = (Object[])iter.next();
    String sName = (String)olist[0];
    String sDesc = (String)olist[1]; System.out.println(
    sName+"="+sDesc
    );
    }
    System.out.println(); tx.commit();
    }
    catch (Exception e) {
    if (tx!=null) tx.rollback();
    throw e;
    }
    finally {
    s.close();
    }