Home
Name Modified Size InfoDownloads / Week
README.txt 2013-08-27 11.0 kB
plugin.pdf 2013-08-27 144.0 kB
dao4j.zip 2013-08-27 1.2 MB
Totals: 3 Items   1.4 MB 0
---------------
  DAO4J v1.19
---------------

INTRODUCTION
------------
    Welcome using DAO4J. DAO4J is a free DAO Generator for Java. 
    
    DAO4J can generate clear and efficient Java source files to populate Database tables via standard JDBC.
    
    Currently, DAO4J doesn't support relationships among tables because I believe that the mapping 
    between one DTO Class and one DB table is enough for DAO layer in most J2EE projects. 
    The business layer often use and coordinate the activities of multiple Dao Access Objects, and may 
    provide transaction services if necessary.

CHANGE LOG
----------
    Version 1.19 (updated on 08/27/2013)
        1. Add setNull for wrapper objects.
        2. Several trivial changes.

    Version 1.18 (updated on 06/07/2012)
        1. Recompiling against JDK 1.6.0 and Squirrel 3.0.3.

    Version 1.17 (updated on 10/11/2011)
        1. Deal with special characters of @$# in table field names.
        2. Avoid a variable name collision in the generated java file.

    Version 1.16 (updated on 12/11/2007)
        1. Recompiling against JDK 1.5.0 and Squirrel 2.6.2.
    
    Version 1.15 (updated on 11/23/2005)
        1. Add a reference of Key object in the Bean object.
    
    Version 1.14 (updated on 10/24/2005)
        1. Fix a bug (decimal) in the file of "sqlserver.properties".
    
    Version 1.13 (updated on 8/18/2005)
        1. Support defining pricision and scale parameters for NUMBER, NUMERIC and DECIMAL types in TypeMapping file.
        2. Add default number(p|s), numeric(p|s) or decimal(p|s) types to oracle.properties, sybase.properties and sqlserver.properties.

    Version 1.12 (updated on 8/12/2005)
        1. Fix a regression bug of wrong field name in generated DAOImpl java file when it contains "_" since v1.10.
        2. Do not always change field names to lowercase to avoid SQLException for some case-sensitive DB, such as Sybase.
        
    Version 1.11 (updated on 8/02/2005)
        1. Set default value of DB Type Definition by JDBC URL.
        2. Add dbmapping files of SQL Server and InstantDB.
        
    Version 1.10 (updated on 8/01/2005)
        1. Make DAO4J a PlugIn of "SQuirreL SQL Client", so it can be used as a GUI program.
        2. dbDataType can contain spaces.

    Version 1.05 (updated on 7/22/2005)
        1. Fix a bug of wrong method name intValueValue().
        2. Add an option "nullProperty" to allow users set null values to the Bean's properties if necessary.
        
    Version 1.04 (updated on 6/19/2005)
        1. Add clone() method to the DTO and DTOKey classes.
        
    Version 1.03 (updated on 6/12/2005)
        1. Add the optional keyword 'FROM' to the DELETE statement.
        
    Version 1.02 (updated on 12/17/2004)
        1. Fix a bug in the getResults(ResultSet rs) method of DAOImpl class.
        2. Add TAB as a separator in the TableDef file.
    
    Version 1.01 (updated on 9/27/2004)
        1. Add toString() method to the DTO and DTOKey classes.
        2. beautify the format of generated codes. 
    
    Version 1.00 (created on 9/8/2004)
    
REQUIREMENTS
------------
The JRE 1.6.0 or higher is required to run DAO4J.

GUI USAGE
-----
1. Decompressed dao4j.zip to a folder, such as <DAO4J_HOME>.
2. Download "SQuirreL SQL Client" from http://squirrel-sql.sourceforge.net/
3. Install "SQuirreL SQL Client" to a folder, such as <SQuirreL SQL Client>.
4. Extract file <DAO4J_HOME>/dao4j-plugin.zip to <SQuirreL SQL Client>/plugins.
5. Start SQuirreL SQL Client.
6. In the Session Window, right-click the Table or View objects for which you want generate DAO classes.
7. Click "Generate DAO" on the popup menu.
8. Set the configuration info for DAO4J in the Dialog, and then click OK Button.
9. A message window will be popuped to report the generation results.

Please refer to the plugin.pdf for more details.

COMMAND LINE USAGE
-----
1. Define table schema
    Prepare a plain text file which defines the table schema for which you want to 
    generate DAO java source files. 
    
    The file should contain 3 columns:
        fieldName, dbDataType, primaryKey
        
        fieldName  : the name of the table field.
        dbDataType : the data types which your database used.
        primaryKey : 1 or pk means PK, 0 means non-PK.
        
    For example:
        
        order_no        int              1
        order_type      smallint         1
        order_date      datetime         0
        value           numeric          0
        buyer           "long varchar"   0

    You can also special syntax to define numeric(p,s), number(p,s) and decimal(p,s) types. The syntax is
    <TYPE>(p|s) , such as:
        number(10|0), number(10|1) and so on...
    
    Note: If dbDataTypes contains white spaces, Please enclose it with quotation marks, 
          such as "long varchar", otherwise DAO4J can not parse it rightly.
    
