Index: trunk/fmgVen/src/com/fmguler/ven/Criteria.java
===================================================================
--- trunk/fmgVen/src/com/fmguler/ven/Criteria.java	(revision 36)
+++ trunk/fmgVen/src/com/fmguler/ven/Criteria.java	(revision 37)
@@ -43,4 +43,5 @@
 public class Criteria {
     private StringBuffer criteriaStringBuffer = new StringBuffer(); //for string criteria
+    private StringBuffer orderStringBuffer = new StringBuffer(); //for ordering
     private LinkedList criterionList = new LinkedList(); //for typed criteria
     private Map parameters = new HashMap(); //the parameters used in criteria string
@@ -99,4 +100,13 @@
     }
 
+    /**
+     * Return order string to SQL
+     */
+    public String orderStringToSQL() {
+        if (orderStringBuffer.length() == 0) return "";
+        orderStringBuffer.insert(0, " order by");
+        return orderStringBuffer.toString();
+    }
+
     //--------------------------------------------------------------------------
     //Typed Criteria Methods
@@ -153,5 +163,6 @@
      */
     public Criteria orderAsc(String attribute) {
-        //Not implemented yet.
+        if (this.orderStringBuffer.length() != 0) this.orderStringBuffer.append(",");
+        this.orderStringBuffer.append(" ").append(convertAttributeToAlias(attribute)).append(" asc");
         return this;
     }
@@ -161,5 +172,6 @@
      */
     public Criteria orderDesc(String attribute) {
-        //Not implemented yet.
+        if (this.orderStringBuffer.length() != 0) this.orderStringBuffer.append(",");
+        this.orderStringBuffer.append(" ").append(convertAttributeToAlias(attribute)).append(" desc");
         return this;
     }
@@ -223,13 +235,13 @@
                     stack.push(sr);
                 } else if (conn.equals(Criterion.CONN_OR)) {
-                        String s1 = (String)stack.pop();
-                        String s2 = (String)stack.pop();
-                        String sr = "(" + s1 + " or " + s2 + ")";
-                        stack.push(sr);
-                    } else if (conn.equals(Criterion.CONN_NOT)) {
-                            String s = (String)stack.pop();
-                            String sr = "not (" + s + ")";
-                            stack.push(sr);
-                        }
+                    String s1 = (String)stack.pop();
+                    String s2 = (String)stack.pop();
+                    String sr = "(" + s1 + " or " + s2 + ")";
+                    stack.push(sr);
+                } else if (conn.equals(Criterion.CONN_NOT)) {
+                    String s = (String)stack.pop();
+                    String sr = "not (" + s + ")";
+                    stack.push(sr);
+                }
             }
         }
@@ -284,8 +296,12 @@
                 .and() //connect previous criteria with and
                 .isNull("SomeDomainObject.description") //attribute is null
-                .or(); //connect previous criteria with and
+                .or() //connect previous criteria with or
+                .orderDesc("SomeDomainObject.name"); //order by some attribute
 
         //print the resulting where clause SQL
         System.out.println(criteria.criteriaToSQL());
+
+        //print the resulting order clause SQL
+        System.out.println(criteria.orderStringToSQL());
 
         //the result is;
Index: trunk/fmgVen/src/com/fmguler/ven/QueryGenerator.java
===================================================================
--- trunk/fmgVen/src/com/fmguler/ven/QueryGenerator.java	(revision 36)
+++ trunk/fmgVen/src/com/fmguler/ven/QueryGenerator.java	(revision 37)
@@ -21,4 +21,5 @@
 import com.fmguler.ven.util.VenList;
 import java.beans.PropertyDescriptor;
+import java.math.BigDecimal;
 import java.util.Date;
 import java.util.HashSet;
@@ -47,4 +48,5 @@
         this.dbClasses.add(Double.class);
         this.dbClasses.add(Boolean.class);
+        this.dbClasses.add(BigDecimal.class);
     }
 
