Index: trunk/fmgVen/nbproject/build-impl.xml
===================================================================
--- trunk/fmgVen/nbproject/build-impl.xml	(revision 36)
+++ trunk/fmgVen/nbproject/build-impl.xml	(revision 37)
@@ -21,8 +21,8 @@
         -->
 <project xmlns:j2seproject1="http://www.netbeans.org/ns/j2se-project/1" xmlns:j2seproject3="http://www.netbeans.org/ns/j2se-project/3" xmlns:jaxrpc="http://www.netbeans.org/ns/j2se-project/jax-rpc" basedir=".." default="default" name="fmgVen-impl">
-    <fail message="Please build using Ant 1.7.1 or higher.">
+    <fail message="Please build using Ant 1.8.0 or higher.">
         <condition>
             <not>
-                <antversion atleast="1.7.1"/>
+                <antversion atleast="1.8.0"/>
             </not>
         </condition>
@@ -252,4 +252,5 @@
         <property name="jar.index" value="false"/>
         <property name="jar.index.metainf" value="${jar.index}"/>
+        <property name="copylibs.rebase" value="true"/>
         <available file="${meta.inf.dir}/persistence.xml" property="has.persistence.xml"/>
     </target>
@@ -438,4 +439,5 @@
                 <resolve name="profiler.current.path" value="${profiler.info.pathvar}"/>
                 <java classname="@{classname}" dir="${profiler.info.dir}" fork="true" jvm="${profiler.info.jvm}">
+                    <jvmarg line="${endorsed.classpath.cmd.line.arg}"/>
                     <jvmarg value="${profiler.info.jvmargs.agent}"/>
                     <jvmarg line="${profiler.info.jvmargs}"/>
@@ -573,5 +575,5 @@
                 </pathconvert>
                 <taskdef classname="org.netbeans.modules.java.j2seproject.copylibstask.CopyLibs" classpath="${libs.CopyLibs.classpath}" name="copylibs"/>
-                <copylibs compress="${jar.compress}" index="${jar.index}" indexMetaInf="${jar.index.metainf}" jarfile="${dist.jar}" manifest="@{manifest}" runtimeclasspath="${run.classpath.without.build.classes.dir}">
+                <copylibs compress="${jar.compress}" index="${jar.index}" indexMetaInf="${jar.index.metainf}" jarfile="${dist.jar}" manifest="@{manifest}" rebase="${copylibs.rebase}" runtimeclasspath="${run.classpath.without.build.classes.dir}">
                     <fileset dir="${build.classes.dir}"/>
                     <manifest>
@@ -898,4 +900,12 @@
     <target depends="init" if="have.sources" name="-javadoc-build">
         <mkdir dir="${dist.javadoc.dir}"/>
+        <condition else="" property="javadoc.endorsed.classpath.cmd.line.arg" value="-J${endorsed.classpath.cmd.line.arg}">
+            <and>
+                <isset property="endorsed.classpath.cmd.line.arg"/>
+                <not>
+                    <equals arg1="${endorsed.classpath.cmd.line.arg}" arg2=""/>
+                </not>
+            </and>
+        </condition>
         <javadoc additionalparam="${javadoc.additionalparam}" author="${javadoc.author}" charset="UTF-8" destdir="${dist.javadoc.dir}" docencoding="UTF-8" encoding="${javadoc.encoding.used}" executable="${platform.javadoc}" failonerror="true" noindex="${javadoc.noindex}" nonavbar="${javadoc.nonavbar}" notree="${javadoc.notree}" private="${javadoc.private}" source="${javac.source}" splitindex="${javadoc.splitindex}" use="${javadoc.use}" useexternalfile="true" version="${javadoc.version}" windowtitle="${javadoc.windowtitle}">
             <classpath>
@@ -909,4 +919,5 @@
                 <exclude name="*.java"/>
             </fileset>
+            <arg line="${javadoc.endorsed.classpath.cmd.line.arg}"/>
         </javadoc>
         <copy todir="${dist.javadoc.dir}">
Index: trunk/fmgVen/nbproject/genfiles.properties
===================================================================
--- trunk/fmgVen/nbproject/genfiles.properties	(revision 36)
+++ trunk/fmgVen/nbproject/genfiles.properties	(revision 37)
@@ -5,4 +5,4 @@
 # Do not edit this file. You may delete it but then the IDE will never regenerate such files for you.
 nbproject/build-impl.xml.data.CRC32=31e5c25b
-nbproject/build-impl.xml.script.CRC32=f1913007
-nbproject/build-impl.xml.stylesheet.CRC32=0ae3a408@1.44.1.45
+nbproject/build-impl.xml.script.CRC32=74d9d881
+nbproject/build-impl.xml.stylesheet.CRC32=fcddb364@1.50.1.46
Index: trunk/fmgVen/nbproject/project.properties
===================================================================
--- trunk/fmgVen/nbproject/project.properties	(revision 36)
+++ trunk/fmgVen/nbproject/project.properties	(revision 37)
@@ -1,4 +1,5 @@
 annotation.processing.enabled=true
 annotation.processing.enabled.in.editor=false
+annotation.processing.processors.list=
 annotation.processing.run.all.processors=true
 application.args=
@@ -54,5 +55,5 @@
 meta.inf.dir=${src.dir}/META-INF
 mkdist.disabled=true
-platform.active=JDK_1.4
+platform.active=JDK_1.5
 run.classpath=\
     ${javac.classpath}:\
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;
+    }
 }
Index: trunk/fmgVen/test/com/fmguler/ven/sample/Sample.java
===================================================================
--- trunk/fmgVen/test/com/fmguler/ven/sample/Sample.java	(revision 36)
+++ trunk/fmgVen/test/com/fmguler/ven/sample/Sample.java	(revision 37)
@@ -168,5 +168,6 @@
                 .like("SomeDomainObject.anotherDomainObjects.name", "a%") //attribute like value
                 .eq("SomeDomainObject.name", "sdo1") //attribute equals value
-                .and(); //connects previous criteria with and
+                .and() //connects previous criteria with and
+                .orderDesc("SomeDomainObject.anotherDomainObjects.name"); //order by some attribute
 
         //list with includes and criteria
