隨筆 - 16  文章 - 0  trackbacks - 0
          <2011年9月>
          28293031123
          45678910
          11121314151617
          18192021222324
          2526272829301
          2345678

          常用鏈接

          留言簿

          隨筆檔案

          友情鏈接

          搜索

          •  

          最新評論

          閱讀排行榜

          評論排行榜

          第一步、配置實體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 民工二代 閱讀(315) | 評論 (0)編輯 收藏
               摘要: 在線創建Oracle分區表
          第一步,檢查源表是否可以在線重定義;
          第二步、創建一張分區表做為中間表;
          第三步、拷備源表中的記錄;
          第四步、同步更新數據;
          第五步、轉換完成  閱讀全文
          posted @ 2012-06-18 09:23 民工二代 閱讀(354) | 評論 (0)編輯 收藏
          最近因為開發需要,自己做了一個小的Demo部署在網上,具體網址http://www.17chuxing.com,實現一個類似公交查詢的功能,目前基本上能夠正常運行。

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

               4、采用gzipFilter對請求進行壓縮,減少每次請求所需網絡流量;
                  <filter>
                      <filter-name>gzipFilter</filter-name>
                      <filter-class>net.sf.ehcache.constructs.web.filter.GzipFilter</filter-class>
                  </filter>
               5、首頁盡可能減少跳轉(redirect),因為每次跳轉都需要一定的時間;

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

          三、其他方面;
                1、向搜索引擎提交網站
                2、其它思考點,通過rewrite 技術實現反寫,生成相應的靜態文件;
          <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 民工二代 閱讀(522) | 評論 (0)編輯 收藏
          調試環境:struts,Spring,jsp

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

          <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>

          第二步:配置監聽
          在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
          文檔內容如下:
          <?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>
           <!--裝飾名稱,可以設置多個-->
           <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>



          第五部:編寫裝飾模板并引用標簽
          在<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>

          第五部:測試
          期待正確的結果。

          posted @ 2012-03-15 09:00 民工二代 閱讀(1544) | 評論 (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>
                      <!--說明事務類別 read-only表示不支持事務,propagation的事務類別與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>

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

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

          posted @ 2012-03-13 10:56 民工二代 閱讀(312) | 評論 (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 民工二代 閱讀(433) | 評論 (0)編輯 收藏

                  昨天參與了項目組的用例需求評審會,發現大家對用戶用例與系統用例存在部分差異,包括架構師與需求分析師對他的理解,最后經過總結明確如下:
                  1、通過對業務流程進行梳理,得出業務流程圖,通過“用戶用例”編寫對業務流程圖進行細化;
                  2、“用戶用例”的編寫主要目的:用于描述業務現狀,正常情況是怎么樣做的,出現異常了什么做的;不需要考慮“做什么”與“怎么做”,如果該業務的部分操作已經由系統實現,盡可能的規避原有的系統操作,以免被原來的系統框架限制;說簡單一點就是“什么人,在什么情況下,做了什么事,有什么結果”;
                  3、“系統用例”的編寫目的:主要是根據“用戶用例”分析得出,要系統要“做什么”,需要考慮有什么業務規則,但是該階段仍然不需要考慮怎么做;“系統用例”需要考慮做事要遵循哪些業務規則,提前告知應用設計師,設計時要考慮哪些問題,如何處理異常流程;

          posted @ 2012-03-08 08:45 民工二代 閱讀(1429) | 評論 (0)編輯 收藏
               摘要: 經過IBM老師的培訓,對性能優化方面進行一個簡單的總結

          系統優化從架構層面,可以考慮從以下方面進行思考:
          一、結構
          1、業務需求方面
          與用戶溝通確認,自己對業務理解是否存在誤區,用戶對業務響應的期望本身就沒有那么高;
          2、產品選型
          應該反思我們在選擇產品方面是否存在缺陷,軟件的設計初衷就與你的希望不一致,還要需要考慮產品是否支持容錯、集群、橫向擴展等
            閱讀全文
          posted @ 2012-02-29 13:29 民工二代 閱讀(1579) | 評論 (0)編輯 收藏
          <!-- 查詢腳本 -->
           <select id="query" parameterType="Province" resultMap="provinceMap">
            <![CDATA[
             select fid,fname,fnumber,fsimpleName,fdescription,fcreateTime,flastUpdateTime,fdirect
             from t_yp_province
             where fname like '%'|| #{name} || '%'
            ]]>
           </select>
          posted @ 2012-02-25 11:24 民工二代 閱讀(373) | 評論 (0)編輯 收藏

          我們在使用 Hibernate scalar 中 hibernate類型 Hibernate.DATE獲取的數據只包含年月日不包含時分秒數據,即只能 2010-01-15 ,
          所以一定要改成 Hibernate.TIMESTAMP ,然后在前臺進行格式化。

          posted @ 2012-02-22 17:34 民工二代 閱讀(366) | 評論 (0)編輯 收藏
               摘要: import org.springframework.test.context.ContextConfiguration;
          import org.springframework.test.context.junit4.AbstractTransactionalJUnit4SpringContextTests;

          /**
          引入Spring配置文件,以便注入
          **/
          @ContextConfiguration(
          locations = {"classpath:/mybatis-config.xml" ,
          "classpath:/application-resources.xml",
          "classpath:/application-dao.xml",
          "classpath:/application-service.xml",
          "classpath:/application-s  閱讀全文
          posted @ 2012-02-22 16:24 民工二代 閱讀(1287) | 評論 (0)編輯 收藏
          mybatis insert空值報空值異常,但是在pl/sql不會提示錯誤,主要原因是mybatis無法進行轉換,

          解決方法:

          在insert語句中,增加jdbcType解決問題

          <insert id="save" parameterType="Province">
            <![CDATA[
            insert into t_yp_province
            (fid,fname,fnumber,fsimpleName,fdescription,fcreateTime,flastUpdateTime,fdirect)
            values
            ( #{id,jdbcType=VARCHAR},
             #{name,jdbcType=VARCHAR},
             #{number,jdbcType=VARCHAR},
             #{simpleName,jdbcType=VARCHAR},
             #{description,jdbcType=VARCHAR},
             #{createTime,jdbcType=DATE},
             #{lastUpdateTime,jdbcType=DATE},
             #{direct,jdbcType=NUMERIC}
            ) 
            ]]>
           </insert>;

          更多jdbcType請參考以下網址
          http://www.jarvana.com/jarvana/view/org/mybatis/mybatis/3.0.1/mybatis-3.0.1-javadoc.jar!/org/apache/ibatis/type/JdbcType.html
          posted @ 2012-02-22 12:18 民工二代 閱讀(2842) | 評論 (0)編輯 收藏
               摘要: 通過Maven快速搭建Struts2 + Spring + myBatis開發環境,避免自己下載各類Java包引起的版本沖突,POM.xml負責整個Maven工程的jar包依賴管理管理。

          POM.xml文件內容如下
            閱讀全文
          posted @ 2012-02-14 11:25 民工二代 閱讀(2864) | 評論 (0)編輯 收藏
          Enum Constant Summary
          ALL
                    Cascade all operations
          MERGE
                    Cascade merge operation
          PERSIST
                    Cascade persist operation
          REFRESH
                    Cascade refresh operation
          REMOVE
                    Cascade remove operation
          posted @ 2011-09-27 22:29 民工二代 閱讀(181) | 評論 (0)編輯 收藏
               摘要: 背景分析:
          在企業內部信息系統中,大部分的業務數據可以簡單的分成兩類:
          一、基礎數據,為業務處理提供必需參數,在MIS系統中的客戶信息、網點信息等等;
          二、業務單據,為實現企業信息流、數據流、資金流的流轉與控制提供業務數據支持,在快遞企業中的運單就是一個典型業務單據。

          簡單的說,基礎數據與具體業務關,業務單據就是只管具體業務。
          基礎數據的特點,1、涉及業務單據的引用問題,一旦引用就是不能刪除;2、為了方便數據歸類,使用編碼進行分類數,如在財務系統中的科目;3、為了增強基礎數據的可讀性,我們需要增加一個名稱屬性,如果名稱太長了,我們可以考慮增加一個檢查或者備注;
          業務數據呢,現實業務中所有單據都通過編碼進行區分,比如發票,業務發生后要記錄業務日期及記賬日期,當業務記錄錯誤時,我們要保證系統業務的原始記錄,不能對系統原始數據直接更改(審計叫做業務數據的靜止性),需要進行紅沖,然后然后寫入新的業務數據,新的業務數據業務編號、業務日期無需改變,記賬則要記錄到當前  閱讀全文
          posted @ 2011-09-20 23:50 民工二代 閱讀(465) | 評論 (0)編輯 收藏
          主站蜘蛛池模板: 澄城县| 临颍县| 博客| 兴安盟| 东丽区| 德州市| 南汇区| 得荣县| 客服| 金坛市| 禄丰县| 海原县| 乌鲁木齐县| 慈溪市| 辽阳县| 霞浦县| 泰来县| 台中市| 沙湾县| 平利县| 永川市| 京山县| 太仆寺旗| 明水县| 河北省| 武隆县| 辉县市| 康保县| 古丈县| 玛沁县| 普陀区| 恩平市| 河西区| 驻马店市| 刚察县| 清苑县| 营口市| 桦南县| 肇东市| 丹阳市| 龙岩市|