@@ -91,5 +93,5 @@
             //if (fieldName.equals("id")) continue; //remove if it does not break the sequence
             if (dbClasses.contains(fieldClass)) { //direct database field (Integer,String,Date, etc)
-                query.append(columnName);
+                query.append(columnName.equals("order")?"\"order\"":columnName);
                 query.append(",");
                 values.append(":").append(fieldName);
@@ -129,5 +131,5 @@
             String fieldName = pdArr[i].getName(); //field name
             if (dbClasses.contains(fieldClass)) { //direct database field (Integer,String,Date, etc)
-                query.append(columnName).append("=:").append(fieldName);
+                query.append(columnName.equals("order")?"\"order\"":columnName).append("=:").append(fieldName);
                 query.append(",");
             }
Index: trunk/fmgVen/src/com/fmguler/ven/QueryMapper.java
===================================================================
--- trunk/fmgVen/src/com/fmguler/ven/QueryMapper.java	(revision 36)
+++ trunk/fmgVen/src/com/fmguler/ven/QueryMapper.java	(revision 37)
@@ -21,4 +21,5 @@
 import com.fmguler.ven.util.VenList;
 import java.beans.PropertyDescriptor;
+import java.math.BigDecimal;
 import java.sql.ResultSet;
 import java.sql.SQLException;
@@ -56,4 +57,5 @@
         this.dbClasses.add(Double.class);
         this.dbClasses.add(Boolean.class);
+        this.dbClasses.add(BigDecimal.class);
     }
 
@@ -125,11 +127,13 @@
                         if (debug) System.out.println("--field not found: " + columnName);
                     }
+                    continue; //if this is a primitive property, it cannot be an object or list
                 }
 
                 //many to one association (object property)
