Changeset 29 for trunk/fmgVen/src


Ignore:
Timestamp:
Feb 10, 2011, 10:06:10 PM (13 years ago)
Author:
fmguler
Message:

Refs #3 - Ven.list() is converted to the new format. Almost the same as Ven.get(). Added javadoc to Ven public methods. Added listing test, and made the sample domain object toString methods more readable.

Now, adding the criteria parameter to the operations is to be done.

File:
1 edited

Legend:

Unmodified
Added
Removed
  • trunk/fmgVen/src/com/fmguler/ven/Ven.java

    r28 r29  
    4545    } 
    4646 
    47     public List list(Class objectClass) { 
    48         return null; 
    49     } 
    50  
    5147    public int count() { 
    5248        return 0; 
    5349    } 
    5450 
     51    /** 
     52     * Get the object with the specified id, of the specified objectClass type. 
     53     * <p> 
     54     * By default none of the associations will be retrieved. 
     55     * To include the object associations (retrieve the object graph) joins should be specified, e.g. 
     56     * <code>SomeObject.anotherObject</code> 
     57     *  
     58     * @param id the id of the object to be retrieved 
     59     * @param objectClass the class of the object to be retrieved 
     60     * @param joins the set of object graphs to be included with the object 
     61     * @return the retrieved object including specified associations 
     62     */ 
    5563    public Object get(int id, Class objectClass, Set joins) { 
    5664        String query = generator.generateSelectQuery(objectClass, joins); 
     
    6573        if (result.size() > 1) System.out.println("Ven - WARNING >> get(id) returns more than one row"); 
    6674        return result.get(0); 
     75    } 
     76 
     77    /** 
     78     * List the objects of the specified objectClass type. 
     79     * <p> 
     80     * By default none of the associations will be retrieved. 
     81     * To include the object associations (retrieve the object graph) joins should be specified, e.g. 
     82     * <code>SomeObject.anotherObject</code> 
     83     *  
     84     * @param objectClass the class of the objects to be retrieved 
     85     * @param joins the set of object graphs to be included with objects 
     86     * @return the list of objects including specified associations 
     87     */ 
     88    public List list(Class objectClass, Set joins) { 
     89        String query = generator.generateSelectQuery(objectClass, joins); 
     90 
     91        Map paramMap = new HashMap(); 
     92        if (debug) System.out.println("Ven - SQL: " + query); 
     93 
     94        List result = mapper.list(query, paramMap, objectClass); 
     95        return result; 
    6796    } 
    6897 
     
    124153    //-------------------------------------------------------------------------- 
    125154    //SETTERS 
     155    /** 
     156     * Set the DataSource to be used to access to the database 
     157     */ 
    126158    public void setDataSource(DataSource dataSource) { 
    127159        if (dataSource == null) throw new RuntimeException("fmgVen - DataSource cannot be null"); 
     
    130162    } 
    131163 
     164    /** 
     165     * Add the domain packages that have corresponding database tables. 
     166     * <p> 
     167     * The objects in these packages are considered persistable. 
     168     * @param domainPackage the package of the entity classes. 
     169     * @return this instance to allow chaining. 
     170     */ 
    132171    public Ven addDomainPackage(String domainPackage) { 
    133172        generator.addDomainPackage(domainPackage); 
Note: See TracChangeset for help on using the changeset viewer.