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

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

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

    軟件藝術思考者  
    混沌,彷徨,立志,蓄勢...
    公告
    日歷
    <2008年11月>
    2627282930311
    2345678
    9101112131415
    16171819202122
    23242526272829
    30123456

    導航

    隨筆分類(86)

    隨筆檔案(85)

    搜索

    •  

    最新評論

    閱讀排行榜

    評論排行榜

     
            hql 是一種近似于sql的db查詢語言。但它操作的元素已經由表名變為pojo類名,由表字段變為pojo的屬性名。這為程序員徹底的使用類來寫程序和查詢語句提供了方便。但大多數據程序員可能不知道,寫hql查詢其實也有它的編輯器,這就是myeclipse提供的 hql edit編輯器。
            怎樣來使用hql edit呢?
              1.創建一個hibernate 工程。然后在工程里添加一個hqlTest.hql文件。后綴必須是hql。
              2.右擊此文件,打開方式里應該有myeclipse hql editor 選項。如果沒有,請在eclipse的首選項里的文件關聯里把*.hql編輯器指定為myeclipse hql editor.
             3.打開后的編輯界面應該是下面的樣子:

    寫完后,點擊綠色的三角按鈕就是查詢。結果會出現 在編輯器的下方。如果你的hql沒問題的話。
    posted on 2008-11-17 14:19 智者無疆 閱讀(2397) 評論(3)  編輯  收藏 所屬分類: about java
    評論:
    • # re: spring service層的測試[未登錄]  lijun Posted @ 2008-11-21 12:04
      1.基類
      package com.movo.tv.test;

      import java.io.IOException;
      import java.util.Properties;

      import org.springframework.orm.hibernate3.SessionFactoryUtils;
      import org.springframework.test.AbstractTransactionalDataSourceSpringContextTests;


      import org.apache.log4j.Logger;
      import org.apache.log4j.PropertyConfigurator;
      import org.hibernate.Session;
      import org.hibernate.SessionFactory;

      import com.movo.tv.Constants;
      /*
      * AbstractTransactionalDataSourceSpringContextTests具體事務回滾能力,這樣測試數據不會成為臟數據.而且具有open session in test能力
      * 同時也就解決了lazy load 問題.但如果不想回滾的話,得注意每個test*方法結束前加上flushCurrentSession()方法.
      * by zy
      */
      public abstract class BaseServiceTestCase extends AbstractTransactionalDataSourceSpringContextTests {

      protected Logger log = Logger.getLogger(BaseServiceTestCase.class);
      /**
      * @see AbstractTransactionalDataSourceSpringContextTests#getConfigLocations()
      */
      @Override
      protected String[] getConfigLocations() {
      setAutowireMode(AUTOWIRE_BY_NAME);
      this.setDefaultRollback(true);
      Properties properties = new Properties();
      try {
      properties.load(this.getClass().getResourceAsStream("/spring/test/log4j.properties"));
      } catch (IOException e) {
      e.printStackTrace();
      }
      PropertyConfigurator.configure(properties);
      return new String[]{Constants.DEFAULT_CONTEXT, Constants.DEFAULT_TEST_CONTEXT};
      }

      protected void flushCurrentSession(){
      Session session = SessionFactoryUtils.getSession((SessionFactory)applicationContext.getBean("sessionFactory"), false);
      if (session !=null){
      session.flush();
      }
      }
      }

      2.測試類
      -------------------------------------------------
      package com.movo.tv.test.service;

      import java.util.List;

      import com.movo.tv.pojo.City;
      import com.movo.tv.test.BaseServiceTestCase;
      import com.movo.tv.yedian.service.CityService;

      public class TestCityServiceImp extends BaseServiceTestCase {

      CityService cityService;

      public CityService getCityService() {
      return cityService;
      }

      public void setCityService(CityService cityService) {
      this.cityService = cityService;
      }

      public void testCitiesOnLang(){
      Long timeStart_0 =System.currentTimeMillis();
      System.out.println("hibernate首次建立緩存:");
      //System.out.println("############ testCitiesOnLang start :"+timeStart);
      List<City> li_0 = getCityService().citiesOnLang("zh");
      City city;
      for(int i=0;i<li_0.size();i++){
      city=li_0.get(i);
      System.out.print("城市名:"+city.getCityname());
      }
      System.out.println("");
      System.out.println("############ testCitiesOnLang use time :"+(System.currentTimeMillis()-timeStart_0)+" 毫秒");

      Long timeStart =System.currentTimeMillis();
      System.out.println("首次使用hibernate二級緩存查詢的情況:");
      System.out.println("############ testCitiesOnLang start :"+timeStart);
      List<City> li = getCityService().citiesOnLang("zh");
      City city1;
      for(int i=0;i<li.size();i++){
      city1=li.get(i);
      System.out.println("城市名:"+city1.getCityname());
      }System.out.println("");
      System.out.println("使用時間 :"+(System.currentTimeMillis()-timeStart)+" 毫秒");

      Long timeStart2 =System.currentTimeMillis();
      System.out.println("第二次使用hibernate二級緩存查詢的情況:");
      System.out.println("使用時間 :"+timeStart);
      List<City> li2 = getCityService().citiesOnLang("zh");
      City city2;
      for(int i=0;i<li2.size();i++){
      city2=li2.get(i);
      System.out.println("城市名:"+city2.getCityname());
      }System.out.println("");
      System.out.println("使用時間 :"+(System.currentTimeMillis()-timeStart2)+" 毫秒");
      }



      }
        回復  更多評論   

    • # re: hql editor 的使用[未登錄]  lijun Posted @ 2008-11-24 13:48
      //for test
      public static final String DEFAULT_CONTEXT = "classpath*:spring/*.xml";
      public static final String DEFAULT_TEST_CONTEXT = "classpath*:spring/test/*.xml";

      public static final int DEFAULT_PAGE_SIZE = 20;

      public static final String CURRENT_LANGUAGE_SESSIONKEY = "CUL";  回復  更多評論   

    • # 胎教大全:可用飛速tudou下載[未登錄]  lijun Posted @ 2008-11-24 13:49
      http://v.ku6.com/special/index_2482375.html  回復  更多評論   

     
    Copyright © 智者無疆 Powered by: 博客園 模板提供:滬江博客


       觀音菩薩贊

    主站蜘蛛池模板: 国产18禁黄网站免费观看| 亚洲日本韩国在线| 免费无码婬片aaa直播表情| 精品国产人成亚洲区| 88xx成人永久免费观看| 亚洲AV无码专区在线观看成人 | 女同免费毛片在线播放| 亚洲国产精品自在在线观看| 国产精品免费观看久久| 一级毛片免费在线播放| 亚洲综合在线成人一区| 哒哒哒免费视频观看在线www| 三上悠亚在线观看免费| 亚洲香蕉在线观看| 亚洲日韩VA无码中文字幕| 91精品视频免费| g0g0人体全免费高清大胆视频| 亚洲中文字幕无码不卡电影| 麻豆一区二区免费播放网站| 一二三四在线观看免费中文在线观看| 免费午夜爽爽爽WWW视频十八禁| 国产色无码精品视频免费| 亚洲人成网站18禁止| 亚洲国产精品嫩草影院在线观看| 99视频全部免费精品全部四虎| 小说专区亚洲春色校园| 精品日韩亚洲AV无码| 国产91精品一区二区麻豆亚洲| 日韩免费视频一区二区| 黄色免费网址在线观看| 国产精品亚洲自在线播放页码| 亚洲国产成人精品91久久久| 国产人在线成免费视频| 97在线免费观看视频| 国产精品久久久久久亚洲小说| 91情国产l精品国产亚洲区| 亚洲麻豆精品国偷自产在线91| 日本高清在线免费| 日韩免费视频一区二区| 国产人成网在线播放VA免费| 日韩成人精品日本亚洲|