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

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

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

    waterye

    #

    IDEA常用的快捷鍵

    本文只介紹幾個常用的快捷鍵

    Ctrl+Space           // Complete Code, 與輸入法沖突, 改為Alt+S
    Ctrl+D               // 行復制, 或選定字符串復制
    Ctrl+Shift+N         // 打開文件
    Ctrl+J               // 插入代碼模板
    Alt+Insert           // Generate, 生成Constructor, setter, getter
    Ctrl+O               // 覆蓋方法
    Ctrl+I               // 實現方法
    Ctrl+Alt+T           // Surround With
    Ctrl+/               // 行注釋
    Ctrl+Alt+L           // 格式化代碼
    Alt+F7               // 查找使用情況
    Shift+F6             // 重命名
    F6                   // 移動
    Ctrl+Shift+F7        // 顯示字符串使用次數
    Alt+Delete           // 安全刪除

    posted @ 2005-08-29 01:30 waterye 閱讀(520) | 評論 (0)編輯 收藏

    Hibernate映射文件的生成方式

    映射文件是的生成方式

    在HB2.1.x時代, 使用的是middlegen生成hbm, 再通過hbm2java生成pojo
    <middlegen appname="${name}"    prefsdir="${build.gen-src.dir}"    gui="${gui}"    databaseurl="${database.url}"    initialContextFactory="${java.naming.factory.initial}"    providerURL="${java.naming.provider.url}"    datasourceJNDIName="${datasource.jndi.name}"    driver="${database.driver}"    username="${database.userid}"    password="${database.password}">
      
    <hibernate destination="${build.gen-src.dir}"    package="${name}.hibernate"    genXDocletTags="false"    genIntergratedCompositeKeys="false"    javaTypeMapper="middlegen.plugins.hibernate.HibernateJavaTypeMapper"/></middlegen>

    <target name="codegen" depends="middlegen">    <taskdef name="hbm2java"      classname="net.sf.hibernate.tool.hbm2java.Hbm2JavaTask"      classpathref="project.classpath"/>    <hbm2java output="${build.classes.dir}"        classpathref="project.classpath"        config="${src.dir}/config.xml">      <fileset dir="${build.gen-src.dir}/maintain/hibernate">          <include name="**/*.hbm.xml"/>      </fileset>    </hbm2java></target>

    <!-- config.xml -->
    <codegen>  <generate renderer="net.sf.hibernate.tool.hbm2java.BasicRenderer"/></codegen>

    到HB3.0.x時代, hbm的定義更靈活, middlegen已不更新, 使用idea手寫hbm, pojo(這時已比較熟悉)

    下一階段, 使用Hibernate Annotations(處于Beta狀態)


    說明:
    只介紹ddl --> hbm --> pojo方式
    很多hibernate tools是基于eclipse的, 所以沒用

    posted @ 2005-08-29 00:52 waterye 閱讀(2543) | 評論 (1)編輯 收藏

    GROOVY Beginners Tutorial

    Groovy終于有比較規范的教程

    http://docs.codehaus.org/display/GROOVY/Beginners+Tutorial

    posted @ 2005-08-26 21:27 waterye 閱讀(759) | 評論 (5)編輯 收藏

    MD5加密

    pl/sql版
    CREATE OR REPLACE function md5(input_string VARCHAR2return varchar2
    IS
    raw_input 
    RAW(128) := UTL_RAW.CAST_TO_RAW(input_string);
    decrypted_raw 
    RAW(2048);
    error_in_input_buffer_length EXCEPTION;
    BEGIN
    sys.dbms_obfuscation_toolkit.MD5(input 
    => raw_input, checksum => decrypted_raw);
    return lower(rawtohex(decrypted_raw));
    END;
    from: unknown

    Java版
    public static String encodePassword(String password, String algorithm)
    {
        
    byte[] unencodedPassword = password.getBytes(); 
        MessageDigest md 
    = null;
        
    try
        
    {
            md 
    = MessageDigest.getInstance(algorithm);
        }

        
    catch (Exception e)
        
    {
            
    return password;
        }

        md.reset();
        md.update(unencodedPassword);
        
    byte[] encodedPassword = md.digest();
        StringBuffer buf 
    = new StringBuffer();
        
    for (int i = 0; i < encodedPassword.length; i++)
        
    {
            
    if ((encodedPassword[i] & 0xff< 0x10)
            
    {
                buf.append(
    "0");
            }

            buf.append(Long.toString(encodedPassword[i] 
    & 0xff16));
        }

        
    return buf.toString();
    }
    from: appfuse

    python版
    1import md5
    2
    3= md5.new()
    4m.update("water")
    5print m.hexdigest()

    posted @ 2005-08-26 21:14 waterye 閱讀(2423) | 評論 (3)編輯 收藏

    Preview of new JDBC features for Spring 1.3

    支持命名參數查詢
    public List getPreferredBeer() {
        Map 
    params = new HashMap(2);
        
    params.put("unwantedBrand""Heineken");
        
    params.put("maxPrice"new BigDecimal(25.00));
        List l 
    = getJdbcTemplate().queryForList(
          
    "select id, price, brand from beers " +
          
    "where price < :maxPrice and brand <> :unwantedBrand",
          
    params);
        
    return l;
      }


    Preview of new JDBC features for Spring 1.3

    posted @ 2005-08-25 20:45 waterye 閱讀(544) | 評論 (3)編輯 收藏

    JIRA安裝小記

    安裝JIRA前,先準備好數據庫(oracle的數據管理比較放心)

    使用現有的開發數據庫,免去安裝Oracle等麻煩事, 增加表空間和用戶即可
    -- 創建表空間
    CREATE TABLESPACE jira LOGGING DATAFILE 'd:\oradata\orcl\jira.dbf' SIZE 2000M REUSE EXTENT MANAGEMENT LOCAL SEGMENT SPACE MANAGEMENT AUTO;

    -- 創建用戶
    CREATE USER jirauser IDENTIFIED BY jirauser DEFAULT TABLESPACE jira;

    -- 授權用戶
    GRANT DBA TO jirauser;
    REVOKE UNLIMITED TABLESPACE FROM jirauser; 
    ALTER USER jirauser QUOTA UNLIMITED ON jira;

    1. 下載atlassian-jira-professional-3.1.1-standalone.zip或atlassian-jira-enterprise-3.1.1-standalone.zip并解壓
    2. 確保有Java_Home
    3. 修改conf/server.xml
    driverClassName = oracle.jdbc.driver.OracleDriver

    url = jdbc:oracle:thin:@dbserver:
    1521:orcl

    username = jirauser

    password = jirauser
    4. copy ojdbc14.jar to common/lib
    5. 修改atlassian-jira/WEB-INF/classes/entityengine.xml的filed-type-name="oracle"
    6. run bin/startup.bat啟動tomcat, 訪問http://localhost:8080, ok!

    posted @ 2005-08-24 22:58 waterye 閱讀(4673) | 評論 (10)編輯 收藏

    OpenSessionInView模式

    Spring+Hibernate中,  集合映射如果使用lazy="true", 當PO傳到View層時, 出現未初始化session已關閉的錯誤,只能在dao先初始化
    parent.getChilds().size();

    Spring提供Open Session In View來解決這個問題, 有兩種方式
    1. Interceptor
        <!-- =========== OpenSession In View pattern ==============-->
        
    <bean id="openSessionInViewInterceptor"
              class
    ="org.springframework.orm.hibernate3.support.OpenSessionInViewInterceptor">
            
    <property name="sessionFactory" ref="sessionFactory"/>
        
    </bean>

        
    <bean id="urlMapping" class="org.springframework.web.servlet.handler.SimpleUrlHandlerMapping">
            
    <property name="interceptors" ref="openSessionInViewInterceptor"/>
            
    <property name="mappings">
                
    <props>
                ......
                
    </props>
            
    </property>
        
    </bean>
    2. Filter
    <web-app>
     
    <filter>
    <filter-name>hibernateFilter</filter-name>
    <filter-class>
    org.springframework.orm.hibernate.support.OpenSessionInViewFilter
    </filter-class>
    </filter>
     
    <filter-mapping>
    <filter-name>hibernateFilter</filter-name>
    <url-pattern>*.do</url-pattern>
    </filter-mapping>

    </web-app>

    說明: 個人更喜歡用Interceptor方式, filter是在web.xml中定義
    有了OpenSessionInView,并不是一切就ok了。簡單的crud可以,但對于復雜業務邏輯就要想點法子。

    OSIV默認是request per session的, 所以即使沒有顯式update(po),Hibernate也會幫你保存的,dao的業務判斷就無效,還好有evict()可用。
    update code
    // Controller
    public ModelAndView update() {
        p 
    = dao.getVo(id);
        bindObject(request);
        dao.update(p);
    }

    // Dao
    public Object getVo(id) {
        p 
    = getHibernateTemplate().get(clazz, id);
        p.getChilds().size();
        getHibernateTemplate().evict(p);
        
    return p;
    }

    public void update(p) {
        oldP 
    = getVo(id);
        
    // ++--(oldP);
        getHibernateTemplate().update(p);
        
    // ++--(p);
    }

    posted @ 2005-08-23 21:58 waterye 閱讀(5439) | 評論 (7)編輯 收藏

    IntelliJ IDEA 5.0.1 Update Now Available

    idea 5.0還是有些小bug的, 使用起來有點不爽, 5.0.1估計有不少bug fix

    下載中, http://download.jetbrains.com/idea/idea-5.0.1.exe

    官方的bug fix

    IntelliJ IDEA 5.0.1

    1. New annotation @NonNls for marking fields, etc. not presented in the UI & not needing localization.
    2. The Hard coded string literals inspection/quick fix now available in UI Designer forms.

    posted @ 2005-08-23 21:16 waterye 閱讀(960) | 評論 (5)編輯 收藏

    Groovy快速入門

         摘要: Groovy is an agile dynamic language for the Java 2 Platform that has many of the features that people like so much in languages like Python, Ruby and Smalltalk, making them available to Java developer...  閱讀全文

    posted @ 2005-08-22 21:52 waterye 閱讀(887) | 評論 (1)編輯 收藏

    使用Spring JDBC Framework簡化開發

    純JDBC操作, 對某些項目來說, 也許更好, Spring JDBC Framework讓你不用關心Connection, Statement, ResultSet.

    定義數據源
    <bean id="dataSource" class="org.springframework.jndi.JndiObjectFactoryBean">
        
    <property name="jndiName">
            
    <value>java:/comp/env/jdbc/oracle</value>
        
    </property>
    </bean>

    定義事務管理器
    <bean id="transactionManager" class="org.springframework.jdbc.datasource.DataSourceTransactionManager">
        
    <property name="dataSource" ref="dataSource" />
    </bean>

    定義dao
    <bean id="customerDAO" class="com.waterye.dao.impl.CustomerDAOImpl">
        
    <property name="dataSource" ref="dataSource" />
        
    <property name="transactionManager" ref="transactionManager" />
    </bean>

    demo
    public class CustomerDaoImpl extends JdbcDaoSupport implements CustomerDAO {
        
    private DataSource dataSource; 
        pirvate TransactionManager transactionManager;

        
    public void setDataSource(DataSource dataSource) {
            
    this.dataSource = dataSource;
        }

        
    public void setTransactionManager(DataSourceTransactionManager transactionManager) {
            
    this.transactionManager = transactionManager;
        } 

        
    public Map get(Integer id) throws Exception {
            String querySql 
    = "select * from customer where id = ?";

            
    return getJdbcTemplate().queryForMap(querySql, new Object[] { id }); 
        }

        
    public void insert(final Map customer) throws Exception {
            String seqSql 
    = "select customer_seql.nextval from dual"
            String insertSql 
    = "insert into customer (id, code, name, status) values (?, ?, ?, ?)";
            
            TransactionTemplate transactionTemplate 
    = new TransactionTemplate(transactionManager);
            transactionTemplate.execute(
    new TransactionCallbackWithoutResult() { 
                
    protected void doInTransactionWithoutResult(TransactionStatus status) { 
                    JdbcTemplate jdbcTemplate 
    = getJdbcTemplate();
                    
    int id = jdbcTemplate.queryForInt(seqSql);
                    Object[] params 
    = new Object[] { new Integer(id), customer.get("code"), customer.get("name"), map.get("status") };
                    jdbcTemplate.update(insertSql, params);
                }
            }
        }

        
    public void update(final Map customer) throws Exception {
            
    //  
        }

        
    public void delete(Integer id) throws Exception {
            String deleteSql 
    = "delete from customer where id = ?";

            TransactionTemplate transactionTemplate 
    = new TransactionTemplate(transactionManager);
            transactionTemplate.execute(
    new TransactionCallbackWithoutResult() { 
                
    protected void doInTransactionWithoutResult(TransactionStatus status) { 
                    getJdbcTemplate().update(deleteSql, 
    new Object[] { id });
                }
            }
        }

        
    public List findValidCustomers() throws Exception {
            String querySql 
    = "select * from customer where status = 'valid' order by code";

            
    return getJdbcTemplate().query(querySql, new OracleColumnMapRowMapper()); 
        }

    說明:
    1. 沒有使用聲明性事務, 使用編程式事務
    2. 沒有使用POJO模式,使用HashMap, (ActiveMapper還在sandbax狀態)
    3. OracleColumnMapRowMapper implements RowMapper, 實現oracle風格到java bean風格mapping
        如: 字段customer_id 對應rowMap.get("customerId");

    posted @ 2005-08-21 20:13 waterye 閱讀(2444) | 評論 (3)編輯 收藏

    僅列出標題
    共18頁: First 上一頁 10 11 12 13 14 15 16 17 18 下一頁 
    主站蜘蛛池模板: 一级毛片成人免费看免费不卡| 亚洲av无码av在线播放| 亚洲乱亚洲乱妇无码麻豆| 亚洲第一精品福利| 中文字幕亚洲精品无码| 亚洲AV电影天堂男人的天堂| 毛片免费在线视频| 区三区激情福利综合中文字幕在线一区亚洲视频1 | 欧美在线看片A免费观看| 免费一级一片一毛片| 亚洲va中文字幕无码久久| 亚洲avav天堂av在线网爱情| 国产天堂亚洲精品| 午夜视频在线免费观看| 亚洲精品一卡2卡3卡三卡四卡| 久久久久亚洲AV无码去区首| 国产嫩草影院精品免费网址| 亚洲熟妇无码爱v在线观看| 日本zzzzwww大片免费| 亚洲国产成人久久综合一区77 | 国精产品一区一区三区免费视频| 99在线精品视频观看免费| 亚洲日韩精品一区二区三区| 国产免费AV片在线观看| 亚洲国产激情一区二区三区| 久青草视频在线观看免费| 国产精品无码一二区免费 | 亚洲一区二区中文| 亚美影视免费在线观看| 日韩高清在线免费观看| 久久精品国产亚洲AV忘忧草18| 午夜寂寞在线一级观看免费| 亚洲一区在线观看视频| 午夜小视频免费观看| 99热在线日韩精品免费| 国产成人精品亚洲精品| 曰批视频免费40分钟试看天天| 久久亚洲精品成人| 国内免费高清在线观看| 久久国产免费直播| 亚洲精品成人久久|