Changes between Version 4 and Version 5 of SERVER_DATABASE_PERSISTENCE


Ignore:
Timestamp:
02/18/10 15:51:57 (15 years ago)
Author:
meddle
Comment:

--

Legend:

Unmodified
Added
Removed
Modified
  • SERVER_DATABASE_PERSISTENCE

    v4 v5  
    6565   * For our purposes using JDBC is enough there is no need of ORM like Hibernate and bean model for it, because we will have small database. 
    6666   * The queries for selecting/updating/inserting data can be categorized and there will be one class that gives methods for using them. This class will capsulate all the actions using JDBC and will take care with the JDBC API for the developers. 
    67    * Class : JdbcTemplate -> Responsible for releasing all the JDBC resources that are used for query like ResultSets and Statements. It is not responsible for managing JDBC Connections. 
     67   * The base API is plased in the {{{org.sophie2.server.core.persistence.db.jdbc}}} package of the server core module, some of the implementations of the interfaces that are used for specific actions with resources are in the {{{org.sophie2.server.core.persistence.db}}} package, where is the Server Resource Persistence API, i.e. specific classes for managing resources. 
     68   * Class : [browser:branches/private/tsachev/paragraphs/modules/org.sophie2.server.core/src/main/java/org/sophie2/server/core/persistence/db/jdbc/JdbcTemplate.java JdbcTemplate] -> Responsible for releasing all the JDBC resources that are used for query like ResultSets and Statements. It is not responsible for managing JDBC Connections. 
    6869    * The JdbcTemplate class can be constructed with a ConenctionManager (used for retrieving of threadsafe connections to the DB and commit and rollback of transactions) 
    6970    * Public methods: 
     
    9899     * {{{public void rollbackCurrentTransation() throws SQLException}}} -> Rollbacks the current tansaction. 
    99100     * {{{public DataSource getDataSource()}}} -> Getter of the data source of the manager. 
     101   * Interface : [browser:branches/private/tsachev/paragraphs/modules/org.sophie2.server.core/src/main/java/org/sophie2/server/core/persistence/db/jdbc/RowMapper.java RowMapper<T>] -> Used to map a row of data selected from the database to an object or list of objects. 
     102    * Public methods: 
     103     * {{{public T mapRow(int rowNum, ResultSet rs) throws SQLException}}} -> Maps a specified row of the passed ResultSet (JDBC API) to an object or list of objects. 
     104    * Implementations: 
     105     * [browser:branches/private/tsachev/paragraphs/modules/org.sophie2.server.core/src/main/java/org/sophie2/server/core/persistence/db/LongRowMapper.java LongRowMapper] -> Maps the first cell in a row to a Long value. 
     106     * [browser:branches/private/tsachev/paragraphs/modules/org.sophie2.server.core/src/main/java/org/sophie2/server/core/persistence/db/StringRowMapper.java StringRowMapper] -> Maps the first cell to a String value. 
     107   * Interface : [browser:branches/private/tsachev/paragraphs/modules/org.sophie2.server.core/src/main/java/org/sophie2/server/core/persistence/db/jdbc/ResultSetMapper.java ResultSetMapper<T>] -> Maps a ResultSet (JDBC API, contains a result from query) to an Object or list of objects, its implementations often use RowMappers to iterate over the ResultSets. 
     108    * Public methods: 
     109     * {{{public void mapRow(int rowNum, ResultSet resSet) throws SQLException}}} -> Maps a row from the ResultSet to a value. 
     110     * {{{public T getResult()}}} -> Getter for the result of the mapping. Ususally the implementator will iterate through a ResultSet and for each of its rows will call mapRow ot the mapper, then after all the rows are iterated will retrieve the result with this method. OFten the implementations use RowMappers to map the columns of a given row. 
     111    * Implementations: 
     112     * [browser:branches/private/tsachev/paragraphs/modules/org.sophie2.server.core/src/main/java/org/sophie2/server/core/persistence/db/KeyMapper.java KeyMapper] -> Maps a result to pair keypath and its id in the database. 
     113     * [browser:branches/private/tsachev/paragraphs/modules/org.sophie2.server.core/src/main/java/org/sophie2/server/core/persistence/db/jdbc/ListMapper.java ListMapper<T>] -> Maps a result to a list of objects, uses RowMapper to map the separate rows.  
     114     * [browser:branches/private/tsachev/paragraphs/modules/org.sophie2.server.core/src/main/java/org/sophie2/server/core/persistence/db/jdbc/SingleResultMapper.java SingleResultMapper<T>] -> Maps a result to a single object, used with select queries that return only one row. 
     115   * Interface : [browser:branches/private/tsachev/paragraphs/modules/org.sophie2.server.core/src/main/java/org/sophie2/server/core/persistence/db/jdbc/ParametersSetter.java ParameterSetter<T>] -> Manages setting the parameters to a PreparedStatement (JDBC API) 
     116    * Public methods: 
     117     * {{{public void setParameters(int batchIndex, PreparedStatement stmnt) throws SQLException}}} -> Sets parameters to a specified statement, it can set different parameters to one statement and its first parameter means which batch of parameters will be set. 
     118     * {{{public int getBatchesCount()}}} -> The number of the batches of the parameters of the setter. 
     119    * Implementations: 
     120     * [browser:branches/private/tsachev/paragraphs/modules/org.sophie2.server.core/src/main/java/org/sophie2/server/core/persistence/db/jdbc/DefaultParameterSetter.java DefaultParameterSetter] -> Manages setting the parameters to a given statement. It is constructed with its parameters, represented as an array of objects for every batch. All the batches are contained in a Collection. 
     121 
     122      
    100123 == The API Used by the Facade and the Web Interface == 
     124  === ResourceDAO === 
     125  * DAOs (comes from Data Access Objects) are something like services that has simple methods for managing a database. They do contain only logic that keeps the data in database valid and logic for selecting of specified data. 
    101126 
    102127= Implementation =