<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的構造型查詢均不支持distinct,但如果不使用構造型方式查詢又支持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 閱讀(1120) 評論(0)  編輯  收藏

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


    網(wǎng)站導航:
     
    主站蜘蛛池模板: 国产无遮挡裸体免费视频在线观看| 亚洲天堂免费在线视频| 在线观看免费播放av片| 亚洲经典千人经典日产| 亚洲精品视频专区| 亚洲成AV人片一区二区| 亚洲AⅤ优女AV综合久久久| 最近的中文字幕大全免费版| 午夜精品一区二区三区免费视频| 久青草国产免费观看| 亚洲精品无码一区二区| 亚洲一区二区三区不卡在线播放| 亚洲日本中文字幕区| 亚洲人成网77777色在线播放| 亚洲国产婷婷综合在线精品| 国产午夜免费秋霞影院| 毛片A级毛片免费播放| 无人影院手机版在线观看免费| 99热在线免费播放| 男人的天堂网免费网站| A片在线免费观看| 99久久免费国产精品热| 久久久受www免费人成| 一区二区三区免费视频播放器| 天天综合亚洲色在线精品| 亚洲AV永久无码精品网站在线观看| 亚洲sss综合天堂久久久| 亚洲av日韩av无码av| 亚洲三级中文字幕| 亚洲一欧洲中文字幕在线| 亚洲啪啪免费视频| 亚洲av无码国产综合专区| 国产精品亚洲片在线va| 亚洲精品一二三区| 久久亚洲中文字幕无码| 老司机午夜在线视频免费| 特级毛片aaaa免费观看| av片在线观看永久免费| 国产精品免费一区二区三区| 精品无码国产污污污免费网站国产 | 亚洲成人福利在线|