zoukankan      html  css  js  c++  java
  • hibernate

    -- select  后面没有加别名

    Encountered a duplicated sql alias [id] during auto-discovery of a native-sql query

    -- 看看数据库是否没有这个column

    could not extract ResultSet

    =====================================================================================================

    session.createQuery(queryStr).list();  //hql
    session.createSQLQuery(queryStr).list();  //普通sql

    ========================================================================

    hibernate 左连接:

    @Test
        public void testLetfJion() {
            Session session = sessionFactory.getCurrentSession();
            session.beginTransaction();
            String queryStr = "select stu from com.bjsxt.hibernate.Student as stu left join com.bjsxt.hibernate.Teacher as te on stu.id = te.id";
            session.createQuery(queryStr).list();
            session.getTransaction().commit();
        }

    报错:java.lang.IllegalStateException: DOT node with no left-hand-side!

    正确写法:

        @Test
        public void testLetfJion() {
            Session session = sessionFactory.getCurrentSession();
            session.beginTransaction();
            String queryStr = "select stu from com.bjsxt.hibernate.Student as stu ,com.bjsxt.hibernate.Teacher as te where stu.id = te.id";
            session.createQuery(queryStr).list();
            session.getTransaction().commit();
        }

    ============================================================================================

    IN适合于外表大而内表小的情况;EXISTS适合于外表小而内表大的情况。

  • 相关阅读:
    MapReduce案例WordCount
    MapReduce排序案例
    MapReduce倒排索引
    MapReduce自定义排序编程
    GroupingComparator 自定义分组
    CombineTextInputFormat小文件处理场景
    cdh 2.6.0版本和apache 2.7.x版本 本地执行环境的差异。
    DistributedCache 分布式缓存
    MapReduce数据压缩机制
    MapReduce其他功能
  • 原文地址:https://www.cnblogs.com/king-/p/6594433.html
Copyright © 2011-2022 走看看