Ignore:
Timestamp:
Jan 16, 2011, 10:00:07 PM (13 years ago)
Author:
fmguler
Message:

Refs #3 - Ven.delete() is converted to the new format. Missing javadocs are entered.

File:
1 edited

Legend:

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

    r26 r27  
    2727 
    2828/** 
    29  * Generates queries in the form of 'Convention over Configuration' of the specified class. 
     29 * Generates queries in the form of 'Convention over Configuration' for the specified objects. 
    3030 * @author Fatih Mehmet Güler 
    3131 */ 
     
    5353    } 
    5454 
    55     public String generateInsertQuery(Object object) throws VenException { 
     55    /** 
     56     * Generates insert query for the specified object 
     57     * @param object the object to generate insert query for 
     58     * @return the insert SQL query 
     59     */ 
     60    public String generateInsertQuery(Object object) { 
    5661        BeanWrapper wr = new BeanWrapperImpl(object); 
    5762        String objectName = Convert.toSimpleName(object.getClass().getName()); 
     
    9095 
    9196    /** 
    92      * Generates insert/update query 
    93      * @return the insert update SQL query 
     97     * Generates update query for the specified object 
     98     * @param object the object to generate update query for 
     99     * @return the update SQL query 
    94100     */ 
    95101    public String generateUpdateQuery(Object object) throws VenException { 
     
    114120        } 
    115121        query.deleteCharAt(query.length() - 1); 
    116         query.append(" where id = :id ;"); //TODO: remove the last comma 
     122        query.append(" where id = :id ;"); 
    117123        return query.toString(); 
    118124    } 
    119125 
     126    /** 
     127     * Generates delete query for the specified object class 
     128     * @param objectClass the object class to generate query for 
     129     * @return the delete SQL query 
     130     */ 
     131    public String generateDeleteQuery(Class objectClass){ 
     132        StringBuffer query = new StringBuffer(); 
     133        query.append("delete from ").append(Convert.toDB(Convert.toSimpleName(objectClass.getName()))).append(" where id = :id;"); 
     134        return query.toString(); 
     135    } 
     136         
     137    /** 
     138     * Generates sequence query for the specified object 
     139     * @param object the objectc to generate sequence query for 
     140     * @return the SQL query to select next id 
     141     */ 
    120142    public String generateSequenceQuery(Object object) throws VenException { 
    121143        String objectName = Convert.toSimpleName(object.getClass().getName()); 
Note: See TracChangeset for help on using the changeset viewer.