躺在沙灘上的小豬

          快樂的每一天

          #

          Hibernate Query

          昨天在用hibernate無意中在后臺發(fā)現(xiàn)一個(gè)很奇怪的問題,一條SQL一直在重復(fù)執(zhí)行,跑了好半天也沒完成:(
          仔細(xì)的看了一下,原來是在查詢字典表,先執(zhí)行一次總的查詢出id,然后分別根據(jù)id分別select,這個(gè)字典表的內(nèi)容太多了,而且本身自關(guān)聯(lián)的。
          當(dāng)然我也知道這個(gè)只是第一次加載慢,第一次加載同時(shí)會被緩存,可是這個(gè)項(xiàng)目剛剛開始,這個(gè)字典表的改動是很頻繁的,需要根據(jù)客戶的需求而經(jīng)常變動,等穩(wěn)定下來再該回去。

          先修改為sql:

          ?select?c.categoryid?as?{category.Id},?c.categoryname?as?{category.Name}
          ???????????
          from?Tb_Article_Category?c
          ???????????
          where?c.categoryparentid?is null

          跑了一下,沒有通過:(

          Hibernate:?select?c.categoryId?as?categoryId0_0_,c.categoryName?as?category2_0_0_?
          ?????????????????????????????????? from?tb_article_category??c?where?c.categoryParentId?is?
          null

          [
          2006 - 03 - 20 ? 09 : 12 : 38 , 812 ] - ERROR?(JDBCExceptionReporter.java: 72 ) | Column? ' category3_0_0_ ' ?not?found.

          試著將表中所有的字段都寫出來便沒有錯(cuò)誤了,不太明白為什么非要我寫出所有字段,可是那并是我想要的,我也怕麻煩。

          目前我的做法是直接返回object [],沒有對每條記錄轉(zhuǎn)化為ArticleCategory對象。
          select ?c.categoryId,c.categoryName? from ?tb_article_category??c? where ?c.categoryParentId? is ? null ?

          ???????? for ?(Object?obj?:?list)? {
          ????????????Object?[]?str?
          =
          ?(Object[])?obj;
          ????????????System.out.println(String.valueOf(str[
          1
          ]));
          ????????}

          沒有修改之前:

          ?

          修改之后:
          ?

          posted @ 2006-03-20 09:15 martin xus| 編輯 收藏

          SVN Service

          http://dark.clansoft.dk/~mbn/svnservice/

          SVN Service Wrapper for Windows

          This is my Win32 Service wrapper for SVN. Source is included, and its in the public domain. No need to copyright this stuff.

          Usage instructions:
          
            SVNService -?                               to display this list
            SVNService -install <svnserve parameters>   to install the service
            SVNService -setup <svnserve parameters>     to change command line parameters for svnserve
            SVNService -remove                          to remove the service
            SVNService -debug                           to run as a console app for debugging
          
          Example:
          
            SVNService -install -d -r c:\svnrepo
            SVNService -setup -d -r c:\otherplace\svnrepo
          
          IMPORTANT:
          
            Make sure you place SVNService.exe in the same directory as svnserve.exe
          

          Special thanks go to Craig Link at Microsoft for creating the initial service.c.

          -Magnus Norddahl

          posted @ 2006-03-17 10:43 martin xus| 編輯 收藏

          IDEA Plugin:GroovyJ

          在最新的EAP版本下跑不起來,害的我又改用了IDEA5.1
          Home Page:
                  http://groovy.codehaus.org/IntelliJ+IDEA+Plugin

          posted @ 2006-03-16 12:54 martin xus| 編輯 收藏

          dwr集成spring

          dwr.xml

          <?xml version="1.0" encoding="UTF-8"?>
          <!DOCTYPE dwr PUBLIC "-//GetAhead Limited//DTD Direct Web Remoting 1.0//EN"
                  "http://www.getahead.ltd.uk/dwr/dwr10.dtd"
          >
          <dwr>
              
          <allow>
                  
          <create creator="spring" javascript="UserDAO">
                      
          <param name="beanName" value="userDao"/>
                      
          <include method="addUser"/>
                      
          <include method="removeUser"/>
                      
          <include method="findUserByName"/>
                  
          </create>

                  
          <convert converter="bean" match="martin.dwr.demo.model.User">
                      
          <param name="include" value="id,name,password,age"/>
                  
          </convert>

              
          </allow>
          </dwr>

          web.xml
          <?xml version="1.0" encoding="UTF-8"?>
          <!DOCTYPE web-app PUBLIC "-//Sun Microsystems, Inc.//DTD Web Application 2.3//EN"
                  "http://java.sun.com/dtd/web-app_2_3.dtd"
          >
          <web-app>

              
          <context-param>
                  
          <param-name>contextConfigLocation</param-name>
                  
          <param-value>/WEB-INF/classes/applicationContext.xml</param-value>
              
          </context-param>

              
          <listener>
                  
          <listener-class>
                      org.springframework.web.context.ContextLoaderListener
                  
          </listener-class>
              
          </listener>

              
          <servlet>
                  
          <servlet-name>dwr-invoker</servlet-name>
                  
          <servlet-class>uk.ltd.getahead.dwr.DWRServlet</servlet-class>
                  
          <init-param>
                      
          <param-name>debug</param-name>
                      
          <param-value>true</param-value>
                  
          </init-param>
                  
          <init-param>
                      
          <param-name>config-admin</param-name>
                      
          <param-value>WEB-INF/classes/dwr.xml</param-value>
                  
          </init-param>
              
          </servlet>

              
          <servlet-mapping>
                  
          <servlet-name>dwr-invoker</servlet-name>
                  
          <url-pattern>/dwr/*</url-pattern>
              
          </servlet-mapping>
          </web-app>

          applicationContext.xml
              <bean id="userDao" class="martin.dwr.demo.dao.hibernate.HibernateUserDAO">
                  
          <property name="sessionFactory" ref="sessionFactory"/>
              
          </bean>

          瀏覽:http://localhost:8080/demo/dwr/index.html 查看調(diào)試信息

          posted @ 2006-03-15 22:44 martin xus| 編輯 收藏

          配置spring,通過Annotations生成SessionFactory

          AnnotationSessionFactoryBean 繼承LocalSessionFactoryBean

          今天用到,查了一下refrence,順便把它貼出來:

          <?xml version="1.0" encoding="UTF-8"?>
          <!DOCTYPE beans PUBLIC "-//SPRING//DTD BEAN//EN"
                  "http://www.springframework.org/dtd/spring-beans.dtd"
          >
          <beans>
              
          <bean id="propertyConfigurer" class="org.springframework.beans.factory.config.PropertyPlaceholderConfigurer">
                  
          <property name="location">
                      
          <value>classpath:jdbc.properties</value>
                  
          </property>
              
          </bean>

              
          <bean id="c3p0DataSource" class="com.mchange.v2.c3p0.ComboPooledDataSource"
                    destroy-method
          ="close">
                  
          <property name="driverClass">
                      
          <value>${db.driverClass}</value>
                  
          </property>
                  
          <property name="jdbcUrl">
                      
          <value>${db.url}</value>
                  
          </property>
                  
          <property name="properties">
                      
          <props>
                          
          <prop key="c3p0.acquire_increment">5</prop>
                          
          <prop key="c3p0.idle_test_period">100</prop>
                          
          <prop key="c3p0.max_size">100</prop>
                          
          <prop key="c3p0.max_statements">0</prop>
                          
          <prop key="c3p0.min_size">10</prop>
                          
          <prop key="user">${db.user}</prop>
                          
          <prop key="password">${db.pass}</prop>
                      
          </props>
                  
          </property>
              
          </bean>

              
          <bean id="sessionFactory" class="org.springframework.orm.hibernate3.annotation.AnnotationSessionFactoryBean">
                  
          <property name="hibernateProperties">
                      
          <props>
                          
          <prop key="hibernate.dialect">${hibernate.dialect}</prop>
                          
          <prop key="hibernate.show_sql">${hibernate.show_sql}</prop>
                      
          </props>
                  
          </property>
                  
          <property name="dataSource" ref="c3p0DataSource"/>
                  
          <property name="annotatedClasses" value="martin.dwr.demo.model.User"/>
              
          </bean>

              
          <bean id="userDao" class="martin.dwr.demo.dao.hibernate.HibernateUserDAO">
                  
          <property name="sessionFactory" ref="sessionFactory"/>
              
          </bean>
          </beans>

          posted @ 2006-03-15 22:09 martin xus| 編輯 收藏

          僅列出標(biāo)題
          共28頁: First 上一頁 2 3 4 5 6 7 8 9 10 下一頁 Last 
          主站蜘蛛池模板: 平罗县| 新竹县| 防城港市| 五大连池市| 吉首市| 汤原县| 大冶市| 西安市| 屏东县| 阿荣旗| 荥阳市| 灵宝市| 盐源县| 武隆县| 江门市| 霞浦县| 福清市| 延庆县| 德钦县| 陆河县| 襄城县| 陈巴尔虎旗| 福鼎市| 西和县| 长垣县| 馆陶县| 浦县| 威宁| 明溪县| 宜君县| 农安县| 临潭县| 明光市| 高州市| 盐池县| 尼勒克县| 乐亭县| 伊金霍洛旗| 诸暨市| 宿松县| 新巴尔虎右旗|