-                if (map && fieldClass.getPackage() != null && domainPackages.contains(fieldClass.getPackage().getName())) {
+                if (fieldClass.getPackage() != null && domainPackages.contains(fieldClass.getPackage().getName())) {
                     if (columns.contains(columnName + "_id")) {
                         if (debug) System.out.println(">>object is found " + columnName);
                         List list = new ArrayList(1); //we know there will be single result
+                        if (!map) list.add(fieldValue); //otherwise we cannot catch one to many assc. (lists) of many to one (object) assc.
                         mapRecursively(rs, columns, columnName, fieldClass, list);
                         if (list.size() > 0) wr.setPropertyValue(pd.getName(), list.get(0));
@@ -151,6 +155,6 @@
             }
         } catch (Exception ex) {
+            System.out.println("Ven - error while mapping row, table: " + tableName + " object class: " + objectClass + " error: " + ex.getMessage());
             if (debug) {
-                System.out.println("Ven - error while mapping row; ");
                 ex.printStackTrace();
             }
Index: trunk/fmgVen/src/com/fmguler/ven/Ven.java
===================================================================
--- trunk/fmgVen/src/com/fmguler/ven/Ven.java	(revision 36)
+++ trunk/fmgVen/src/com/fmguler/ven/Ven.java	(revision 37)
@@ -53,7 +53,8 @@
      * <p>
      * By default none of the associations will be retrieved.
-     * To include the object associations (retrieve the object graph) joins should be specified, e.g.
-     * <code>SomeObject.anotherObject</code>
-     * 
+     * To include the object associations (retrieve the object graph) joins
+     * should be specified, e.g.
+     * <code>SomeObject.anotherObject</code>
+     *
      * @param id the id of the object to be retrieved
      * @param objectClass the class of the object to be retrieved
@@ -76,10 +77,39 @@
 
     /**
+     * Get the object with the specified id, of the specified objectClass type.
+     * <p>
+     * By default none of the associations will be retrieved.
+     * To include the object associations (retrieve the object graph) joins
+     * should be specified, e.g.
+     * <code>SomeObject.anotherObject</code>
+     *
+     * @param id the id of the object to be retrieved
+     * @param objectClass the class of the object to be retrieved
+     * @param joins the set of object graphs to be included with the object
+     * @param criteria to filter and order the result according to some criteria
+     * (e.g. for associations)
+     * @return the retrieved object including specified associations
+     */
+    public Object get(int id, Class objectClass, Set joins, Criteria criteria) {
+        String query = generator.generateSelectQuery(objectClass, joins);
+        query += " where 1=1 and " + Convert.toDB(Convert.toSimpleName(objectClass.getName())) + ".id = :___id " + criteria.criteriaStringToSQL() + " and " + criteria.criteriaToSQL() + criteria.orderStringToSQL();
+
+        criteria.getParameters().put("___id", new Integer(id));
+        if (debug) System.out.println("Ven - SQL: " + query);
+
+        List result = mapper.list(query, criteria.getParameters(), objectClass);
+        if (result.isEmpty()) return null;
+        if (result.size() > 1) System.out.println("Ven - WARNING >> get(id) returns more than one row");
+        return result.get(0);
+    }
+
+    /**
      * List the objects of the specified objectClass type.
      * <p>
      * By default none of the associations will be retrieved.
-     * To include the object associations (retrieve the object graph) joins should be specified, e.g.
-     * <code>SomeObject.anotherObject</code>
-     * 
+     * To include the object associations (retrieve the object graph) joins
+     * should be specified, e.g.
+     * <code>SomeObject.anotherObject</code>
+     *
      * @param objectClass the class of the objects to be retrieved
      * @param joins the set of object graphs to be included with objects
@@ -87,28 +117,25 @@
      */
     public List list(Class objectClass, Set joins) {
-        String query = generator.generateSelectQuery(objectClass, joins);
-
-        Map paramMap = new HashMap();
-        if (debug) System.out.println("Ven - SQL: " + query);
-
-        List result = mapper.list(query, paramMap, objectClass);
-        return result;
-    }
-
-    /**
-     * List the objects of the specified objectClass type, filtering according to some criteria.
-     * <p>
-     * By default none of the associations will be retrieved.
-     * To include the object associations (retrieve the object graph) joins should be specified, e.g.
-     * <code>SomeObject.anotherObject</code>
-     * 
+        return list(objectClass, joins, new Criteria());
+    }
+
+    /**
+     * List the objects of the specified objectClass type, filtering according
+     * to some criteria.
+     * <p>
+     * By default none of the associations will be retrieved.
+     * To include the object associations (retrieve the object graph) joins
+     * should be specified, e.g.
+     * <code>SomeObject.anotherObject</code>
+     *
      * @param objectClass the class of the objects to be retrieved
      * @param joins the set of object graphs to be included with objects
      * @param criteria to filter and order the result according to some criteria
-     * @return the list of objects including the specified associations filtered according to the specified criteria
+     * @return the list of objects including the specified associations filtered
+     * according to the specified criteria
      */
     public List list(Class objectClass, Set joins, Criteria criteria) {
         String query = generator.generateSelectQuery(objectClass, joins);
-        query += " where 1=1 " + criteria.criteriaStringToSQL() + " and " + criteria.criteriaToSQL();
+        query += " where 1=1 " + criteria.criteriaStringToSQL() + " and " + criteria.criteriaToSQL() + criteria.orderStringToSQL();
 
         if (debug) System.out.println("Ven - SQL: " + query);
@@ -119,10 +146,11 @@
 
     /**
-     * Save the object. If it has a non null (or non zero) "id" property it will be updated.
+     * Save the object. If it has a non null (or non zero) "id" property it will
+     * be updated.
      * It will be inserted otherwise.
      * <p>
      * The object will be saved to a table with the same name as the object,
      * The fields of object will be mapped to the table fields.
-     * 
+     *
      * @param object the object to be saved
      */
@@ -144,5 +172,6 @@
 
     /**
-     * Delete the the object with the specified id of the specified objectClass type
+     * Delete the the object with the specified id of the specified objectClass
+     * type
      * @param id the id of the object to be deleted
      * @param objectClass the class of the object to be deleted
@@ -200,5 +229,6 @@
      * Set debug mode, true will log all debug messages to System.out
      * <p>
-     * Note: Use debug mode to detect problems only. It is not a general purpose logging mode.
+     * Note: Use debug mode to detect problems only. It is not a general purpose
+     * logging mode.
      * @param debug set true to enable debug mode
      */
@@ -208,3 +238,20 @@
         mapper.setDebug(debug);
     }
+
+    //--------------------------------------------------------------------------
+    //GETTERS
+    
+    /**
+     * @return the underlying query generator, for advanced usage.
+     */
+    public QueryGenerator getQueryGenerator() {
+        return generator;
+    }
+
+    /**
+     * @return the underlying query mapper, for advanced usage.
+     */
+    public QueryMapper getQueryMapper() {
+        return mapper;
+    }
 }