2. Define type mappings
    Prepare a plain text file which defines the mappings between dbDataTypes and javaDataTypes.
    
    Syntax is dbDataTypes=javaDataTypes
    
    For example:

        bit=boolean
        tinyint=byte
        smallint=Short
        int=int
        real=float
        float=float
        double=double
        numeric=java.math.BigDecimal
        decimal=java.math.BigDecimal
        money=java.math.BigDecimal
        char=String
        varchar=String
        long\ varchar=String
        text=String
        binary=byte[]
        varbinary=byte[]
        image=byte[]
        datetime=java.util.Date
        smalldatetime=java.sql.Timestamp
        timestamp=java.sql.Timestamp
    
    There are special syntax to define numeric(p,s), number(p,s) and decimal(p,s) types. You can 
    define them as <TYPE>(p|s), such as:
        number(10|0) which means precision ranges 0 to 10, and scale is 0.
        number(11-30|0) which means precision ranges 11 to 30, and scale is 0.
        number(2-5|1) which means precision ranges 2 to 5, and scale is bigger than 0.
    
    If the parser doen't find the exact <TYPE>(p|s) definition, then the mapping of <TYPE>=javaDataTypes
    is used by default.
    
    Note: If dbDataTypes contains white spaces, please escape it with a backslash character, such as "\ ",
          otherwise DAO4J can not parse it rightly.
          There are some pre-defined Database TypeMapping files under <DAO4J_HOME>/conf/ or 
          <SQuirreL SQL Client >/plugins/dao4j/conf/. The file names are <database>.properties,
          such as "oracle.properties", "sybase.properties" ... ...
          For more informations about valid Java Data Types which are supported by DAO4J, 
          please refer to APPENDIX  --  Supported Java Data Types.

3. Run DAO4J to generate DAO java source files
    java -jar dao4j.jar [option]..

          -c,--class          Specify the Class name for genarated Javabeans. It
                              will be guessed by tableName if not specified
          -d                  Specify where to place the generated files. Default
                              value is current workdir
          -h,--help           Print this help message
          -i,--in             Required. Specify the input file which contains table
                              schema
          -m,--mapping        Required. Specify the name of typeMappinf file
          -n,--nullProperty   Indicate whether to set null value to the Bean's
                              property if it is null in the table
          -p,--package        Required. Specify the package name for genarated Java
                              source files
          -t,--tableName      Required. Specify the table name
    
    For example:
        
        java hlg.zhaoliang.dao4j.Main \
            -d source \
            --in table.def \
            --tableName business_order \
            --mapping conf\\DBTypeMapping.properties  \
            --class Order \ 
            --package com.company.project
        
        which will generate the following java source files:
            source\com\company\project\Order.java
                -- This is the DTO Class
            source\com\company\project\OrderKey.java
                -- The DTO Class which contains only the PK fields and can be used as the key of HashMap
            source\com\company\project\dao\OrderDAO.java
                -- The DAO interface
            source\com\company\project\orm\OrderDAOImpl.java
                -- The DAO Impl Class

APPENDIX  --  Supported Java Data Types
-------------------------------------------
        Primary Type:
                        boolean
                        byte
                        byte[]
                        short
                        int
                        long
                        float
                        double
        
        Wrapper Classes:
                        Boolean
                        Byte
                        Short
                        Integer
                        Long   
                        Short
                        Double
                        String
        
        Other Classes:
                        java.math.BigDecimal
                        java.sql.Array
                        java.sql.Blob
                        java.sql.Clob
                        java.sql.Date
                        java.sql.Ref
                        java.sql.Struct
                        java.sql.Time
                        java.sql.Timestamp
                        java.util.Date

    Note:
        The Wrapper Classes which are in java.lang package MUST NOT have package name.
        Other Classes MUST have package names;
        
LIBRARYS
--------
    The jar file which has all dependent classes is under ${DAO4J}\lib, please add the it 
    to the classpath before you run DAO4J.
        
        UNIX:
            $CLASSPATH=dao4j.jar:$CLASSPATH
            export $CLASSPATH
        WINDOWS:
            set CLASSPATH=dao4j.jar;%CLASSPATH%
    
    Run DAO4J:
        
        java hlg.zhaoliang.dao4j.Main
      
    Or you can run DAO4J like this:
    
        java -jar dao4j.jar [option]...

    Note: 
        This product includes software developed by the Apache Software Foundation (http://www.apache.org/).
        For more information on the Apache Software Foundation, please see <http://www.apache.org/>.

CONTACTS
--------
    Website
        http://sourceforge.net/projects/dao4j
    
    If you find bugs or have any comments about DAO4J, please send emails to 
        
        b-i-d@163.com
    
    Your comments are very valuable to improve DAO4J.
    
    Thank you!   

Zhao Liang
hlg, Beijing, China
08/27/2013
Source: README.txt, updated 2013-08-27