Index: SQLBuilderTest.java
===================================================================
--- SQLBuilderTest.java	(revision 44197)
+++ SQLBuilderTest.java	(revision 44198)
@@ -1,11 +1,9 @@
 package org.gvsig.fmap.dal.store.jdbc2;
 
-import java.util.ArrayList;
-import java.util.List;
+import junit.framework.TestCase;
 import org.apache.commons.lang3.ArrayUtils;
 import org.cresques.cts.IProjection;
-import org.gvsig.expressionevaluator.ExpressionBuilder.Parameter;
-import org.gvsig.expressionevaluator.ExpressionBuilder.Variable;
+import org.gvsig.expressionevaluator.ExpressionBuilder;
 import org.gvsig.fmap.crs.CRSFactory;
 import org.gvsig.fmap.dal.SQLBuilder;
 import org.gvsig.fmap.dal.SQLBuilder.Privilege;
@@ -15,48 +13,29 @@
 import org.gvsig.fmap.geom.GeometryLocator;
 import org.gvsig.fmap.geom.GeometryManager;
 import org.gvsig.fmap.geom.primitive.Polygon;
-import org.gvsig.tools.junit.AbstractLibraryAutoInitTestCase;
+import org.gvsig.tools.library.impl.DefaultLibrariesInitializer;
 
