Changeset 30 for trunk/fmgVen/src


Ignore:
Timestamp:
Apr 9, 2011, 12:44:03 PM (13 years ago)
Author:
fmguler
Message:

Fixes #3 - Criteria object is mostly implemented. An override of Ven.list() having criteria parameter is added. Old codebase only had string based criteria. In this commit, I am also adding typed criteria as a new feauture. With this new criteria system, user can create criteria object like;

new Criteria().eq(attr,value).like(attr,value).and().gt(attr, value).or().orderAsc(attr).orderDesc(attr).limit(limit, offset);

The orderings and the limit/offset values are not taken into account in the Ven (these are trivial, I will do them later).

Not thouroughly tested, because complex scenarios are only possible when applying to a real problem in a real application (which I am planning to do next).

Location:
trunk/fmgVen/src/com/fmguler/ven
Files:
1 added
1 edited

Legend:

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

    r29 r30  
    9797 
    9898    /** 
     99     * List the objects of the specified objectClass type, filtering according to some criteria. 
     100     * <p> 
     101     * By default none of the associations will be retrieved. 
     102     * To include the object associations (retrieve the object graph) joins should be specified, e.g. 
     103     * <code>SomeObject.anotherObject</code> 
     104     *  
     105     * @param objectClass the class of the objects to be retrieved 
     106     * @param joins the set of object graphs to be included with objects 
     107     * @param criteria to filter and order the result according to some criteria 
     108     * @return the list of objects including the specified associations filtered according to the specified criteria 
     109     */ 
     110    public List list(Class objectClass, Set joins, Criteria criteria) { 
     111        String query = generator.generateSelectQuery(objectClass, joins); 
     112        query += " where 1=1 " + criteria.criteriaStringToSQL() + " and " + criteria.criteriaToSQL(); 
     113 
     114        if (debug) System.out.println("Ven - SQL: " + query); 
     115 
     116        List result = mapper.list(query, criteria.getParameters(), objectClass); 
     117        return result; 
     118    } 
     119 
     120    /** 
    99121     * Save the object. If it has a non null (or non zero) "id" property it will be updated. 
    100122     * It will be inserted otherwise. 
Note: See TracChangeset for help on using the changeset viewer.