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

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

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

    隨筆 - 16  文章 - 0  trackbacks - 0
    <2012年3月>
    26272829123
    45678910
    11121314151617
    18192021222324
    25262728293031
    1234567

    常用鏈接

    留言簿

    隨筆檔案

    友情鏈接

    搜索

    •  

    最新評論

    閱讀排行榜

    評論排行榜

    第一步、配置實(shí)體Bean:
    @Entity
    @Table(name = "t_bd_city")
    public class City extends BaseObject {
       
        /**
         * 省份
         */
        @ManyToOne(fetch = FetchType.LAZY)
        @JoinColumn(name = "fprovinceid")
        private Province province;
    }

    第二步、手動提交保存方法:

    public abstract class CoreDaoHibernate<Entity extends CoreObject> implements CoreObjectDao<Entity> {

        /**
         * Log variable for all child classes. Uses LogFactory.getLog(getClass())
         * from Commons Logging
         */
        protected final Log log = LogFactory.getLog(getClass());
        private Class<Entity> persistentClass ;
        private HibernateTemplate hibernateTemplate;
        private SessionFactory sessionFactory;


        public CoreDaoHibernate(){
            Class<?> c = this.getClass();
            Type t = c.getGenericSuperclass();
            if(t instanceof ParameterizedType){
               this.persistentClass =  (Class<Entity>)((ParameterizedType) t).getActualTypeArguments()[0];
            }
        }

        public HibernateTemplate getHibernateTemplate() {
            return this.hibernateTemplate;
        }

        public SessionFactory getSessionFactory() {
            return this.sessionFactory;
        }

        @Autowired
        @Required
        public void setSessionFactory(SessionFactory sessionFactory) {
            this.sessionFactory = sessionFactory;
            this.hibernateTemplate = new HibernateTemplate(sessionFactory);
        }

        /**
         * {@inheritDoc}
         */
        @Override
        public Entity save(Entity object) {
            Entity result =  hibernateTemplate.merge(object);
            hibernateTemplate.flush();
            return result;
        }
    }

    第三步、配置web.xml
       <filter>
            <filter-name>lazyLoadingFilter</filter-name>
            <filter-class>org.springframework.orm.hibernate3.support.OpenSessionInViewFilter</filter-class>
            <init-param>
                <param-name>sessionFactoryBeanName</param-name>
                <param-value>sessionFactory</param-value>
            </init-param>
            <init-param>
                <param-name>singleSession</param-name>
                <param-value>true</param-value>           
            </init-param>
            <init-param>
                <param-name>flushMode</param-name>
                <param-value>AUTO</param-value>        
            </init-param>
        </filter>
      <filter-mapping>
            <filter-name>lazyLoadingFilter</filter-name>
            <url-pattern>/*</url-pattern>
        </filter-mapping>

    posted @ 2012-06-18 23:24 民工二代 閱讀(312) | 評論 (0)編輯 收藏
         摘要: 在線創(chuàng)建Oracle分區(qū)表
    第一步,檢查源表是否可以在線重定義;
    第二步、創(chuàng)建一張分區(qū)表做為中間表;
    第三步、拷備源表中的記錄;
    第四步、同步更新數(shù)據(jù);
    第五步、轉(zhuǎn)換完成  閱讀全文
    posted @ 2012-06-18 09:23 民工二代 閱讀(351) | 評論 (0)編輯 收藏
    最近因?yàn)殚_發(fā)需要,自己做了一個小的Demo部署在網(wǎng)上,具體網(wǎng)址http://www.17chuxing.com,實(shí)現(xiàn)一個類似公交查詢的功能,目前基本上能夠正常運(yùn)行。

    現(xiàn)在總結(jié)一下,以便以后查詢使用;
    一、技術(shù)方面
         1、demo的整體技術(shù)結(jié)構(gòu)采用比較簡單的Struts+spring+hibernate,struts 可以定義全局的異常、返回值、攔截器,hibernate采用統(tǒng)一的Spring-hibernate模板進(jìn)行數(shù)據(jù)提交,減少開發(fā)量。如果采用hiberante懶加載方式,需要手工flush(),web.xml需要增加lazyLoadingFilter;
        <filter>
            <filter-name>lazyLoadingFilter</filter-name>
            <filter-class>org.springframework.orm.hibernate3.support.OpenSessionInViewFilter</filter-class>
        </filter>
         2、數(shù)據(jù)量較小采用了mySql作為數(shù)據(jù)庫,采用mysql需要注意的是早期的mysql版本,表名區(qū)分大小寫,a 與A的結(jié)果不一樣;
         3、在展現(xiàn)層方面采用sitemesh裝飾器對展現(xiàn)的頁面進(jìn)行渲染(包括樣式、頁頭、頁腳、統(tǒng)計代碼),保證每個網(wǎng)頁的風(fēng)格一致性,并且可以減少一定開發(fā)工作量;
            <filter>
                <filter-name>sitemesh</filter-name>
                <filter-class>com.opensymphony.module.sitemesh.filter.PageFilter</filter-class>
            </filter>

         4、采用gzipFilter對請求進(jìn)行壓縮,減少每次請求所需網(wǎng)絡(luò)流量;
            <filter>
                <filter-name>gzipFilter</filter-name>
                <filter-class>net.sf.ehcache.constructs.web.filter.GzipFilter</filter-class>
            </filter>
         5、首頁盡可能減少跳轉(zhuǎn)(redirect),因?yàn)槊看翁D(zhuǎn)都需要一定的時間;

    二、部署流程
         1、申請域名
         2、選擇虛擬機(jī)托管商
         3、部署程序
         4、申請備案

    三、其他方面;
          1、向搜索引擎提交網(wǎng)站
          2、其它思考點(diǎn),通過rewrite 技術(shù)實(shí)現(xiàn)反寫,生成相應(yīng)的靜態(tài)文件;
    <filter>
            <filter-name>rewriteFilter</filter-name>
            <filter-class>org.tuckey.web.filters.urlrewrite.UrlRewriteFilter</filter-class>
            <!-- sets up log level (will be logged to context log)
                can be: TRACE, DEBUG, INFO (default), WARN, ERROR, FATAL, log4j, commons, sysout:{level} (ie, sysout:DEBUG)
                if you are having trouble using normal levels use sysout:DEBUG -->
            <init-param>
                <param-name>logLevel</param-name>
                <param-value>commons</param-value>
            </init-param>
            <!-- set the amount of seconds the conf file will be checked for reload
                can be a valid integer (0 denotes check every time,
                -1 denotes no reload check, default -1) -->
            <init-param>
                <param-name>confReloadCheckInterval</param-name>
                <param-value>-1</param-value>
            </init-param>
        </filter>
    posted @ 2012-04-25 13:16 民工二代 閱讀(519) | 評論 (0)編輯 收藏
    調(diào)試環(huán)境:struts,Spring,jsp

    第一步:安裝插件
    在pom.xml文檔中增加相應(yīng)依賴:

    <dependency>
       <groupId>org.sitemesh</groupId>
       <artifactId>sitemesh</artifactId>
       <version>2.4.2</version>
      </dependency>
      <dependency>
       <groupId>org.apache.struts</groupId>
       <artifactId>struts2-sitemesh-plugin</artifactId>
       <version>2.3.1.2</version>
      </dependency>

    第二步:配置監(jiān)聽
    在web.xml文檔中,增加過濾器
    <!-- sitemesh 裝飾器 -->
     <filter>
          <filter-name>sitemesh</filter-name>
          <filter-class>com.opensymphony.module.sitemesh.filter.PageFilter</filter-class>
     </filter>
      <filter-name>sitemesh</filter-name>
          <url-pattern>*</url-pattern>
     </filter-mapping>

    第三部:配置裝飾器
    在WEB-INF文件夾下,新建裝飾器配置文檔:decorators.xml
    文檔內(nèi)容如下:
    <?xml version="1.0" encoding="UTF-8"?>
    <!DOCTYPE decorators PUBLIC "-//OpenSymphony//SiteMesh 1.5 Decorators//EN" "<decorators defaultdir="/decorators"><!--文件夾可以修改-->
     <!-- 放棄裝飾部分 -->
         <excludes>
              <pattern>/40*.jsp</pattern>
              <pattern>/*ajax=true*</pattern>
              <pattern>/scripts/dojo/*</pattern>
              <pattern>/struts/dojo/*</pattern>
              <pattern>/resources/*</pattern>
         </excludes>
     <!--裝飾名稱,可以設(shè)置多個-->
     <decorator name="default" page="default.jsp">
          <pattern>*</pattern>
     </decorator>
    </decorators>

    第四步  在WEB-INF文件夾下,新建sitemesh配置文檔:sitemesh.xml
    <sitemesh>
        <property name="decorators-file" value="/WEB-INF/decorators.xml"/>
        <excludes file="${decorators-file}"/>
        <page-parsers>
            <parser default="true" class="com.opensymphony.module.sitemesh.parser.FastPageParser"/>
            <parser content-type="text/html" class="com.opensymphony.module.sitemesh.parser.FastPageParser"/>
            <parser content-type="text/html;charset=ISO-8859-1" class="com.opensymphony.module.sitemesh.parser.FastPageParser"/>
        </page-parsers>

        <decorator-mappers>
            <mapper class="com.opensymphony.module.sitemesh.mapper.ConfigDecoratorMapper">
                <param name="config" value="${decorators-file}"/>
            </mapper>
        </decorator-mappers>
    </sitemesh>



    第五部:編寫裝飾模板并引用標(biāo)簽
    在<decorators defaultdir="/decorators">指定的文件下,新加模板:default.jsp

    <!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN"
        "
    <%@ page language="java" contentType="text/html; charset=UTF-8"
     pageEncoding="UTF-8"%>
    <%@ taglib uri="
    <%@ taglib uri="<html xmlns="<head>
        <%@ include file="/common/meta.jsp"%>
        <title><decorator:title /> | Demo</title>
        <decorator:head />
    </head>
    <body
         <decorator:getProperty property="body.id" writeEntireProperty="true"/>
         <decorator:getProperty property="body.class" writeEntireProperty="true"/>>
         <div id="page">
              <div id="header" class="clearfix">
               <jsp:include page="/common/header.jsp" />
              </div>

              <div id="content" class="clearfix">
               <div id="main">
               <%@ include file="/common/messages.jsp"%>
          <h1>
               <decorator:getProperty property="meta.heading" />
          </h1>
              <decorator:body />
         </div> 
      <c:set var="currentMenu" scope="request">
       <decorator:getProperty property="meta.menu" />
      </c:set>
     
      <div id="nav">
       <div class="wrapper"></div>
        <hr />
       </div>
       <!-- end nav -->
      </div>
     
      <div id="footer" class="clearfix">
       <jsp:include page="/common/footer.jsp" />
      </div>
     </div>
    </body>
    </html>

    第五部:測試
    期待正確的結(jié)果。

    posted @ 2012-03-15 09:00 民工二代 閱讀(1542) | 評論 (0)編輯 收藏

    <beans xmlns=" xmlns:xsi="http://www.springframework.org/schema/beans
               http://www.springframework.org/schema/beans/spring-beans-3.1.xsd
               http://www.springframework.org/schema/context
               http://www.springframework.org/schema/context/spring-context-3.1.xsd        
               http://www.springframework.org/schema/aop
               http://www.springframework.org/schema/aop/spring-aop-3.1.xsd
               http://www.springframework.org/schema/tx
              

     <!-- 攔截配置 -->
     <tx:advice id="txAdvice" transaction-manager="transactionManager">
          <tx:attributes>
                <!--說明事務(wù)類別 read-only表示不支持事務(wù),propagation的事務(wù)類別與EJB保持一致-->
               <tx:method name="find*" read-only="true" />
               <tx:method name="get*" read-only="true" />
               <tx:method name="load*" read-only="true" />
               <tx:method name="save*" propagation="REQUIRED" />
               <tx:method name="insert*" propagation="REQUIRED" />
               <tx:method name="update*" propagation="REQUIRED" />
               <tx:method name="delete*" propagation="REQUIRED" />
               <tx:method name="*" propagation="REQUIRED" />
          </tx:attributes>
     </tx:advice>

     <!-- 切入點(diǎn) -->
     <aop:config>
          <!-- Dao層事務(wù) 說明你要攔截那些包下面的類的方法-->
          <aop:advisor id="daoTx" advice-ref="txAdvice"  pointcut="execution(* *..dao.impl.*.*(..))" order="0" />
          <!-- service層事務(wù) -->
          <aop:advisor id="serviceTx" advice-ref="txAdvice"  pointcut="execution(* *..service.impl.*.*(..))" order="1" />
     </aop:config>

     <!-- Enable @Transactional support -->
     <tx:annotation-driven />
     
     <!-- 事務(wù)管理 -->
     <bean id="transactionManager"  class="org.springframework.jdbc.datasource.DataSourceTransactionManager">
          <property name="dataSource" ref="dataSource" />
     </bean>
    。。。下面是具體的dataSource配置
    或下載附件
    http://www.tkk7.com/Files/yiqi/application-resources.rar

    posted @ 2012-03-13 10:56 民工二代 閱讀(303) | 評論 (0)編輯 收藏
    oracle 的 ojdbc無法支持通過maven使用,需要手工將oracle-ojdbc手工加入maven倉庫。

    mvn
    install:install-file
    -DgeneratePom=true
    -DgroupId=com.oracle
    -DartifactId=ojdbc14 
    -Dversion=10.2.0.4.0  版本號
    -Dpackaging=jar 打包方式
    -Dfile=D:\sale_workspace\sale\third_lib\ojdbc-14.jar 本地文件路徑
    posted @ 2012-03-13 09:09 民工二代 閱讀(427) | 評論 (0)編輯 收藏
    主站蜘蛛池模板: 亚洲一区二区无码偷拍| 免费人人潮人人爽一区二区| 成人免费一区二区无码视频| 亚洲jizzjizz少妇| 亚洲午夜无码久久久久| 亚洲精品国产免费| 免费成人激情视频| 欧美日韩亚洲精品| 亚洲熟女一区二区三区| 999国内精品永久免费视频| 久久亚洲精品无码gv| 亚洲s色大片在线观看| 成人免费激情视频| 一二三四在线观看免费中文在线观看| 久久99国产亚洲高清观看首页| 福利免费观看午夜体检区| h视频在线观看免费| 亚洲免费一级视频| 国产亚洲av人片在线观看| 麻豆最新国产剧情AV原创免费| 香蕉视频免费在线| 亚洲成a人片77777群色| 国产亚洲老熟女视频| 国内免费高清在线观看| 特级做A爰片毛片免费看无码| 亚洲乱码一区二区三区国产精品| 日韩精品亚洲aⅴ在线影院| 女人18毛片a级毛片免费| 日韩免费电影网址| 免费在线人人电影网| 亚洲AV成人噜噜无码网站| 亚洲精品无码成人AAA片| 日韩特黄特色大片免费视频| 19禁啪啪无遮挡免费网站| eeuss影院免费92242部| 亚洲成a∧人片在线观看无码| 亚洲美免无码中文字幕在线| 麻豆国产精品免费视频| 中国一级毛片视频免费看| 黄色免费网址在线观看| 亚洲综合中文字幕无线码|