-public class SQLBuilderTest extends AbstractLibraryAutoInitTestCase {
+public class SQLBuilderTest extends TestCase {
     
+    public SQLBuilderTest(String testName) {
+        super(testName);
+    }
+
     @Override
-    protected void doSetUp() throws Exception {
+    protected void setUp() throws Exception {
+        super.setUp();
+        new DefaultLibrariesInitializer().fullInitialize();
+    }
 
+    @Override
+    protected void tearDown() throws Exception {
+        super.tearDown();
     }
-    
-    List<String> getVariableNames(SQLBuilder builder) {
-        List<String> vars = new ArrayList<>();
-        for (Variable var : builder.getVariables()) {
-            vars.add(var.getName());
-        }
-        return vars;
+
+    private SQLBuilder createSQLBuilder() {
+        return new SQLBuilderBase();
     }
     
-    List<String> getParameterNames(SQLBuilder builder) {
-        List<String> params = new ArrayList<>();
-        for (Parameter param : builder.getParameters()) {
-            String s;
-            switch(param.getType()) {
-                case Constant:
-                    Object value = param.getValue();
-                    if( value==null ) {
-                        s = "null";
-                    } else if( value instanceof String ) {
-                        s = "'" + (String)value + "'";
-                    } else {
-                        s = value.toString();
-                    }    
-                    break;
-                case Geometry:
-                case Variable:
-                default:
-                    s = "\"" + param.getName() + "\"";
-            }
-            params.add(s);
-        }
-        return params;
-    }
-    
  
     public void testCalulateEnvelope() throws Exception {
         GeometryManager geometryManager = GeometryLocator.getGeometryManager();
@@ -69,60 +48,60 @@
         limit.addVertex(100, 0);
         limit.addVertex(0, 0);
         
-        SQLBuilder builder = new SQLBuilderBase();
+        SQLBuilder sqlbuilder = createSQLBuilder();
+        ExpressionBuilder expbuilder = sqlbuilder.expression();
         
-        builder.select().column().value(
-            builder.getAsGeometry(
-              builder.ST_ExtentAggregate(
-                builder.column("the_geom")
+        sqlbuilder.select().column().value(
+            expbuilder.as_geometry(
+              expbuilder.ST_ExtentAggregate(
+                expbuilder.column("the_geom")
               )
             )
         ).as("envelope");
-        builder.select().from().table().database("master").schema("dbo").name("test1");
-        builder.select().where().set(
-            builder.ST_Intersects(
-                builder.ST_Envelope(
-                    builder.column("the_geom")
+        sqlbuilder.select().from().table().database("master").schema("dbo").name("test1");
+        sqlbuilder.select().where().set(
+            expbuilder.ST_Intersects(
+                expbuilder.ST_Envelope(
+                    expbuilder.column("the_geom")
                 ),
-                builder.geometry(limit, proj)
+                expbuilder.geometry(limit, proj)
             )
         );
-        builder.select().where().and(
-                builder.custom("x = 27")
+        sqlbuilder.select().where().and(
+                expbuilder.custom("x = 27")
         );
         
-        // SELECT ST_AsBinary(ST_Extent("the_geom")) AS "envelope" FROM "master"."dbo"."test1" WHERE ST_Intersects((ST_Envelope("the_geom")), (ST_GeomFromText('POLYGON ((0 0, 0 100, 100 100, 100 0, 0 0))', (4326)))) AND x = 27
-        
         System.out.println("# Test:: testCalulateEnvelope");
-        System.out.println("# SQL:: " + builder.toString());
-        System.out.println("# Variables:: " + ArrayUtils.toString(getVariableNames(builder)));
-        System.out.println("# Parametros:: " + ArrayUtils.toString(getParameterNames(builder)));
+        System.out.println("# SQL:: " + sqlbuilder.toString());
+        System.out.println("# Variables:: " + ArrayUtils.toString(sqlbuilder.variables_names()));
+        System.out.println("# Parametros:: " + ArrayUtils.toString(sqlbuilder.parameters_names()));
         assertEquals(
-                "SELECT ST_AsBinary(ST_Extent(\"the_geom\")) AS \"envelope\" FROM \"master\".\"dbo\".\"test1\" WHERE ST_Intersects((ST_Envelope(\"the_geom\")), (ST_GeomFromText('POLYGON ((0 0, 0 100, 100 100, 100 0, 0 0))', (4326)))) AND x = 27",
-                builder.toString()
+                "SELECT ST_AsBinary(ST_ExtentAggregate(\"the_geom\")) AS \"envelope\" FROM \"master\".\"dbo\".\"test1\" WHERE ST_Intersects((ST_Envelope(\"the_geom\")), (ST_GeomFromWKB((DECODE('000000000300000001000000050000000000000000000000000000000000000000000000004059000000000000405900000000000040590000000000004059000000000000000000000000000000000000000000000000000000000000','hex')), (4326)))) AND x = 27",
+                sqlbuilder.toString()
         );
         assertEquals(
                 "[the_geom]",
-                ArrayUtils.toString(getVariableNames(builder))
+                ArrayUtils.toString(sqlbuilder.variables_names())
         );
         assertEquals(
                 "[]",
-                ArrayUtils.toString(getParameterNames(builder))
+                ArrayUtils.toString(sqlbuilder.parameters_names())
         );
     }
 
     public void testCount() throws Exception {
-        SQLBuilder builder = new SQLBuilderBase();
+        SQLBuilder sqlbuilder = createSQLBuilder();
+        ExpressionBuilder expbuilder = sqlbuilder.expression();
         
-        builder.select().column().value(builder.count().all());
-        builder.select().from().table().database("master").schema("dbo").name("test1");
-        builder.select().from().subquery(null);
-        builder.select().where().set( builder.custom("pp = 200"));
+        sqlbuilder.select().column().value(sqlbuilder.count().all());
+        sqlbuilder.select().from().table().database("master").schema("dbo").name("test1");
+        sqlbuilder.select().from().subquery(null);
+        sqlbuilder.select().where().set( expbuilder.custom("pp = 200"));
 
         System.out.println("# Test:: testCount");
-        System.out.println("# SQL:: " + builder.toString());
-        System.out.println("# Variables:: " + ArrayUtils.toString(getVariableNames(builder)));
-        System.out.println("# Parametros:: " + ArrayUtils.toString(getParameterNames(builder)));
+        System.out.println("# SQL:: " + sqlbuilder.toString());
+        System.out.println("# Variables:: " + ArrayUtils.toString(sqlbuilder.variables_names()));
+        System.out.println("# Parametros:: " + ArrayUtils.toString(sqlbuilder.parameters_names()));
 
         //# Test:: testCount
         //# SQL:: SELECT COUNT(*) FROM "master"."dbo"."test1" WHERE pp = 200
@@ -131,23 +110,24 @@
 
         assertEquals(
                 "SELECT COUNT(*) FROM \"master\".\"dbo\".\"test1\" WHERE pp = 200",
-                builder.toString()
+                sqlbuilder.toString()
         );
         assertEquals(
                 "[]",
-                ArrayUtils.toString(getVariableNames(builder))
+                ArrayUtils.toString(sqlbuilder.variables_names())
         );
         assertEquals(
                 "[]",
-                ArrayUtils.toString(getParameterNames(builder))
+                ArrayUtils.toString(sqlbuilder.parameters_names())
         );
     }
     
     public void testCreateTable() throws Exception {
-        SQLBuilder builder = new SQLBuilderBase();
+        SQLBuilder sqlbuilder = createSQLBuilder();
+        ExpressionBuilder expbuilder = sqlbuilder.expression();
 
-        builder.create_table().table().database("master").schema("dbo").name("test1");
-        builder.create_table().add_column(
+        sqlbuilder.create_table().table().database("master").schema("dbo").name("test1");
+        sqlbuilder.create_table().add_column(
                 "name",
                 DataTypes.STRING,
                 45,
@@ -158,7 +138,7 @@
                 false,
                 null
         );
-        builder.create_table().add_column(
+        sqlbuilder.create_table().add_column(
                 "id",
                 DataTypes.INT,
                 0,
@@ -169,7 +149,7 @@
                 true,
                 0
         );
-        builder.create_table().add_column(
+        sqlbuilder.create_table().add_column(
                 "geom",
                 DataTypes.GEOMETRY,
                 0,
@@ -184,95 +164,98 @@
         
         // CREATE TABLE "master"."dbo"."test1" ("name" VARCHAR(45) DEFAULT NULL NULL, "id" SERIAL DEFAULT '0' NOT NULL PRIMARY KEY, "geom" TEXT DEFAULT NULL NULL )
         System.out.println("# Test:: testCreateTable");
-        System.out.println("# SQL:: " + builder.toString());
-        System.out.println("# Variables:: " + ArrayUtils.toString(getVariableNames(builder)));
-        System.out.println("# Parametros:: " + ArrayUtils.toString(getParameterNames(builder)));
+        System.out.println("# SQL:: " + sqlbuilder.toString());
+        System.out.println("# Variables:: " + ArrayUtils.toString(sqlbuilder.variables_names()));
+        System.out.println("# Parametros:: " + ArrayUtils.toString(sqlbuilder.parameters_names()));
         assertEquals(
                 "CREATE TABLE \"master\".\"dbo\".\"test1\" (\"name\" VARCHAR(45) DEFAULT NULL NULL, \"id\" SERIAL DEFAULT '0' NOT NULL PRIMARY KEY, \"geom\" TEXT DEFAULT NULL NULL )",
-                builder.toString()
+                sqlbuilder.toString()
         );
         assertEquals(
                 "[]",
-                ArrayUtils.toString(getVariableNames(builder))
+                ArrayUtils.toString(sqlbuilder.variables_names())
         );
         assertEquals(
                 "[]",
-                ArrayUtils.toString(getParameterNames(builder))
+                ArrayUtils.toString(sqlbuilder.parameters_names())
         );
     }
 
     public void testDropTable() throws Exception {
-        SQLBuilder builder = new SQLBuilderBase();
+        SQLBuilder sqlbuilder = createSQLBuilder();
+        ExpressionBuilder expbuilder = sqlbuilder.expression();
         
-        builder.drop_table().table().database("master").schema("dbo").name("test1");
+        sqlbuilder.drop_table().table().database("master").schema("dbo").name("test1");
 
         // DROP TABLE "master"."dbo"."test1"; DELETE FROM GEOMETRY_COLUMNS WHERE f_table_schema = 'dbo' AND f_table_name = 'test1'
         
         System.out.println("# Test:: testDropTable");
-        System.out.println("# SQL:: " + builder.toString());
-        System.out.println("# Variables:: " + ArrayUtils.toString(getVariableNames(builder)));
-        System.out.println("# Parametros:: " + ArrayUtils.toString(getParameterNames(builder)));
+        System.out.println("# SQL:: " + sqlbuilder.toString());
+        System.out.println("# Variables:: " + ArrayUtils.toString(sqlbuilder.variables_names()));
+        System.out.println("# Parametros:: " + ArrayUtils.toString(sqlbuilder.parameters_names()));
         assertEquals(
                 "DROP TABLE \"master\".\"dbo\".\"test1\"; DELETE FROM GEOMETRY_COLUMNS WHERE f_table_schema = 'dbo' AND f_table_name = 'test1'",
-                builder.toString()
+                sqlbuilder.toString()
         );
         assertEquals(
                 "[]",
-                ArrayUtils.toString(getVariableNames(builder))
+                ArrayUtils.toString(sqlbuilder.variables_names())
         );
         assertEquals(
                 "[]",
-                ArrayUtils.toString(getParameterNames(builder))
+                ArrayUtils.toString(sqlbuilder.parameters_names())
         );
     }
     
     public void testFetchFeatureProviderByReference() throws Exception {
-        SQLBuilder builder = new SQLBuilderBase();
+        SQLBuilder sqlbuilder = createSQLBuilder();
+        ExpressionBuilder expbuilder = sqlbuilder.expression();
         
         String value = "yoyo";
-        builder.select().column().name("name");
-        builder.select().column().name("id");
-        builder.select().column().name("geom").as_geometry();
-        builder.select().from().table().database("master").schema("dbo").name("test1");
-        builder.select().where().set(
-            builder.eq(
-                builder.column("name"),
-                builder.parameter(value).as_constant()
+        sqlbuilder.select().column().name("name");
+        sqlbuilder.select().column().name("id");
+        sqlbuilder.select().column().name("geom").as_geometry();
+        sqlbuilder.select().from().table().database("master").schema("dbo").name("test1");
+        sqlbuilder.select().where().set(
+            expbuilder.eq(
+                expbuilder.column("name"),
+                expbuilder.parameter(value).as_constant()
             )
         );
-        builder.select().limit(1);
+        sqlbuilder.select().limit(1);
 
         // SELECT "name", "id", ST_AsBinary("geom") FROM "master"."dbo"."test1" WHERE ( ("name") = (?) ) LIMIT 1
 
         System.out.println("# Test:: testFetchFeatureProviderByReference");
-        System.out.println("# SQL:: " + builder.toString());
-        System.out.println("# Variables:: " + ArrayUtils.toString(getVariableNames(builder)));
-        System.out.println("# Parametros:: " + ArrayUtils.toString(getParameterNames(builder)));
+        System.out.println("# SQL:: " + sqlbuilder.toString());
+        System.out.println("# Variables:: " + ArrayUtils.toString(sqlbuilder.variables_names()));
+        System.out.println("# Parametros:: " + ArrayUtils.toString(sqlbuilder.parameters_names()));
         assertEquals(
                 "SELECT \"name\", \"id\", ST_AsBinary(\"geom\") FROM \"master\".\"dbo\".\"test1\" WHERE ( (\"name\") = (?) ) LIMIT 1",
-                builder.toString()
+                sqlbuilder.toString()
         );
         assertEquals(
                 "[geom, id, name]",
-                ArrayUtils.toString(getVariableNames(builder))
+                ArrayUtils.toString(sqlbuilder.variables_names())
         );
         assertEquals(
                 "['yoyo']",
-                ArrayUtils.toString(getParameterNames(builder))
+                ArrayUtils.toString(sqlbuilder.parameters_names())
         );
     }
     
     public void testFetchFeatureType() throws Exception {
-        SQLBuilder builder = new SQLBuilderBase();
+        SQLBuilder sqlbuilder = createSQLBuilder();
+        ExpressionBuilder expbuilder = sqlbuilder.expression();
 
-        builder.select().column().all();
-        builder.select().from().table().database("master").schema("dbo").name("test1");
-        builder.select().limit(1);
+        sqlbuilder.select().column().all();
+        sqlbuilder.select().from().table().database("master").schema("dbo").name("test1");
+        sqlbuilder.select().limit(1);
 
         System.out.println("# Test:: testFetchFeatureType");
-        System.out.println("# SQL:: " + builder.toString());
-        System.out.println("# Variables:: " + ArrayUtils.toString(getVariableNames(builder)));
-        System.out.println("# Parametros:: " + ArrayUtils.toString(getParameterNames(builder)));
+        System.out.println("# SQL:: " + sqlbuilder.toString());
+        System.out.println("# Variables:: " + ArrayUtils.toString(sqlbuilder.variables_names()));
+        System.out.println("# Parametros:: " + ArrayUtils.toString(sqlbuilder.parameters_names()));
         
         //# Test:: testFetchFeatureType
         //# SQL:: SELECT * FROM [master].[dbo].[test1] LIMMIT 1
@@ -281,205 +264,242 @@
         
         assertEquals(
                 "SELECT * FROM \"master\".\"dbo\".\"test1\" LIMIT 1",
-                builder.toString()
+                sqlbuilder.toString()
         );
         assertEquals(
                 "[]",
-                ArrayUtils.toString(getVariableNames(builder))
+                ArrayUtils.toString(sqlbuilder.variables_names())
         );
         assertEquals(
                 "[]",
-                ArrayUtils.toString(getParameterNames(builder))
+                ArrayUtils.toString(sqlbuilder.parameters_names())
         );
     }
         
     public void testPerformDeletes() throws Exception {
-        SQLBuilder builder = new SQLBuilderBase();
+        SQLBuilder sqlbuilder = createSQLBuilder();
+        ExpressionBuilder expbuilder = sqlbuilder.expression();
 
-        builder.delete().table().database("master").schema("dbo").name("test1");
-        builder.delete().where().and(
-            builder.eq( 
-                builder.column("id1"),
-                builder.parameter("id1").as_variable()
+        sqlbuilder.delete().table().database("master").schema("dbo").name("test1");
+        sqlbuilder.delete().where().and(
+            expbuilder.eq( 
+                expbuilder.column("id1"),
+                expbuilder.parameter("id1").as_variable()
             )
         );
-        builder.delete().where().and(
-            builder.eq( 
-                builder.column("id2"),
-                builder.parameter("id2").as_variable()
+        sqlbuilder.delete().where().and(
+            expbuilder.eq( 
+                expbuilder.column("id2"),
+                expbuilder.parameter("id2").as_variable()
             )
         );
 
         // DELETE FROM "master"."dbo"."test1" WHERE ( ("id1") = (?) ) AND ( ("id2") = (?) )
 
         System.out.println("# Test:: testPerformDeletes");
-        System.out.println("# SQL:: " + builder.toString());
-        System.out.println("# Variables:: " + ArrayUtils.toString(getVariableNames(builder)));
-        System.out.println("# Parametros:: " + ArrayUtils.toString(getParameterNames(builder)));
+        System.out.println("# SQL:: " + sqlbuilder.toString());
+        System.out.println("# Variables:: " + ArrayUtils.toString(sqlbuilder.variables_names()));
+        System.out.println("# Parametros:: " + ArrayUtils.toString(sqlbuilder.parameters_names()));
         assertEquals(
                 "DELETE FROM \"master\".\"dbo\".\"test1\" WHERE ( (\"id1\") = (?) ) AND ( (\"id2\") = (?) )",
-                builder.toString()
+                sqlbuilder.toString()
         );
         assertEquals(
                 "[id1, id2]",
-                ArrayUtils.toString(getVariableNames(builder))
+                ArrayUtils.toString(sqlbuilder.variables_names())
         );
         assertEquals(
                 "[\"id1\", \"id2\"]",
-                ArrayUtils.toString(getParameterNames(builder))
+                ArrayUtils.toString(sqlbuilder.parameters_names())
         );
     }
 
     public void testPerformInserts1() throws Exception {
         IProjection proj = CRSFactory.getCRS("EPSG:4326");
 
-        SQLBuilder builder = new SQLBuilderBase();
+        SQLBuilder sqlbuilder = createSQLBuilder();
+        ExpressionBuilder expbuilder = sqlbuilder.expression();
 
-        builder.insert().table().database("master").schema("dbo").name("test1");
-        builder.insert().column().name("id").with_value(builder.parameter("id"));
-        builder.insert().column().name("name").with_value(builder.parameter("name"));
-        builder.insert().column().name("geom").with_value(builder.parameter("geom").as_geometry_variable().srs(proj));
+        sqlbuilder.insert().table().database("master").schema("dbo").name("test1");
+        sqlbuilder.insert().column().name("id").with_value(expbuilder.parameter("id"));
+        sqlbuilder.insert().column().name("name").with_value(expbuilder.parameter("name"));
+        sqlbuilder.insert().column().name("geom").with_value(expbuilder.parameter("geom").as_geometry_variable().srs(proj));
         
-        // INSERT INTO "master"."dbo"."test1" ( "id", "name", "geom" ) VALUES ( ?, ?, ST_GeomFromText(?, (4326)) )
-        
         System.out.println("# Test:: testPerformInserts1");
-        System.out.println("# SQL:: " + builder.toString());
-        System.out.println("# Variables:: " + ArrayUtils.toString(getVariableNames(builder)));
-        System.out.println("# Parametros:: " + ArrayUtils.toString(getParameterNames(builder)));
+        System.out.println("# SQL:: " + sqlbuilder.toString());
+        System.out.println("# Variables:: " + ArrayUtils.toString(sqlbuilder.variables_names()));
+        System.out.println("# Parametros:: " + ArrayUtils.toString(sqlbuilder.parameters_names()));
         assertEquals(
-                "INSERT INTO \"master\".\"dbo\".\"test1\" ( \"id\", \"name\", \"geom\" ) VALUES ( ?, ?, ST_GeomFromText(?, (4326)) )",
-                builder.toString()
+                "INSERT INTO \"master\".\"dbo\".\"test1\" ( \"id\", \"name\", \"geom\" ) VALUES ( ?, ?, ST_GeomFromWKB((?), (4326)) )",
+                sqlbuilder.toString()
         );
         assertEquals(
                 "[geom, id, name]",
-                ArrayUtils.toString(getVariableNames(builder))
+                ArrayUtils.toString(sqlbuilder.variables_names())
         );
         assertEquals(
                 "[\"id\", \"name\", \"geom\"]",
-                ArrayUtils.toString(getParameterNames(builder))
+                ArrayUtils.toString(sqlbuilder.parameters_names())
         );
     }
 
     public void testPerformInserts2() throws Exception {
         IProjection proj = CRSFactory.getCRS("EPSG:4326");
 
-        SQLBuilder builder = new SQLBuilderBase();
+        SQLBuilder sqlbuilder = createSQLBuilder();
+        ExpressionBuilder expbuilder = sqlbuilder.expression();
 
-        builder.insert().table().database("master").schema("dbo").name("test1");
-        builder.insert().column().name("id").with_value(builder.parameter("id"));
-        builder.insert().column().name("name").with_value(builder.parameter("name"));
-        builder.insert().column().name("geom").with_value(builder.parameter("geom").as_geometry_variable().srs(proj));
+        sqlbuilder.insert().table().database("master").schema("dbo").name("test1");
+        sqlbuilder.insert().column().name("id").with_value(expbuilder.parameter("id"));
+        sqlbuilder.insert().column().name("name").with_value(expbuilder.parameter("name"));
+        sqlbuilder.insert().column().name("geom").with_value(expbuilder.parameter("geom").as_geometry_variable().srs(proj));
         
-        // INSERT INTO "master"."dbo"."test1" ( "id", "name", "geom" ) VALUES ( ?, ?, ST_GeomFromText(?, (?)) )
-        
         System.out.println("# Test:: testPerformInserts2");
-        System.out.println("# SQL:: " + builder.toString());
-        System.out.println("# Variables:: " + ArrayUtils.toString(getVariableNames(builder)));
-        System.out.println("# Parametros:: " + ArrayUtils.toString(getParameterNames(builder)));
+        System.out.println("# SQL:: " + sqlbuilder.toString());
+        System.out.println("# Variables:: " + ArrayUtils.toString(sqlbuilder.variables_names()));
+        System.out.println("# Parametros:: " + ArrayUtils.toString(sqlbuilder.parameters_names()));
         assertEquals(
-                "INSERT INTO \"master\".\"dbo\".\"test1\" ( \"id\", \"name\", \"geom\" ) VALUES ( ?, ?, ST_GeomFromText(?, (?)) )",
-                builder.toString()
+                "INSERT INTO \"master\".\"dbo\".\"test1\" ( \"id\", \"name\", \"geom\" ) VALUES ( ?, ?, ST_GeomFromWKB((?), (4326)) )",
+                sqlbuilder.toString()
         );
         assertEquals(
                 "[geom, id, name]",
-                ArrayUtils.toString(getVariableNames(builder))
+                ArrayUtils.toString(sqlbuilder.variables_names())
         );
         assertEquals(
-                "[\"id\", \"name\", \"geom\", 4326]",
-                ArrayUtils.toString(getParameterNames(builder))
+                "[\"id\", \"name\", \"geom\"]",
+                ArrayUtils.toString(sqlbuilder.parameters_names())
         );
     }
 
-    public void testPerformUpdates() throws Exception {
+    public void testPerformUpdates1() throws Exception {
         IProjection proj = CRSFactory.getCRS("EPSG:4326");
 
-        SQLBuilder builder = new SQLBuilderBase();
+        SQLBuilder sqlbuilder = createSQLBuilder();
+        ExpressionBuilder expbuilder = sqlbuilder.expression();
 
-        builder.update().table().database("master").schema("dbo").name("test1");
-        builder.update().where().and(
-            builder.eq(
-                builder.column("id"), 
-                builder.parameter("id").as_variable()
+        sqlbuilder.update().table().database("master").schema("dbo").name("test1");
+        sqlbuilder.update().where().and(
+            expbuilder.eq(
+                expbuilder.column("id"), 
+                expbuilder.parameter("id").as_variable()
             )
         );
-        builder.update().column().name("name").with_value(builder.parameter("name"));
-        builder.update().column().name("geom").with_value(
-                builder.parameter("geom").as_geometry_variable().srs(proj) 
+        sqlbuilder.update().column().name("name").with_value(expbuilder.parameter("name"));
+        sqlbuilder.update().column().name("geom").with_value(
+                expbuilder.parameter("geom").as_geometry_variable().srs(proj) 
         );
 
-        // UPDATE "master"."dbo"."test1" SET "name" = ?, "geom" = ST_GeomFromText(?, (?)) WHERE ( ("id") = (?) )
+        System.out.println("# Test:: testPerformUpdates");
+        System.out.println("# SQL:: " + sqlbuilder.toString());
+        System.out.println("# Variables:: " + ArrayUtils.toString(sqlbuilder.variables_names()));
+        System.out.println("# Parametros:: " + ArrayUtils.toString(sqlbuilder.parameters_names()));
+        assertEquals(
+                "UPDATE \"master\".\"dbo\".\"test1\" SET \"name\" = ?, \"geom\" = ST_GeomFromWKB((?), (4326)) WHERE ( (\"id\") = (?) )",
+                sqlbuilder.toString()
+        );
+        assertEquals(
+                "[geom, id, name]",
+                ArrayUtils.toString(sqlbuilder.variables_names())
+        );
+        assertEquals(
+                "[\"name\", \"geom\", \"id\"]",
+                ArrayUtils.toString(sqlbuilder.parameters_names())
+        );
+    }
 
+    public void testPerformUpdates2() throws Exception {
+        IProjection proj = CRSFactory.getCRS("EPSG:4326");
+
+        SQLBuilder sqlbuilder = createSQLBuilder();
+        ExpressionBuilder expbuilder = sqlbuilder.expression();
+
+        sqlbuilder.update().table().database("master").schema("dbo").name("test1");
+        sqlbuilder.update().where().and(
+            expbuilder.eq(
+                expbuilder.column("id"), 
+                expbuilder.parameter("id").as_variable()
+            )
+        );
+        sqlbuilder.update().column().name("name").with_value(expbuilder.parameter("name"));
+        sqlbuilder.update().column().name("geom").with_value(
+                expbuilder.parameter("geom").as_geometry_variable()
+                        .srs(expbuilder.parameter().value(proj)) 
+        );
+
         System.out.println("# Test:: testPerformUpdates");
-        System.out.println("# SQL:: " + builder.toString());
-        System.out.println("# Variables:: " + ArrayUtils.toString(getVariableNames(builder)));
-        System.out.println("# Parametros:: " + ArrayUtils.toString(getParameterNames(builder)));
+        System.out.println("# SQL:: " + sqlbuilder.toString());
+        System.out.println("# Variables:: " + ArrayUtils.toString(sqlbuilder.variables_names()));
+        System.out.println("# Parametros:: " + ArrayUtils.toString(sqlbuilder.parameters_names()));
         assertEquals(
-                "UPDATE \"master\".\"dbo\".\"test1\" SET \"name\" = ?, \"geom\" = ST_GeomFromText(?, (?)) WHERE ( (\"id\") = (?) )",
-                builder.toString()
+                "UPDATE \"master\".\"dbo\".\"test1\" SET \"name\" = ?, \"geom\" = ST_GeomFromWKB((?), (?)) WHERE ( (\"id\") = (?) )",
+                sqlbuilder.toString()
         );
         assertEquals(
                 "[geom, id, name]",
-                ArrayUtils.toString(getVariableNames(builder))
+                ArrayUtils.toString(sqlbuilder.variables_names())
         );
         assertEquals(
                 "[\"name\", \"geom\", 4326, \"id\"]",
-                ArrayUtils.toString(getParameterNames(builder))
+                ArrayUtils.toString(sqlbuilder.parameters_names())
         );
     }
 
     public void testGrant1() throws Exception {
 
-        SQLBuilder builder = new SQLBuilderBase();
+        SQLBuilder sqlbuilder = createSQLBuilder();
+        ExpressionBuilder expbuilder = sqlbuilder.expression();
 
-        builder.grant().table().database("master").schema("dbo").name("test1");
-        builder.grant().role("prueba").select().insert().update();
-        builder.grant().role("gis").all();
+        sqlbuilder.grant().table().database("master").schema("dbo").name("test1");
+        sqlbuilder.grant().role("prueba").select().insert().update();
+        sqlbuilder.grant().role("gis").all();
                 
         
         System.out.println("# Test:: testGrant1");
-        System.out.println("# SQL:: " + builder.toString());
-        System.out.println("# Variables:: " + ArrayUtils.toString(getVariableNames(builder)));
-        System.out.println("# Parametros:: " + ArrayUtils.toString(getParameterNames(builder)));
+        System.out.println("# SQL:: " + sqlbuilder.toString());
+        System.out.println("# Variables:: " + ArrayUtils.toString(sqlbuilder.variables_names()));
+        System.out.println("# Parametros:: " + ArrayUtils.toString(sqlbuilder.parameters_names()));
         assertEquals(
                 "",
-                builder.toString()
+                sqlbuilder.toString()
         );
         assertEquals(
                 "[]",
-                ArrayUtils.toString(getVariableNames(builder))
+                ArrayUtils.toString(sqlbuilder.variables_names())
         );
         assertEquals(
                 "[]",
-                ArrayUtils.toString(getParameterNames(builder))
+                ArrayUtils.toString(sqlbuilder.parameters_names())
         );
     }
 
     public void testGrant2() throws Exception {
 
-        SQLBuilder builder = new SQLBuilderBase();
+        SQLBuilder sqlbuilder = createSQLBuilder();
+        ExpressionBuilder expbuilder = sqlbuilder.expression();
 
-        builder.grant().table().database("master").schema("dbo").name("test1");
-        builder.grant().role("prueba").privilege(Privilege.SELECT)
+        sqlbuilder.grant().table().database("master").schema("dbo").name("test1");
+        sqlbuilder.grant().role("prueba").privilege(Privilege.SELECT)
                 .privilege(Privilege.INSERT)
                 .privilege(Privilege.UPDATE);
-        builder.grant().role("gis").privilege(Privilege.ALL);
+        sqlbuilder.grant().role("gis").privilege(Privilege.ALL);
                 
         
         System.out.println("# Test:: testGrant2");
-        System.out.println("# SQL:: " + builder.toString());
-        System.out.println("# Variables:: " + ArrayUtils.toString(getVariableNames(builder)));
-        System.out.println("# Parametros:: " + ArrayUtils.toString(getParameterNames(builder)));
+        System.out.println("# SQL:: " + sqlbuilder.toString());
+        System.out.println("# Variables:: " + ArrayUtils.toString(sqlbuilder.variables_names()));
+        System.out.println("# Parametros:: " + ArrayUtils.toString(sqlbuilder.parameters_names()));
         assertEquals(
                 "",
-                builder.toString()
+                sqlbuilder.toString()
         );
         assertEquals(
                 "[]",
-                ArrayUtils.toString(getVariableNames(builder))
+                ArrayUtils.toString(sqlbuilder.variables_names())
         );
         assertEquals(
                 "[]",
-                ArrayUtils.toString(getParameterNames(builder))
+                ArrayUtils.toString(sqlbuilder.parameters_names())
         );
     }
 
