<rt id="bn8ez"></rt>
<label id="bn8ez"></label>

  • <span id="bn8ez"></span>

    <label id="bn8ez"><meter id="bn8ez"></meter></label>

    編程生活

       :: 首頁 :: 新隨筆 :: 聯(lián)系 :: 聚合  :: 管理 ::
      113 隨筆 :: 0 文章 :: 18 評論 :: 0 Trackbacks
    openJPA的0.9.7和1.0.0的構(gòu)造型查詢均不支持distinct,但如果不使用構(gòu)造型方式查詢又支持distinct,最后檢查JPQLExpressionBuilder.java的evalSelectClause(..)方法,發(fā)現(xiàn)是openJPA中的問題,我將其修改為:
    private Expression evalSelectClause(QueryExpressions exps) {
            
    if (exps.operation != QueryOperations.OP_SELECT)
                
    return null;

            JPQLNode selectNode 
    = root();

            JPQLNode constructor 
    = selectNode.findChildByID(JJTCONSTRUCTOR, true);
            
    if (constructor != null{
                
    // build up the fully-qualified result class name by
                
    // appending together the components of the children
                String resultClassName = assemble(left(constructor));
                exps.resultClass 
    = resolver.classForName(resultClassName, null);

                
    // now assign the arguments to the select clause as the projections
                JPQLNode selectClause = selectNode.findChildByID(JJTSELECTCLAUSE, false);
                
    if (selectClause != null && selectClause.hasChildID(JJTDISTINCT))
                  exps.distinct 
    = exps.DISTINCT_TRUE | exps.DISTINCT_AUTO;
                
    else
                  exps.distinct 
    = exps.DISTINCT_FALSE;
                
                
    return assignProjections(right(constructor), exps);
            }
     else {
                JPQLNode selectClause 
    = selectNode.
                    findChildByID(JJTSELECTCLAUSE, 
    false);
                
    if (selectClause != null && selectClause.hasChildID(JJTDISTINCT))
                    exps.distinct 
    = exps.DISTINCT_TRUE | exps.DISTINCT_AUTO;
                
    else
                    exps.distinct 
    = exps.DISTINCT_FALSE;

                
    // handle SELECT clauses
                JPQLNode expNode = selectNode.
                    findChildByID(JJTSELECTEXPRESSIONS, 
    true);
                
    if (expNode == null)
                    
    return null;

                
    int selectCount = expNode.getChildCount();
                JPQLNode selectChild 
    = firstChild(expNode);

                
    // if we are selecting just one thing and that thing is the
                
    // schema's alias, then do not treat it as a projection
                if (selectCount == 1 && selectChild != null &&
                    selectChild.getChildCount() 
    == 1 &&
                    onlyChild(selectChild) 
    != null &&
                    assertSchemaAlias().
                        equalsIgnoreCase(onlyChild(selectChild).text)) 
    {
                    
    return null;
                }
     else {
                    
    // JPQL does not filter relational joins for projections
                    exps.distinct &= ~exps.DISTINCT_AUTO;
                    
    return assignProjections(expNode, exps);
                }

            }

        }

    使用方式為:
    select DISTINCT new com.wile.test.AData(a.id, a.name,..) from A where a.id=?1
    目前已向openJPA提出此bug(bug-id:OPENJPA-420),希望他們能在1.0.1中進行修改
    posted on 2007-10-26 15:48 wilesun 閱讀(1123) 評論(0)  編輯  收藏

    只有注冊用戶登錄后才能發(fā)表評論。


    網(wǎng)站導(dǎo)航:
     
    主站蜘蛛池模板: 亚洲免费在线视频| 亚洲精品乱码久久久久蜜桃| 亚洲精品免费网站| 亚洲A∨精品一区二区三区下载| 在线亚洲午夜理论AV大片| 18pao国产成视频永久免费| 亚洲人成网站免费播放| 国产亚洲精品久久久久秋霞| 2021国内精品久久久久精免费| 亚洲丁香婷婷综合久久| 亚洲Av无码专区国产乱码DVD | 国产精品亚洲片夜色在线| 国产成人免费片在线视频观看| 国产在线精品免费aaa片| 亚洲国产日韩综合久久精品| 亚洲一本大道无码av天堂| 在线永久看片免费的视频| 一级做α爱过程免费视频| 亚洲乱码中文字幕小综合| 亚洲日韩VA无码中文字幕| 无码人妻一区二区三区免费| 巨胸喷奶水www永久免费| 亚洲人成电影网站色www| 久久久久无码精品亚洲日韩| 国产一级淫片免费播放| 亚洲一区二区三区免费在线观看| 和老外3p爽粗大免费视频| 亚洲欧美综合精品成人导航| 亚洲福利在线视频| 亚洲国产香蕉人人爽成AV片久久| 一个人在线观看视频免费| a级毛片100部免费观看| 在线观看免费亚洲| 久久久久亚洲国产| 4444亚洲国产成人精品| 亚洲中文字幕无码一区| 亚洲av麻豆aⅴ无码电影| 成人免费午间影院在线观看| 精品无码免费专区毛片| 18禁在线无遮挡免费观看网站| 日本黄页网址在线看免费不卡|