• Hibernate实现对多个表进行关联查询


    Hibernate实现对多个表进行关联查询?

    String sTest = "from tBookInfo book, BookSelection sel where book.id = sel.bookId";
    Collection result = new ArrayList();
    Transaction tx = null;
    try {
     Session session = HibernateUtil.currentSession();
     tx = session.beginTransaction();
     Query query = session.createQuery(sql);
     result = query.list();
     tx.commit();
    } catch (Exception e) {
     throw e;
    } finally {
     HibernateUtil.closeSession();
    }
    ArrayList sList = (ArrayList) result;
    Iterator iterator1 = sList.iterator();
    while (iterator1.hasNext()) {
     Object[] o = (Object[]) iterator1.next();
     tBookInfo bookInfo = (tBookInfo) o[0];
     BookSelection bookSelect = (BookSelection) o[1];
     System.out.println("BookInfo-Title: " + bookInfo.getTitle());
     System.out.println("BookSelection-BookSelectionId: " + bookSelect.getId());
    }

  • 相关阅读:
    jquery自调用匿名函数解析
    C# 分页
    C#一般处理程序获取Session
    Python全栈开发,Day12
    Python全栈开发,Day11
    Python全栈开发,Day10
    Python全栈开发,Day9
    Python全栈开发,Day8
    Python全栈开发,Day7
    Python全栈开发,Day6
  • 原文地址:https://www.cnblogs.com/javaitpx/p/2766182.html
Copyright © 2020-2023  润新知