Index: trunk/org.gvsig.desktop/org.gvsig.desktop.compat.cdc/org.gvsig.fmap.dal/org.gvsig.fmap.dal.db/org.gvsig.fmap.dal.db.jdbc/src/main/java/org/gvsig/fmap/dal/store/jdbc/JDBCNewStoreParameters.java
===================================================================
--- trunk/org.gvsig.desktop/org.gvsig.desktop.compat.cdc/org.gvsig.fmap.dal/org.gvsig.fmap.dal.db/org.gvsig.fmap.dal.db.jdbc/src/main/java/org/gvsig/fmap/dal/store/jdbc/JDBCNewStoreParameters.java	(revision 44057)
+++ trunk/org.gvsig.desktop/org.gvsig.desktop.compat.cdc/org.gvsig.fmap.dal/org.gvsig.fmap.dal.db/org.gvsig.fmap.dal.db.jdbc/src/main/java/org/gvsig/fmap/dal/store/jdbc/JDBCNewStoreParameters.java	(revision 44058)
@@ -23,9 +23,6 @@
 package org.gvsig.fmap.dal.store.jdbc;
 
 import org.apache.commons.lang3.StringUtils;
-import org.gvsig.fmap.dal.feature.EditableFeatureType;
-import org.gvsig.fmap.dal.feature.FeatureType;
-import org.gvsig.fmap.dal.feature.NewFeatureStoreParameters;
 import org.gvsig.fmap.dal.store.db.DBNewStoreParameters;
 
 import static org.gvsig.fmap.dal.store.jdbc.JDBCConnectionParameters.CATALOG_PARAMTER_NAME;
Index: trunk/org.gvsig.desktop/org.gvsig.desktop.compat.cdc/org.gvsig.fmap.dal/org.gvsig.fmap.dal.db/org.gvsig.fmap.dal.db.jdbc/src/main/java/org/gvsig/fmap/dal/store/jdbc2/OperationsFactory.java
===================================================================
--- trunk/org.gvsig.desktop/org.gvsig.desktop.compat.cdc/org.gvsig.fmap.dal/org.gvsig.fmap.dal.db/org.gvsig.fmap.dal.db.jdbc/src/main/java/org/gvsig/fmap/dal/store/jdbc2/OperationsFactory.java	(revision 44057)
+++ trunk/org.gvsig.desktop/org.gvsig.desktop.compat.cdc/org.gvsig.fmap.dal/org.gvsig.fmap.dal.db/org.gvsig.fmap.dal.db.jdbc/src/main/java/org/gvsig/fmap/dal/store/jdbc2/OperationsFactory.java	(revision 44058)
@@ -10,6 +10,8 @@
 import org.gvsig.fmap.dal.feature.FeatureType;
 import org.gvsig.fmap.dal.SQLBuilder;
 import org.gvsig.fmap.dal.feature.spi.FeatureReferenceProviderServices;
+import org.gvsig.fmap.dal.store.jdbc.JDBCNewStoreParameters;
+import org.gvsig.fmap.dal.store.jdbc.JDBCServerExplorerParameters;
 import org.gvsig.fmap.dal.store.jdbc.JDBCStoreParameters;
 import org.gvsig.fmap.dal.store.jdbc2.spi.operations.AppendOperation;
 import org.gvsig.fmap.dal.store.jdbc2.spi.operations.CalculateEnvelopeOfColumnOperation;
@@ -30,35 +32,43 @@
 
 public interface OperationsFactory {
 
-    public FetchFeatureTypeOperation createFetchFeatureType(
-            EditableFeatureType type,
+    public interface TableReference {
+        public String getDatabase();
+        public String getSchema();
+        public String getTable();
+        public String getSubquery();
+        public boolean hasDatabase();
+        public boolean hasSchema();
+        public boolean hasTable();
+        public boolean hasSubquery();
+    }
+    
+    public TableReference createTableReference(
             String database,
             String schema,
             String table,
+            String subquery            
+    );
+    
+    public TableReference createTableReference(JDBCStoreParameters params);
+    public TableReference createTableReference(JDBCNewStoreParameters params);
+    
+    public FetchFeatureTypeOperation createFetchFeatureType(
+            EditableFeatureType type,
+            TableReference table,
             List<String> primaryKeys,
             String defaultGeometryField,
             IProjection crs
     );
     
-//    public FetchFeatureTypeOperation createFetchFeatureType(
-//                EditableFeatureType type, 
-//                String defaultGeometryField, 
-//                IProjection crs
-//    );
-//
     public FetchFeatureProviderByReferenceOperation createFetchFeatureProviderByReference(
             FeatureReferenceProviderServices reference,
             FeatureType featureType,
-            String database,
-            String schema,
-            String table
+            TableReference table
     );
 
     public CalculateEnvelopeOfColumnOperation createCalculateEnvelopeOfColumn(
-            String subquery,
-            String database,
-            String schema,
-            String table,
+            TableReference table,
             String columnName,
             String baseFilter,
             Envelope workingArea,
@@ -66,9 +76,7 @@
     );
 
     public PerformChangesOperation createPerformChanges(
-            String database,
-            String schema,
-            String table,
+            TableReference table,
             FeatureType type,
             Iterator deleteds,
             Iterator inserteds,
@@ -77,35 +85,24 @@
     );
 
     public AppendOperation createAppend(
-            String database,
-            String schema,
-            String table,
+            TableReference table,
             FeatureType type
     );
 
     public CountOperation createCount(
-            String database,
-            String schema,
-            String table,
-            String sql,
+            TableReference table,
             String baseFilter,
             String filter
     );
 
     public TableIsEmptyOperation createTableIsEmpty(
-            String database,
-            String schema,
-            String table,
-            String sql,
+            TableReference table,
             String baseFilter,
             String filtersql
     );
 
     public ResultSetForSetProviderOperation createResultSetForSetProvider(
-            String database,
-            String schema,
-            String table,
-            String subquery,
+            TableReference table,
             String baseFilter,
             String baseOrder,
             FeatureQuery query,
@@ -123,15 +120,11 @@
     );
 
     public DropTableOperation createDropTable(
-            String database,
-            String schemaName,
-            String tableName
+            TableReference table
     );
 
     public CreateTableOperation createTable(
-            String database,
-            String schemaName,
-            String tableName,
+            TableReference table,
             FeatureType type,
             List<Pair<String, SQLBuilder.Privilege>> userAndPrivileges,
             List<String> additionalSQLs
@@ -140,15 +133,11 @@
     public CanCreateTablesOperation createCanCreateTables();
     
     public UpdateTableStatisticsOperation createUpdateTableStatistics(
-            String database,
-            String schemaName,
-            String tableName
+            TableReference table
     );
 
     public CanModifyTableOperation createCanModifyTableOperation(
-            String dbName,
-            String schemaName, 
-            String tableName
+            TableReference table
     );
     
     public ExecuteOperation createExecute(String sql);
Index: trunk/org.gvsig.desktop/org.gvsig.desktop.compat.cdc/org.gvsig.fmap.dal/org.gvsig.fmap.dal.db/org.gvsig.fmap.dal.db.jdbc/src/main/java/org/gvsig/fmap/dal/store/jdbc2/spi/operations/CreateTableOperation.java
===================================================================
--- trunk/org.gvsig.desktop/org.gvsig.desktop.compat.cdc/org.gvsig.fmap.dal/org.gvsig.fmap.dal.db/org.gvsig.fmap.dal.db.jdbc/src/main/java/org/gvsig/fmap/dal/store/jdbc2/spi/operations/CreateTableOperation.java	(revision 44057)
+++ trunk/org.gvsig.desktop/org.gvsig.desktop.compat.cdc/org.gvsig.fmap.dal/org.gvsig.fmap.dal.db/org.gvsig.fmap.dal.db.jdbc/src/main/java/org/gvsig/fmap/dal/store/jdbc2/spi/operations/CreateTableOperation.java	(revision 44058)
@@ -5,7 +5,6 @@
 import java.sql.Statement;
 import java.util.ArrayList;
 import java.util.List;
-import org.apache.commons.collections.CollectionUtils;
 import org.apache.commons.lang3.tuple.Pair;
 import org.gvsig.fmap.dal.exception.DataException;
 import org.gvsig.fmap.dal.feature.FeatureAttributeDescriptor;
@@ -15,36 +14,31 @@
 import org.gvsig.fmap.dal.store.jdbc2.spi.JDBCSQLBuilderBase;
 import org.gvsig.fmap.dal.store.jdbc.exception.JDBCSQLException;
 import org.gvsig.fmap.dal.store.jdbc2.JDBCUtils;
+import org.gvsig.fmap.dal.store.jdbc2.OperationsFactory.TableReference;
 import org.gvsig.fmap.geom.DataTypes;
 
 public class CreateTableOperation extends AbstractConnectionWritableOperation {
 
-    private final String schemaName;
-    private final String tableName;
+    private final TableReference table;
     private final FeatureType type;
     private final List<Pair<String, SQLBuilder.Privilege>> userAndPrivileges;
     private final List<String> additionalSQLs;
-    private final String dbName;
 
     public CreateTableOperation(
             JDBCHelper helper
         ) {
-        this(helper, null, null, null, null, null, null);
+        this(helper, null, null, null, null);
     }
     
     public CreateTableOperation(
             JDBCHelper helper,
-            String dbName,
-            String schemaName,
-            String tableName,
+            TableReference table,
             FeatureType type,
             List<Pair<String, SQLBuilder.Privilege>> userAndPrivileges,
             List<String> additionalSQLs
         ) {
         super(helper);
-        this.dbName = dbName;
-        this.schemaName = schemaName;
-        this.tableName = tableName;
+        this.table = table;
         this.type = type;
         this.userAndPrivileges = userAndPrivileges;
         this.additionalSQLs = additionalSQLs;
@@ -53,14 +47,11 @@
     @Override
     public final Object perform(Connection conn) throws DataException {
         return this.performCreateTable(conn, 
-                dbName, schemaName, tableName,
-                type, userAndPrivileges, additionalSQLs);
+                table, type, userAndPrivileges, additionalSQLs);
     }
 
     protected List<String> buildCreateIndexesSQL(
-            String database,
-            String schema,
-            String table,
+            TableReference table,
             FeatureType type
         ) {
         ArrayList<String> sqls = new ArrayList<>();
@@ -74,7 +65,11 @@
                 sqlbuilder.create_index().if_not_exist();
                 sqlbuilder.create_index().name("idx_" + table + "_" + attr.getName());
                 sqlbuilder.create_index().column(attr.getName());
-                sqlbuilder.create_index().table().database(database).schema(schema).name(table);
+                sqlbuilder.create_index().table()
+                        .database(this.table.getDatabase())
+                        .schema(this.table.getSchema())
+                        .name(this.table.getTable()
+                );
                 sqls.addAll(sqlbuilder.create_index().toStrings());
             }
         }
@@ -82,15 +77,16 @@
     }
     
     public boolean performCreateTable(Connection conn,
-            String dbName, 
-            String schemaName,
-            String tableName,
+            TableReference table,
             FeatureType type,
             List<Pair<String, SQLBuilder.Privilege>> rolesAndPrivileges,
             List<String> additionalSQLs) throws DataException {
 
         JDBCSQLBuilderBase sqlbuilder = this.createSQLBuilder();
-        sqlbuilder.create_table().table().database(dbName).schema(schemaName).name(tableName);
+        sqlbuilder.create_table().table()
+                .database(this.table.getDatabase())
+                .schema(this.table.getSchema())
+                .name(this.table.getTable());
         for (FeatureAttributeDescriptor attr : type) {
             if( attr.getType()==DataTypes.GEOMETRY ) {
                 sqlbuilder.create_table().add_geometry_column(
@@ -121,7 +117,7 @@
 
         List<String> sqls;
         sqls = sqlbuilder.create_table().toStrings();
-        sqls.addAll(buildCreateIndexesSQL(dbName, schemaName, tableName, type));
+        sqls.addAll(buildCreateIndexesSQL(this.table,type));
         sqls.addAll(sqlbuilder.grant().toStrings());
         sqls.addAll(additionalSQLs);
 
Index: trunk/org.gvsig.desktop/org.gvsig.desktop.compat.cdc/org.gvsig.fmap.dal/org.gvsig.fmap.dal.db/org.gvsig.fmap.dal.db.jdbc/src/main/java/org/gvsig/fmap/dal/store/jdbc2/spi/operations/DropTableOperation.java
===================================================================
--- trunk/org.gvsig.desktop/org.gvsig.desktop.compat.cdc/org.gvsig.fmap.dal/org.gvsig.fmap.dal.db/org.gvsig.fmap.dal.db.jdbc/src/main/java/org/gvsig/fmap/dal/store/jdbc2/spi/operations/DropTableOperation.java	(revision 44057)
+++ trunk/org.gvsig.desktop/org.gvsig.desktop.compat.cdc/org.gvsig.fmap.dal/org.gvsig.fmap.dal.db/org.gvsig.fmap.dal.db.jdbc/src/main/java/org/gvsig/fmap/dal/store/jdbc2/spi/operations/DropTableOperation.java	(revision 44058)
@@ -8,44 +8,40 @@
 import org.gvsig.fmap.dal.store.jdbc2.spi.JDBCSQLBuilderBase;
 import org.gvsig.fmap.dal.store.jdbc.exception.JDBCSQLException;
 import org.gvsig.fmap.dal.store.jdbc2.JDBCUtils;
+import org.gvsig.fmap.dal.store.jdbc2.OperationsFactory.TableReference;
 
 public class DropTableOperation extends AbstractConnectionWritableOperation {
 
-    private final String schemaName;
-    private final String tableName;
-    private final String dbName;
+    private final TableReference table;
 
     public DropTableOperation(
             JDBCHelper helper
     ) {
-        this(helper, null, null, null);
+        this(helper, null);
     }
 
     public DropTableOperation(
             JDBCHelper helper,
-            String dbName,
-            String schemaName,
-            String tableName
+            TableReference table
     ) {
         super(helper);
-        this.dbName = dbName;
-        this.schemaName = schemaName;
-        this.tableName = tableName;
+        this.table = table;
     }
 
     @Override
     public final Object perform(Connection conn) throws DataException {
-        this.dropTable(conn, dbName, schemaName, tableName);
+        this.dropTable(conn, table);
         return true;
     }
 
     public void dropTable(Connection conn,
-            String dbName,
-            String schemaName,
-            String tableName) throws DataException {
+            TableReference table) throws DataException {
 
         JDBCSQLBuilderBase sqlbuilder = this.createSQLBuilder();
-        sqlbuilder.drop_table().table().database(dbName).schema(schemaName).name(tableName);
+        sqlbuilder.drop_table().table()
+                .database(this.table.getDatabase())
+                .schema(this.table.getSchema())
+                .name(this.table.getTable());
 
         Statement st = null;
         try {
Index: trunk/org.gvsig.desktop/org.gvsig.desktop.compat.cdc/org.gvsig.fmap.dal/org.gvsig.fmap.dal.db/org.gvsig.fmap.dal.db.jdbc/src/main/java/org/gvsig/fmap/dal/store/jdbc2/spi/operations/CanModifyTableOperation.java
===================================================================
--- trunk/org.gvsig.desktop/org.gvsig.desktop.compat.cdc/org.gvsig.fmap.dal/org.gvsig.fmap.dal.db/org.gvsig.fmap.dal.db.jdbc/src/main/java/org/gvsig/fmap/dal/store/jdbc2/spi/operations/CanModifyTableOperation.java	(revision 44057)
+++ trunk/org.gvsig.desktop/org.gvsig.desktop.compat.cdc/org.gvsig.fmap.dal/org.gvsig.fmap.dal.db/org.gvsig.fmap.dal.db.jdbc/src/main/java/org/gvsig/fmap/dal/store/jdbc2/spi/operations/CanModifyTableOperation.java	(revision 44058)
@@ -3,43 +3,32 @@
 import java.sql.Connection;
 import org.gvsig.fmap.dal.exception.DataException;
 import org.gvsig.fmap.dal.store.jdbc2.JDBCHelper;
+import org.gvsig.fmap.dal.store.jdbc2.OperationsFactory.TableReference;
 
 public class CanModifyTableOperation extends AbstractConnectionOperation {
 
-    private final String schemaName;
-    private final String tableName;
-    private final String dbName;
+    private final TableReference table;
 
     public CanModifyTableOperation(
             JDBCHelper helper
         ) {
-        this(helper, null, null, null);
+        this(helper, null);
     }
 
     public CanModifyTableOperation(
             JDBCHelper helper,
-            String dbName,
-            String schemaName,
-            String tableName
+            TableReference table
         ) {
         super(helper);
-        this.dbName = dbName;
-        this.schemaName = schemaName;
-        this.tableName = tableName;
+        this.table = table;
     }
 
     @Override
     public Object perform(Connection conn) throws DataException {
-        return this.canModifyTable(conn,
-                dbName, schemaName, tableName);
+        return this.canModifyTable(conn,table);
     }
 
-    public boolean canModifyTable(Connection conn,
-            String dbName,
-            String schemaName,
-            String tableName
-        ) throws DataException {
-
+    public boolean canModifyTable(Connection conn,TableReference table) throws DataException {
         return true;
     }
 
Index: trunk/org.gvsig.desktop/org.gvsig.desktop.compat.cdc/org.gvsig.fmap.dal/org.gvsig.fmap.dal.db/org.gvsig.fmap.dal.db.jdbc/src/main/java/org/gvsig/fmap/dal/store/jdbc2/spi/operations/AbstractConnectionOperation.java
===================================================================
--- trunk/org.gvsig.desktop/org.gvsig.desktop.compat.cdc/org.gvsig.fmap.dal/org.gvsig.fmap.dal.db/org.gvsig.fmap.dal.db.jdbc/src/main/java/org/gvsig/fmap/dal/store/jdbc2/spi/operations/AbstractConnectionOperation.java	(revision 44057)
+++ trunk/org.gvsig.desktop/org.gvsig.desktop.compat.cdc/org.gvsig.fmap.dal/org.gvsig.fmap.dal.db/org.gvsig.fmap.dal.db.jdbc/src/main/java/org/gvsig/fmap/dal/store/jdbc2/spi/operations/AbstractConnectionOperation.java	(revision 44058)
@@ -11,7 +11,7 @@
 
 public abstract class AbstractConnectionOperation implements ConnectionOperation {
 
-    final static protected Logger logger = LoggerFactory.getLogger(AbstractConnectionOperation.class);
+    final static protected Logger LOGGER = LoggerFactory.getLogger(AbstractConnectionOperation.class);
 
     final protected JDBCHelper helper;
     
@@ -55,7 +55,7 @@
     
     protected Object perform_operation() throws Exception {
         Object result = null;
-        logger.debug("preparing execution of "+this.getClass().getSimpleName()+".");
+        LOGGER.debug("preparing execution of "+this.getClass().getSimpleName()+".");
         if( needTransaction() ) {
             try {
                 // XXX OJO esta condicion NO ES FIABLE
@@ -66,7 +66,7 @@
                 }
                 this.getConnection().setAutoCommit(false);
                 try {
-                    logger.debug("Excuting operation {}.", this.getClass().getSimpleName());
+                    LOGGER.debug("Excuting operation {}.", this.getClass().getSimpleName());
                     result = perform(this.getConnection());
                 } catch (Exception ex) {
                     try {
@@ -83,7 +83,7 @@
             }
         } else {
             try {
-                logger.debug("Excuting operation {}.", this.getClass().getSimpleName());
+                LOGGER.debug("Excuting operation {}.", this.getClass().getSimpleName());
                 result = perform(this.getConnection());
             } catch (Exception ex) {
                 throw new RuntimeException("Can't perform operation '"+this.getClass().getSimpleName()+"'.",ex);
Index: trunk/org.gvsig.desktop/org.gvsig.desktop.compat.cdc/org.gvsig.fmap.dal/org.gvsig.fmap.dal.db/org.gvsig.fmap.dal.db.jdbc/src/main/java/org/gvsig/fmap/dal/store/jdbc2/spi/operations/OperationsFactoryBase.java
===================================================================
--- trunk/org.gvsig.desktop/org.gvsig.desktop.compat.cdc/org.gvsig.fmap.dal/org.gvsig.fmap.dal.db/org.gvsig.fmap.dal.db.jdbc/src/main/java/org/gvsig/fmap/dal/store/jdbc2/spi/operations/OperationsFactoryBase.java	(revision 44057)
+++ trunk/org.gvsig.desktop/org.gvsig.desktop.compat.cdc/org.gvsig.fmap.dal/org.gvsig.fmap.dal.db/org.gvsig.fmap.dal.db.jdbc/src/main/java/org/gvsig/fmap/dal/store/jdbc2/spi/operations/OperationsFactoryBase.java	(revision 44058)
@@ -2,6 +2,7 @@
 
 import java.util.Iterator;
 import java.util.List;
+import org.apache.commons.lang3.StringUtils;
 import org.apache.commons.lang3.tuple.Pair;
 import org.cresques.cts.IProjection;
 import org.gvsig.fmap.dal.exception.DataException;
@@ -10,6 +11,8 @@
 import org.gvsig.fmap.dal.feature.FeatureType;
 import org.gvsig.fmap.dal.SQLBuilder;
 import org.gvsig.fmap.dal.feature.spi.FeatureReferenceProviderServices;
+import org.gvsig.fmap.dal.store.jdbc.JDBCNewStoreParameters;
+import org.gvsig.fmap.dal.store.jdbc.JDBCServerExplorerParameters;
 import org.gvsig.fmap.dal.store.jdbc.JDBCStoreParameters;
 import org.gvsig.fmap.dal.store.jdbc2.JDBCHelper;
 import org.gvsig.fmap.dal.store.jdbc2.OperationsFactory;
@@ -17,6 +20,62 @@
 
 public class OperationsFactoryBase implements OperationsFactory {
 
+    protected class DefaultTableReference implements TableReference {
+
+        private final String database;
+        private final String schema;
+        private final String table;
+        private final String subquery;
+
+        public DefaultTableReference(String database, String schema, String table, String subquery) {
+            this.database = StringUtils.defaultIfBlank(database, null);
+            this.schema = StringUtils.defaultIfBlank(schema, null);
+            this.table = StringUtils.defaultIfBlank(table, null);
+            this.subquery = StringUtils.defaultIfBlank(subquery, null);
+        }
+        
+        @Override
+        public String getDatabase() {
+            return this.database;
+        }
+
+        @Override
+        public String getSchema() {
+            return this.schema;
+        }
+
+        @Override
+        public String getTable() {
+            return this.table;
+        }
+
+        @Override
+        public String getSubquery() {
+            return this.subquery;
+        }
+
+        @Override
+        public boolean hasDatabase() {
+            return this.database != null;
+        }
+        
+        @Override
+        public boolean hasSchema() {
+            return this.schema != null;
+        }
+        
+        @Override
+        public boolean hasTable() {
+            return this.table != null;
+        }
+        
+        @Override
+        public boolean hasSubquery() {
+            return this.subquery != null;
+        }
+        
+    }
+    
     protected final JDBCHelper helper;
 
     public OperationsFactoryBase(JDBCHelper helper) {
@@ -24,112 +83,110 @@
     }
 
     @Override
+    public TableReference createTableReference(JDBCStoreParameters params) {
+        TableReference t = new DefaultTableReference(
+                params.getDBName(),
+                params.getSchema(),
+                params.getTable(),
+                params.getSQL()
+        );
+        return t;
+    }
+
+    @Override
+    public TableReference createTableReference(JDBCNewStoreParameters params) {
+        TableReference t = new DefaultTableReference(
+                params.getDBName(),
+                params.getSchema(),
+                params.getTable(),
+                null
+        );
+        return t;
+    }
+
+    @Override
+    public TableReference createTableReference(String database, String schema, String table, String subquery) {
+        TableReference t = new DefaultTableReference(database, schema, table, subquery);
+        return t;
+    }
+
+    
+    @Override
     public FetchFeatureTypeOperation createFetchFeatureType(
             EditableFeatureType type, 
-            String database,
-            String schema, 
-            String table, 
+            TableReference table, 
             List<String> primaryKeys, 
             String defaultGeometryField, 
             IProjection crs
         ) {
-        return new FetchFeatureTypeOperation(helper, type, database, schema, table, 
+        return new FetchFeatureTypeOperation(helper, type, table, 
                 primaryKeys, defaultGeometryField, crs);
     }
     
-//    @Override
-//    public FetchFeatureTypeOperation createFetchFeatureType(
-//            EditableFeatureType type, 
-//            String defaultGeometryField, 
-//            IProjection crs
-//        ) {
-//        return new FetchFeatureTypeOperation(helper, type, defaultGeometryField, crs);
-//    }
-
     @Override
     public FetchFeatureProviderByReferenceOperation createFetchFeatureProviderByReference(
             FeatureReferenceProviderServices reference, 
             FeatureType featureType, 
-            String database,
-            String schema, 
-            String table
+            TableReference table
         ) {
         return new FetchFeatureProviderByReferenceOperation(helper, reference, 
-                featureType, database, schema, table);
+                featureType, table);
     }
 
     @Override
     public CalculateEnvelopeOfColumnOperation createCalculateEnvelopeOfColumn(
-            String subquery, 
-            String database,
-            String schema, 
-            String table, 
+            TableReference table, 
             String columnName, 
             String baseFilter, 
             Envelope workingArea, 
             IProjection crs
         ) {
-        return new CalculateEnvelopeOfColumnOperation(helper, subquery, database, schema, 
+        return new CalculateEnvelopeOfColumnOperation(helper, 
                 table, columnName, baseFilter, workingArea, crs);
     }
 
     @Override
     public PerformChangesOperation createPerformChanges(
-            String database,
-            String schema, 
-            String table, 
+            TableReference table, 
             FeatureType type, 
             Iterator deleteds, 
             Iterator inserteds, 
             Iterator updateds, 
             Iterator featureTypesChanged
         ) {
-        return new PerformChangesOperation(helper, database,schema, table, type, 
+        return new PerformChangesOperation(helper, table, type, 
                 deleteds, inserteds, updateds, featureTypesChanged);
     }
 
     @Override
     public AppendOperation createAppend(
-            String database,
-            String schema, 
-            String table, 
+            TableReference table, 
             FeatureType type
         ) {
-        return new AppendOperation(helper, database,schema, table, type);
+        return new AppendOperation(helper, table, type);
     }
 
     @Override
     public CountOperation createCount(
-            String database,
-            String schema, 
-            String table, 
-            String sql, 
+            TableReference table, 
             String baseFilter, 
             String filter
         ) {
-        return new CountOperation(helper, database, schema, table, sql, 
-                baseFilter, filter);
+        return new CountOperation(helper, table, baseFilter, filter);
     }
 
     @Override
     public TableIsEmptyOperation createTableIsEmpty(
-            String database,
-            String schema, 
-            String table,
-            String sql, 
+            TableReference table,
             String baseFilter, 
             String filter
         ) {
-        return new TableIsEmptyOperation(helper, database, schema, table, sql, 
-                baseFilter, filter);
+        return new TableIsEmptyOperation(helper, table, baseFilter, filter);
     }
 
     @Override
     public ResultSetForSetProviderOperation createResultSetForSetProvider(
-            String database,
-            String schema, 
-            String table, 
-            String subquery, 
+            TableReference table, 
             String baseFilter, 
             String baseOrder, 
             FeatureQuery query, 
@@ -139,8 +196,8 @@
             long offset, 
             int fetchSize
         ) {
-        return new ResultSetForSetProviderOperation(helper, database, schema, table, 
-                subquery, baseFilter, baseOrder, query, storeType, setType, 
+        return new ResultSetForSetProviderOperation(helper, table, 
+                baseFilter, baseOrder, query, storeType, setType, 
                 limit, offset, fetchSize);
     }
 
@@ -156,24 +213,20 @@
     
     @Override
     public DropTableOperation createDropTable( 
-            String dbName,
-            String schemaName,
-            String tableName            
+            TableReference tableName            
         ) {
-        return new DropTableOperation(helper, dbName, schemaName, tableName);
+        return new DropTableOperation(helper, tableName);
     }
     
     @Override
     public CreateTableOperation createTable(
-            String dbName,
-            String schemaName, 
-            String tableName, 
+            TableReference table, 
             FeatureType type, 
             List<Pair<String, SQLBuilder.Privilege>> userAndPrivileges, 
             List<String> additionalSQLs
         ) throws DataException {
         return new CreateTableOperation(
-                helper, dbName, schemaName, tableName, type, 
+                helper, table, type, 
                 userAndPrivileges, additionalSQLs
         );
     }
@@ -185,20 +238,16 @@
 
     @Override
     public UpdateTableStatisticsOperation createUpdateTableStatistics(
-            String dbName,
-            String schemaName, 
-            String tableName
+            TableReference table
         ) {
-        return new UpdateTableStatisticsOperation(helper, dbName, schemaName, tableName);
+        return new UpdateTableStatisticsOperation(helper, table);
     }
     
     @Override
     public CanModifyTableOperation createCanModifyTableOperation(
-            String dbName,
-            String schemaName, 
-            String tableName
+            TableReference table
         ) {
-        return new CanModifyTableOperation(helper, dbName, schemaName, tableName);
+        return new CanModifyTableOperation(helper, table);
     }
     
     @Override
Index: trunk/org.gvsig.desktop/org.gvsig.desktop.compat.cdc/org.gvsig.fmap.dal/org.gvsig.fmap.dal.db/org.gvsig.fmap.dal.db.jdbc/src/main/java/org/gvsig/fmap/dal/store/jdbc2/spi/operations/ResultSetForSetProviderOperation.java
===================================================================
--- trunk/org.gvsig.desktop/org.gvsig.desktop.compat.cdc/org.gvsig.fmap.dal/org.gvsig.fmap.dal.db/org.gvsig.fmap.dal.db.jdbc/src/main/java/org/gvsig/fmap/dal/store/jdbc2/spi/operations/ResultSetForSetProviderOperation.java	(revision 44057)
+++ trunk/org.gvsig.desktop/org.gvsig.desktop.compat.cdc/org.gvsig.fmap.dal/org.gvsig.fmap.dal.db/org.gvsig.fmap.dal.db.jdbc/src/main/java/org/gvsig/fmap/dal/store/jdbc2/spi/operations/ResultSetForSetProviderOperation.java	(revision 44058)
@@ -13,15 +13,14 @@
 import org.gvsig.fmap.dal.feature.FeatureQueryOrder.FeatureQueryOrderMember;
 import org.gvsig.fmap.dal.feature.FeatureType;
 import org.gvsig.fmap.dal.store.jdbc2.JDBCHelper;
+import org.gvsig.fmap.dal.store.jdbc2.OperationsFactory.TableReference;
 import org.gvsig.fmap.dal.store.jdbc2.ResulSetControler.ResultSetEntry;
 import org.gvsig.fmap.dal.store.jdbc2.spi.JDBCSQLBuilderBase;
 import org.gvsig.fmap.geom.DataTypes;
 import org.gvsig.tools.evaluator.Evaluator;
 
 public class ResultSetForSetProviderOperation extends AbstractConnectionOperation {
-    private final String schema;
-    private final String table;
-    private final String subquery;
+    private final TableReference table;
     private final String baseFilter;
     private final String baseOrder;
     private final FeatureType storeType;
@@ -30,14 +29,10 @@
     private final long limit;
     private final long offset;
     private final int fetchSize;
-    private final String database;
 
     public ResultSetForSetProviderOperation(
             JDBCHelper helper,
-            String database,
-            String schema,
-            String table,
-            String subquery,
+            TableReference table,
             String baseFilter,
             String baseOrder,
             FeatureQuery query,
@@ -48,10 +43,7 @@
             int fetchSize
         ) {
         super(helper);
-        this.database = database;
-        this.schema = schema;
         this.table = table;
-        this.subquery = subquery;
         this.baseFilter = baseFilter;
         this.baseOrder = baseOrder;
         this.storeType = storeType;
@@ -65,8 +57,7 @@
     @Override
     protected Object perform_operation() throws Exception {
         ResultSetEntry rs = createResultSet(
-                database, schema, table, subquery, 
-                baseFilter, baseOrder, storeType, setType, query, 
+                table, baseFilter, baseOrder, storeType, setType, query, 
                 limit, offset, fetchSize);
         return rs;
     }
@@ -77,10 +68,7 @@
     }
     
     public ResultSetEntry createResultSet(
-            String database,
-            String schema,
-            String table,
-            String subquery,
+            TableReference table,
             String baseFilter,
             String baseOrder,
             FeatureType storeType,
@@ -134,13 +122,13 @@
             columns.add(setType.getAttributeDescriptor(attrName));
         }
         
-        if( StringUtils.isEmpty(subquery)  ) {
-            sqlbuilder.select().from().table().database(database).schema(schema).name(table);
-        } else {
-            sqlbuilder.select().from().subquery(subquery);
-        }
+        sqlbuilder.select().from().table()
+                .database(this.table.getDatabase())
+                .schema(this.table.getSchema())
+                .name(this.table.getTable());
+        sqlbuilder.select().from().subquery(this.table.getSubquery());
         
-        Evaluator filter = query.getFilter();
+        Evaluator filter = query==null? null:query.getFilter();
         if( filter != null ) {
             String sqlfilter = filter.getSQL();
             if( ! StringUtils.isEmpty(sqlfilter) ) {
@@ -151,7 +139,7 @@
             sqlbuilder.select().where().and(sqlbuilder.custom(baseFilter));
         }
         
-        FeatureQueryOrder order = query.getOrder();
+        FeatureQueryOrder order = query==null? null:query.getOrder();
         if( order != null ) {
             for( FeatureQueryOrderMember member : order.members() ) {
                 if( member.hasEvaluator() ) {
@@ -188,7 +176,7 @@
         if( limit > 0 ) {
             sqlbuilder.select().limit(limit);
         } else {
-            sqlbuilder.select().limit(query.getLimit());
+            sqlbuilder.select().limit(query==null? null:query.getLimit());
         }
         if( offset>0 ) {
             sqlbuilder.select().offset(offset);
Index: trunk/org.gvsig.desktop/org.gvsig.desktop.compat.cdc/org.gvsig.fmap.dal/org.gvsig.fmap.dal.db/org.gvsig.fmap.dal.db.jdbc/src/main/java/org/gvsig/fmap/dal/store/jdbc2/spi/operations/CountOperation.java
===================================================================
--- trunk/org.gvsig.desktop/org.gvsig.desktop.compat.cdc/org.gvsig.fmap.dal/org.gvsig.fmap.dal.db/org.gvsig.fmap.dal.db.jdbc/src/main/java/org/gvsig/fmap/dal/store/jdbc2/spi/operations/CountOperation.java	(revision 44057)
+++ trunk/org.gvsig.desktop/org.gvsig.desktop.compat.cdc/org.gvsig.fmap.dal/org.gvsig.fmap.dal.db/org.gvsig.fmap.dal.db.jdbc/src/main/java/org/gvsig/fmap/dal/store/jdbc2/spi/operations/CountOperation.java	(revision 44058)
@@ -10,59 +10,50 @@
 import org.gvsig.fmap.dal.store.jdbc2.spi.JDBCSQLBuilderBase;
 import org.gvsig.fmap.dal.store.jdbc.exception.JDBCSQLException;
 import org.gvsig.fmap.dal.store.jdbc2.JDBCUtils;
+import org.gvsig.fmap.dal.store.jdbc2.OperationsFactory.TableReference;
 
 public class CountOperation extends AbstractConnectionOperation {
 
-    private final String schemaName;
-    private final String tableName;
-    private final String subquery;
+    private final TableReference table;
     private final String baseFilter;
     private final String filter;
-    private final String dbName;
 
     public CountOperation(
             JDBCHelper helper
         ) {
-        this(helper, null, null, null, null, null, null);
+        this(helper, null, null, null);
     }
 
     public CountOperation(
             JDBCHelper helper,
-            String dbName,
-            String schemaName,
-            String tableName,
-            String subquery,
+            TableReference table,
             String baseFilter,
             String filter
         ) {
         super(helper);
-        this.dbName = dbName;
-        this.schemaName = schemaName;
-        this.tableName = tableName;
-        this.subquery = subquery;
+        this.table = table;
         this.baseFilter = baseFilter;
         this.filter = filter;
     }
 
     @Override
     public final Object perform(Connection conn) throws DataException {
-        return this.count(conn,
-                dbName, schemaName, tableName, subquery, baseFilter, filter);
+        return this.count(conn, table, baseFilter, filter);
     }
 
     public long count(Connection conn,
-            String dbName, 
-            String schemaName,
-            String tableName,
-            String subquery,
+            TableReference table,
             String baseFilter,
             String filter) throws DataException {
 
         JDBCSQLBuilderBase sqlbuilder = this.createSQLBuilder();
 
         sqlbuilder.select().column().value(sqlbuilder.count().all());
-        sqlbuilder.select().from().table().database(dbName).schema(schemaName).name(tableName);
-        sqlbuilder.select().from().subquery(subquery);
+        sqlbuilder.select().from().table()
+                .database(this.table.getDatabase())
+                .schema(this.table.getSchema())
+                .name(this.table.getTable());
+        sqlbuilder.select().from().subquery(this.table.getSubquery());
         if (!StringUtils.isEmpty(baseFilter)) {
             sqlbuilder.select().where().set( sqlbuilder.custom(baseFilter) );
         }
Index: trunk/org.gvsig.desktop/org.gvsig.desktop.compat.cdc/org.gvsig.fmap.dal/org.gvsig.fmap.dal.db/org.gvsig.fmap.dal.db.jdbc/src/main/java/org/gvsig/fmap/dal/store/jdbc2/spi/operations/FetchFeatureProviderByReferenceOperation.java
===================================================================
--- trunk/org.gvsig.desktop/org.gvsig.desktop.compat.cdc/org.gvsig.fmap.dal/org.gvsig.fmap.dal.db/org.gvsig.fmap.dal.db.jdbc/src/main/java/org/gvsig/fmap/dal/store/jdbc2/spi/operations/FetchFeatureProviderByReferenceOperation.java	(revision 44057)
+++ trunk/org.gvsig.desktop/org.gvsig.desktop.compat.cdc/org.gvsig.fmap.dal/org.gvsig.fmap.dal.db/org.gvsig.fmap.dal.db.jdbc/src/main/java/org/gvsig/fmap/dal/store/jdbc2/spi/operations/FetchFeatureProviderByReferenceOperation.java	(revision 44058)
@@ -15,6 +15,7 @@
 import org.gvsig.fmap.dal.store.jdbc.exception.JDBCSQLException;
 import org.gvsig.fmap.dal.store.jdbc2.JDBCHelper;
 import org.gvsig.fmap.dal.store.jdbc2.JDBCUtils;
+import org.gvsig.fmap.dal.store.jdbc2.OperationsFactory.TableReference;
 import org.gvsig.fmap.dal.store.jdbc2.spi.JDBCSQLBuilderBase;
 import org.gvsig.fmap.geom.DataTypes;
 
@@ -22,22 +23,16 @@
 public class FetchFeatureProviderByReferenceOperation extends AbstractConnectionOperation {
     private final FeatureType featureType;
     private final FeatureReferenceProviderServices reference;
-    private final String schema;
-    private final String table;
-    private final String database;
+    private final TableReference table;
 
     public FetchFeatureProviderByReferenceOperation(
             JDBCHelper helper,
             FeatureReferenceProviderServices reference,
             FeatureType featureType,
-            String database,
-            String schema,
-            String table
+            TableReference table
         ) {
         super(helper);
         this.reference = reference;
-        this.database = database;
-        this.schema = schema;
         this.table = table;
         this.featureType = featureType;
     }
@@ -48,8 +43,6 @@
                 conn,
                 reference, 
                 featureType,
-                database,
-                schema,
                 table
         );
         return feature;
@@ -60,9 +53,7 @@
             FeatureReferenceProviderServices reference,
             // FeatureType storeType,
             FeatureType featureType,
-            String database,
-            String schema,
-            String table
+            TableReference table
         ) throws DataException {
         List<FeatureAttributeDescriptor> columns = new ArrayList<>();        
         
@@ -80,7 +71,10 @@
                 columns.add(attr);
             }
         }
-        sqlbuilder.select().from().table().database(database).schema(schema).name(table);
+        sqlbuilder.select().from().table()
+                .database(this.table.getDatabase())
+                .schema(this.table.getSchema())
+                .name(this.table.getTable());
         for (String name : primaryKeys )  {
             if( !sqlbuilder.select().has_column(name) ) {
                 sqlbuilder.select().column().name(name);
Index: trunk/org.gvsig.desktop/org.gvsig.desktop.compat.cdc/org.gvsig.fmap.dal/org.gvsig.fmap.dal.db/org.gvsig.fmap.dal.db.jdbc/src/main/java/org/gvsig/fmap/dal/store/jdbc2/spi/operations/CalculateEnvelopeOfColumnOperation.java
===================================================================
--- trunk/org.gvsig.desktop/org.gvsig.desktop.compat.cdc/org.gvsig.fmap.dal/org.gvsig.fmap.dal.db/org.gvsig.fmap.dal.db.jdbc/src/main/java/org/gvsig/fmap/dal/store/jdbc2/spi/operations/CalculateEnvelopeOfColumnOperation.java	(revision 44057)
+++ trunk/org.gvsig.desktop/org.gvsig.desktop.compat.cdc/org.gvsig.fmap.dal/org.gvsig.fmap.dal.db/org.gvsig.fmap.dal.db.jdbc/src/main/java/org/gvsig/fmap/dal/store/jdbc2/spi/operations/CalculateEnvelopeOfColumnOperation.java	(revision 44058)
@@ -10,37 +10,29 @@
 import org.gvsig.fmap.dal.store.jdbc.exception.JDBCSQLException;
 import org.gvsig.fmap.dal.store.jdbc2.JDBCHelper;
 import org.gvsig.fmap.dal.store.jdbc2.JDBCUtils;
+import org.gvsig.fmap.dal.store.jdbc2.OperationsFactory.TableReference;
 import org.gvsig.fmap.dal.store.jdbc2.spi.JDBCSQLBuilderBase;
 import org.gvsig.fmap.geom.Geometry;
 import org.gvsig.fmap.geom.primitive.Envelope;
 
 public class CalculateEnvelopeOfColumnOperation extends AbstractConnectionOperation {
 
-    private final String subquery;
-    private final String schemaName;
-    private final String tableName;
+    private final TableReference table;
     private final String columnName;
     private final String baseFilter;
     private final Envelope limit;
     private final IProjection crs;
-    private final String dbName;
 
     public CalculateEnvelopeOfColumnOperation(
             JDBCHelper helper,
-            String subquery,
-            String dbName,
-            String schemaName,
-            String tableName,
+            TableReference table,
             String columnName,
             String baseFilter,
             Envelope limit,
             IProjection crs
     ) {
         super(helper);
-        this.subquery = subquery;
-        this.dbName = dbName;
-        this.schemaName = schemaName;
-        this.tableName = tableName;
+        this.table = table;
         this.columnName = columnName;
         this.baseFilter = baseFilter;
         this.limit = limit;
@@ -51,10 +43,7 @@
     public final Object perform(Connection conn) throws DataException {
         Envelope env = calculateEnvelopeOfColumn(
             conn,
-            subquery,
-            dbName,
-            schemaName,
-            tableName,
+            table,
             columnName,
             baseFilter,
             limit,
@@ -65,10 +54,7 @@
 
     public Envelope calculateEnvelopeOfColumn(
             Connection conn,
-            String subquery,
-            String dbName,
-            String schemaName,
-            String tableName,
+            TableReference table,
             String columnName,
             String baseFilter,
             Envelope limit,
@@ -92,11 +78,11 @@
             )
         );
 
-        if (StringUtils.isEmpty(subquery)) {
-            sqlbuilder.select().from().table().database(dbName).schema(schemaName).name(tableName);
-        } else {
-            sqlbuilder.select().from().subquery(subquery);
-        }
+        sqlbuilder.select().from().table()
+                .database(this.table.getDatabase())
+                .schema(this.table.getSchema())
+                .name(this.table.getTable());
+        sqlbuilder.select().from().subquery(this.table.getSubquery());
 
         if (StringUtils.isEmpty(baseFilter)) {
             if (limit != null) {
Index: trunk/org.gvsig.desktop/org.gvsig.desktop.compat.cdc/org.gvsig.fmap.dal/org.gvsig.fmap.dal.db/org.gvsig.fmap.dal.db.jdbc/src/main/java/org/gvsig/fmap/dal/store/jdbc2/spi/operations/TableIsEmptyOperation.java
===================================================================
--- trunk/org.gvsig.desktop/org.gvsig.desktop.compat.cdc/org.gvsig.fmap.dal/org.gvsig.fmap.dal.db/org.gvsig.fmap.dal.db.jdbc/src/main/java/org/gvsig/fmap/dal/store/jdbc2/spi/operations/TableIsEmptyOperation.java	(revision 44057)
+++ trunk/org.gvsig.desktop/org.gvsig.desktop.compat.cdc/org.gvsig.fmap.dal/org.gvsig.fmap.dal.db/org.gvsig.fmap.dal.db.jdbc/src/main/java/org/gvsig/fmap/dal/store/jdbc2/spi/operations/TableIsEmptyOperation.java	(revision 44058)
@@ -10,59 +10,51 @@
 import org.gvsig.fmap.dal.store.jdbc2.spi.JDBCSQLBuilderBase;
 import org.gvsig.fmap.dal.store.jdbc.exception.JDBCSQLException;
 import org.gvsig.fmap.dal.store.jdbc2.JDBCUtils;
+import org.gvsig.fmap.dal.store.jdbc2.OperationsFactory.TableReference;
 
 public class TableIsEmptyOperation extends AbstractConnectionOperation {
 
-    private final String schemaName;
-    private final String tableName;
-    private final String subquery;
+    private final TableReference table;
     private final String baseFilter;
     private final String filter;
-    private final String dbName;
 
     public TableIsEmptyOperation(
             JDBCHelper helper
         ) {
-        this(helper, null, null, null, null, null, null);
+        this(helper, null, null, null);
     }
 
     public TableIsEmptyOperation(
             JDBCHelper helper,
-            String dbName,
-            String schemaName,
-            String tableName,
-            String subquery,
+            TableReference table,
             String baseFilter,
             String filter
         ) {
         super(helper);
-        this.dbName = dbName;
-        this.schemaName = schemaName;
-        this.tableName = tableName;
-        this.subquery = subquery;
+        this.table = table;
         this.baseFilter = baseFilter;
         this.filter = filter;
     }
 
     @Override
     public final Object perform(Connection conn) throws DataException {
-        return this.tableIsEmpty(conn,
-                dbName, schemaName, tableName, subquery, baseFilter, filter);
+        return this.tableIsEmpty(conn, table, baseFilter, filter);
     }
 
     public boolean tableIsEmpty(Connection conn,
-            String database,
-            String schema,
-            String table,
-            String subquery,
+            TableReference table,
             String baseFilter,
-            String filter) throws DataException {
+            String filter
+        ) throws DataException {
 
         JDBCSQLBuilderBase sqlbuilder = this.createSQLBuilder();
 
         sqlbuilder.select().column().all();
-        sqlbuilder.select().from().table().database(database).schema(schema).name(table);
-        sqlbuilder.select().from().subquery(subquery);
+        sqlbuilder.select().from().table()
+                .database(this.table.getDatabase())
+                .schema(this.table.getSchema())
+                .name(this.table.getTable());
+        sqlbuilder.select().from().subquery(this.table.getSubquery());
         if (!StringUtils.isEmpty(baseFilter)) {
             sqlbuilder.select().where().set( sqlbuilder.custom(baseFilter) );
         }
Index: trunk/org.gvsig.desktop/org.gvsig.desktop.compat.cdc/org.gvsig.fmap.dal/org.gvsig.fmap.dal.db/org.gvsig.fmap.dal.db.jdbc/src/main/java/org/gvsig/fmap/dal/store/jdbc2/spi/operations/PerformChangesOperation.java
===================================================================
--- trunk/org.gvsig.desktop/org.gvsig.desktop.compat.cdc/org.gvsig.fmap.dal/org.gvsig.fmap.dal.db/org.gvsig.fmap.dal.db.jdbc/src/main/java/org/gvsig/fmap/dal/store/jdbc2/spi/operations/PerformChangesOperation.java	(revision 44057)
+++ trunk/org.gvsig.desktop/org.gvsig.desktop.compat.cdc/org.gvsig.fmap.dal/org.gvsig.fmap.dal.db/org.gvsig.fmap.dal.db.jdbc/src/main/java/org/gvsig/fmap/dal/store/jdbc2/spi/operations/PerformChangesOperation.java	(revision 44058)
@@ -23,14 +23,13 @@
 import org.gvsig.fmap.dal.store.jdbc.exception.JDBCUpdateWithoutChangesException;
 import org.gvsig.fmap.dal.store.jdbc2.spi.JDBCSQLBuilderBase;
 import org.gvsig.fmap.dal.store.jdbc2.JDBCUtils;
+import org.gvsig.fmap.dal.store.jdbc2.OperationsFactory.TableReference;
 import org.gvsig.tools.dispose.Disposable;
 import org.gvsig.tools.dispose.DisposeUtils;
 
 public class PerformChangesOperation extends AbstractConnectionWritableOperation {
 
-    protected String dbName;
-    protected String schemaName;
-    protected String tableName;
+    protected TableReference table;
     protected FeatureType featureType;
     protected Iterator<FeatureReferenceProviderServices> deleteds;
     protected Iterator<FeatureStoreProvider.FeatureTypeChanged> featureTypesChanged;
@@ -40,25 +39,21 @@
     protected boolean typeChanged = false;
     
     public PerformChangesOperation(JDBCHelper helper) {
-        this(helper, null, null, null, null, null, null, null, null);
+        this(helper, null, null, null, null, null, null);
     }
 
     public PerformChangesOperation(JDBCHelper helper,
-            String dbName,
-            String schemaName,
-            String tableName,
+            TableReference table,
             FeatureType featureType,
             Iterator<FeatureReferenceProviderServices> deleteds,
             Iterator<FeatureProvider> inserteds,
             Iterator<FeatureProvider> updateds,
             Iterator<FeatureStoreProvider.FeatureTypeChanged> featureTypesChanged) {
         super(helper);
-        this.dbName = dbName;
         this.deleteds = deleteds;
         this.inserteds = inserteds;
         this.updateds = updateds;
-        this.schemaName = schemaName;
-        this.tableName = tableName;
+        this.table = table;
         this.featureType = featureType;
         this.featureTypesChanged = featureTypesChanged;
     }
@@ -71,31 +66,32 @@
     public Object perform(Connection conn) throws DataException {
         if (featureTypesChanged.hasNext()) {
             FeatureStoreProvider.FeatureTypeChanged item = featureTypesChanged.next();
-            this.performUpdateTable(conn, dbName, schemaName, tableName, item.getSource(), item.getTarget());
+            this.performUpdateTable(conn, table, item.getSource(), item.getTarget());
             typeChanged = true;
         } else {
             typeChanged = false;
         }
         if (deleteds.hasNext()) {
-            performDeletes(conn, dbName, schemaName, tableName, featureType, deleteds);
+            performDeletes(conn, table, featureType, deleteds);
         }
         if (updateds.hasNext()) {
-            performUpdates(conn, dbName, schemaName, tableName, featureType, updateds);
+            performUpdates(conn, table, featureType, updateds);
         }
         if (inserteds.hasNext()) {
-            performInserts(conn, dbName, schemaName, tableName, featureType, inserteds);
+            performInserts(conn, table, featureType, inserteds);
         }
         return true;
     }
     
     protected JDBCSQLBuilderBase buildDeleteSQL(
-            String database,
-            String schema,
-            String table,
+            TableReference table,
             FeatureType type
         ) {
         JDBCSQLBuilderBase sqlbuilder = createSQLBuilder();
-        sqlbuilder.delete().table().database(database).schema(schema).name(table);
+        sqlbuilder.delete().table()
+                .database(this.table.getDatabase())
+                .schema(this.table.getSchema())
+                .name(this.table.getTable());
         for (FeatureAttributeDescriptor attr : type) {
             if (attr.isPrimaryKey()) {
                 sqlbuilder.delete().where().and(
@@ -113,13 +109,11 @@
     }
 
     public void performDeletes(Connection conn,
-            String database,
-            String schema,
-            String table,
+            TableReference table,
             FeatureType type,
             Iterator<FeatureReferenceProviderServices> deleteds) throws DataException {
 
-        JDBCSQLBuilderBase sqlbuilder = buildDeleteSQL(database, schema, table, type);
+        JDBCSQLBuilderBase sqlbuilder = buildDeleteSQL(table, type);
 
         PreparedStatement st = null;
         Disposable paramsDisposer = null;
@@ -137,7 +131,7 @@
                     );
                 }
                 if (nAffected > 1) {
-                    logger.warn("Remove statement affectst to {} rows ( {} )",
+                    LOGGER.warn("Remove statement affectst to {} rows ( {} )",
                             nAffected, sql
                     );
                 }
@@ -151,14 +145,15 @@
     }
     
     protected JDBCSQLBuilderBase buildInsertSQL(
-            String database,
-            String schema,
-            String table,
+            TableReference table,
             FeatureType type
         ) {
         JDBCSQLBuilderBase sqlbuilder = createSQLBuilder();
 
-        sqlbuilder.insert().table().database(database).schema(schema).name(table);
+        sqlbuilder.insert().table()
+                .database(this.table.getDatabase())
+                .schema(this.table.getSchema())
+                .name(this.table.getTable());
         for (FeatureAttributeDescriptor attr : type) {
             if( attr.isAutomatic() ) {
                 continue;
@@ -179,12 +174,10 @@
     }
 
     public void performInserts(Connection conn,
-            String database,
-            String schema,
-            String table,
+            TableReference table,
             FeatureType type,
             Iterator<FeatureProvider> inserteds) throws DataException {
-        JDBCSQLBuilderBase sqlbuilder = buildInsertSQL(database, schema, table, type);
+        JDBCSQLBuilderBase sqlbuilder = buildInsertSQL(table, type);
 
         PreparedStatement st;
         Disposable paramsDisposer;
@@ -213,14 +206,15 @@
     }
 
     protected JDBCSQLBuilderBase buildUpdateSQL(
-            String database,
-            String schema,
-            String table,
+            TableReference table,
             FeatureType type
         ) {
         JDBCSQLBuilderBase sqlbuilder = createSQLBuilder();
 
-        sqlbuilder.update().table().database(database).schema(schema).name(table);
+        sqlbuilder.update().table()
+                .database(this.table.getDatabase())
+                .schema(this.table.getSchema())
+                .name(this.table.getTable());
         for (FeatureAttributeDescriptor attr : type) {
             if (attr.isPrimaryKey()) {
                 sqlbuilder.update().where().and(
@@ -250,13 +244,11 @@
     }
     
     public void performUpdates(Connection conn,
-            String database,
-            String schema,
-            String table,
+            TableReference table,
             FeatureType type,
             Iterator<FeatureProvider> updateds) throws DataException {
 
-        JDBCSQLBuilderBase sqlbuilder = buildUpdateSQL(database, schema, table, type);
+        JDBCSQLBuilderBase sqlbuilder = buildUpdateSQL(table, type);
         
         PreparedStatement st = null;
         Disposable paramsDisposer = null;
@@ -279,14 +271,15 @@
     }
 
     protected List<String> buildUpdateTableSQL(
-            String database,
-            String schema,
-            String table,
+            TableReference table,
             FeatureType original,
             FeatureType target
         ) {
         JDBCSQLBuilderBase sqlbuilder = createSQLBuilder();
-        sqlbuilder.alter_table().table().database(database).schema(schema).name(table);
+        sqlbuilder.alter_table().table()
+                .database(this.table.getDatabase())
+                .schema(this.table.getSchema())
+                .name(this.table.getTable());
 
         for (FeatureAttributeDescriptor attrOrgiginal : original) {
             FeatureAttributeDescriptor attrTarget = target.getAttributeDescriptor(
@@ -387,9 +380,7 @@
     }
 
     protected List<String> buildCreateIndexSQL(
-            String database,
-            String schema,
-            String table,
+            TableReference table,
             FeatureType original,
             FeatureType target
         ) {
@@ -417,7 +408,10 @@
                 sqlbuilder.create_index().if_not_exist();
                 sqlbuilder.create_index().name("idx_" + table + "_" + attrTarget.getName());
                 sqlbuilder.create_index().column(attrTarget.getName());
-                sqlbuilder.create_index().table().database(database).schema(schema).name(table);
+                sqlbuilder.create_index().table()
+                    .database(this.table.getDatabase())
+                    .schema(this.table.getSchema())
+                    .name(this.table.getTable());
                 sqls.addAll(sqlbuilder.create_index().toStrings());
             }
         }
@@ -425,16 +419,14 @@
     }
     
     public void performUpdateTable(Connection conn,
-            String database,
-            String schema,
-            String table,
+            TableReference table,
             FeatureType original,
             FeatureType target) throws DataException {
         
         ArrayList<String> sqls = new ArrayList<>();
         
-        sqls.addAll(buildUpdateTableSQL(database, schema, table, original, target));
-        sqls.addAll(buildCreateIndexSQL(database, schema, table, original, target));
+        sqls.addAll(buildUpdateTableSQL(table, original, target));
+        sqls.addAll(buildCreateIndexSQL(table, original, target));
 
         if( !CollectionUtils.isEmpty(sqls) ) {
             Statement st = null;
Index: trunk/org.gvsig.desktop/org.gvsig.desktop.compat.cdc/org.gvsig.fmap.dal/org.gvsig.fmap.dal.db/org.gvsig.fmap.dal.db.jdbc/src/main/java/org/gvsig/fmap/dal/store/jdbc2/spi/operations/UpdateTableStatisticsOperation.java
===================================================================
--- trunk/org.gvsig.desktop/org.gvsig.desktop.compat.cdc/org.gvsig.fmap.dal/org.gvsig.fmap.dal.db/org.gvsig.fmap.dal.db.jdbc/src/main/java/org/gvsig/fmap/dal/store/jdbc2/spi/operations/UpdateTableStatisticsOperation.java	(revision 44057)
+++ trunk/org.gvsig.desktop/org.gvsig.desktop.compat.cdc/org.gvsig.fmap.dal/org.gvsig.fmap.dal.db/org.gvsig.fmap.dal.db.jdbc/src/main/java/org/gvsig/fmap/dal/store/jdbc2/spi/operations/UpdateTableStatisticsOperation.java	(revision 44058)
@@ -9,47 +9,42 @@
 import org.gvsig.fmap.dal.store.jdbc2.spi.JDBCSQLBuilderBase;
 import org.gvsig.fmap.dal.store.jdbc.exception.JDBCSQLException;
 import org.gvsig.fmap.dal.store.jdbc2.JDBCUtils;
+import org.gvsig.fmap.dal.store.jdbc2.OperationsFactory.TableReference;
 
 public class UpdateTableStatisticsOperation extends AbstractConnectionWritableOperation {
 
-    private final String schemaName;
-    private final String tableName;
-    private final String dbName;
+    private final TableReference table;
 
     public UpdateTableStatisticsOperation(
             JDBCHelper helper
         ) {
-        this(helper, null, null, null);
+        this(helper, null);
     }
 
     public UpdateTableStatisticsOperation(
             JDBCHelper helper,
-            String dbName,
-            String schemaName,
-            String tableName
+            TableReference table
         ) {
         super(helper);
-        this.dbName = dbName;
-        this.schemaName = schemaName;
-        this.tableName = tableName;
+        this.table = table;
     }
 
     @Override
     public final Object perform(Connection conn) throws DataException {
-        this.updateTableStatistics(conn, dbName, schemaName, tableName);
+        this.updateTableStatistics(conn, table);
         return true;
     }
 
     public void updateTableStatistics(
             Connection conn,
-            String database,
-            String schema,
-            String table
+            TableReference table
         ) throws DataException {
 
         JDBCSQLBuilderBase sqlbuilder = this.createSQLBuilder();
-        sqlbuilder.update_table_statistics().table().database(database).schema(schema).name(table);
-
+        sqlbuilder.update_table_statistics().table()
+                .database(this.table.getDatabase())
+                .schema(this.table.getSchema())
+                .name(this.table.getTable());
         List<String> sqls;
         sqls = sqlbuilder.update_table_statistics().toStrings();
 
Index: trunk/org.gvsig.desktop/org.gvsig.desktop.compat.cdc/org.gvsig.fmap.dal/org.gvsig.fmap.dal.db/org.gvsig.fmap.dal.db.jdbc/src/main/java/org/gvsig/fmap/dal/store/jdbc2/spi/operations/AppendOperation.java
===================================================================
--- trunk/org.gvsig.desktop/org.gvsig.desktop.compat.cdc/org.gvsig.fmap.dal/org.gvsig.fmap.dal.db/org.gvsig.fmap.dal.db.jdbc/src/main/java/org/gvsig/fmap/dal/store/jdbc2/spi/operations/AppendOperation.java	(revision 44057)
+++ trunk/org.gvsig.desktop/org.gvsig.desktop.compat.cdc/org.gvsig.fmap.dal/org.gvsig.fmap.dal.db/org.gvsig.fmap.dal.db.jdbc/src/main/java/org/gvsig/fmap/dal/store/jdbc2/spi/operations/AppendOperation.java	(revision 44058)
@@ -13,6 +13,8 @@
 import org.gvsig.fmap.dal.store.jdbc.exception.JDBCPreparingSQLException;
 import org.gvsig.fmap.dal.store.jdbc2.JDBCHelper;
 import org.gvsig.fmap.dal.store.jdbc2.JDBCUtils;
+import org.gvsig.fmap.dal.store.jdbc2.OperationsFactory;
+import org.gvsig.fmap.dal.store.jdbc2.OperationsFactory.TableReference;
 import org.gvsig.fmap.dal.store.jdbc2.spi.JDBCSQLBuilderBase;
 import org.gvsig.tools.dispose.Disposable;
 import org.gvsig.tools.dispose.DisposeUtils;
@@ -22,9 +24,7 @@
 
     protected Connection connection = null;
     protected final JDBCHelper helper;
-    protected final String database;
-    protected final String schema;
-    protected final String table;
+    protected final TableReference table;
     protected final FeatureType type;
     
     protected JDBCSQLBuilderBase sqlbuilder = null;
@@ -33,14 +33,10 @@
     
     public AppendOperation(
             JDBCHelper helper, 
-            String database,
-            String schema, 
-            String table, 
+            TableReference table, 
             FeatureType type
         ) {
         this.helper = helper;
-        this.database = database;
-        this.schema = schema;
         this.table = table;
         this.type = type;
     }
@@ -55,7 +51,11 @@
             
             this.sqlbuilder = this.helper.createSQLBuilder();
 
-            this.sqlbuilder.insert().table().database(this.database).schema(this.schema).name(this.table);
+            this.sqlbuilder.insert().table()
+                    .database(this.table.getDatabase())
+                    .schema(this.table.getSchema())
+                    .name(this.table.getTable()
+            );
             for (FeatureAttributeDescriptor attr : type) {
                 if( attr.isAutomatic() ) {
                     continue;
Index: trunk/org.gvsig.desktop/org.gvsig.desktop.compat.cdc/org.gvsig.fmap.dal/org.gvsig.fmap.dal.db/org.gvsig.fmap.dal.db.jdbc/src/main/java/org/gvsig/fmap/dal/store/jdbc2/spi/operations/FetchFeatureTypeOperation.java
===================================================================
--- trunk/org.gvsig.desktop/org.gvsig.desktop.compat.cdc/org.gvsig.fmap.dal/org.gvsig.fmap.dal.db/org.gvsig.fmap.dal.db.jdbc/src/main/java/org/gvsig/fmap/dal/store/jdbc2/spi/operations/FetchFeatureTypeOperation.java	(revision 44057)
+++ trunk/org.gvsig.desktop/org.gvsig.desktop.compat.cdc/org.gvsig.fmap.dal/org.gvsig.fmap.dal.db/org.gvsig.fmap.dal.db.jdbc/src/main/java/org/gvsig/fmap/dal/store/jdbc2/spi/operations/FetchFeatureTypeOperation.java	(revision 44058)
@@ -18,16 +18,15 @@
 import org.gvsig.fmap.dal.store.jdbc2.spi.JDBCSQLBuilderBase;
 import org.gvsig.fmap.dal.store.jdbc2.JDBCHelper;
 import org.gvsig.fmap.dal.store.jdbc2.JDBCUtils;
-import static org.gvsig.fmap.dal.store.jdbc2.spi.operations.AbstractConnectionOperation.logger;
+import org.gvsig.fmap.dal.store.jdbc2.OperationsFactory.TableReference;
 import org.gvsig.fmap.geom.Geometry;
 import org.gvsig.fmap.geom.GeometryLocator;
 import org.gvsig.fmap.geom.type.GeometryType;
+import static org.gvsig.fmap.dal.store.jdbc2.spi.operations.AbstractConnectionOperation.LOGGER;
 
 public class FetchFeatureTypeOperation extends AbstractConnectionOperation {
     private final EditableFeatureType featureType;
-    private final String dbname;
-    private final String schema;
-    private final String table;
+    private final TableReference table;
     private final List<String> primaryKeys;
     private final String defaultGeometryColumn;
     private final IProjection crs;
@@ -35,7 +34,7 @@
     public FetchFeatureTypeOperation(
             JDBCHelper helper
         ) {
-        this(helper, null, null, null, null, null, null, null);
+        this(helper, null, null, null, null, null);
     }
     
     public FetchFeatureTypeOperation(
@@ -44,23 +43,19 @@
             String defaultGeometryColumn,
             IProjection crs
         ) {
-        this(helper, featureType, null, null, null, null, defaultGeometryColumn, crs);
+        this(helper, featureType, null, null, defaultGeometryColumn, crs);
     }
 
     public FetchFeatureTypeOperation(
             JDBCHelper helper,
             EditableFeatureType featureType,
-            String dbname,
-            String schema,
-            String table,
+            TableReference table,
             List<String> primaryKeys,
             String defaultGeometryColumn,
             IProjection crs
         ) {
         super(helper);
         this.featureType = featureType;
-        this.dbname = dbname;
-        this.schema = schema;
         this.table = table;
         this.primaryKeys = primaryKeys;
         this.defaultGeometryColumn = defaultGeometryColumn;
@@ -69,30 +64,20 @@
     
     @Override
     public final Object perform(Connection conn) throws DataException {
-        this.fetch(featureType, conn, dbname, schema, table, 
+        this.fetch(featureType, conn, table, 
                 primaryKeys, defaultGeometryColumn, crs
         );
         return true;
     }
     
-    protected String getDatabase() {
-        return this.dbname;
-    }
-    
-    protected String getSchema() {
-        return this.schema;
-    }
-    
-    protected String getTablename() {
+    protected TableReference getTable() {
         return this.table;
     }
     
     public void fetch(
             EditableFeatureType featureType,
             Connection conn,
-            String database,
-            String schema,
-            String table,
+            TableReference table,
             List<String> pks,
             String defaultGeometryColumn,
             IProjection crs
@@ -102,17 +87,21 @@
         ResultSet rs = null;
         try {
             if (CollectionUtils.isEmpty(pks)) {
-                if (!StringUtils.isEmpty(table)) {
-                    pks = this.getPrimaryKeysFromMetadata(conn, null, schema, table);
+                if (!table.hasSubquery()) {
+                    pks = this.getPrimaryKeysFromMetadata(conn, null, table.getSchema(), table.getTable());
                     if (CollectionUtils.isEmpty(pks)) {
-                        pks = getPrimaryKeysFromInformationSchema(conn, null, schema, table);
+                        pks = getPrimaryKeysFromInformationSchema(conn, null, table.getSchema(), table.getTable());
                     }
                 }
             }
 
             JDBCSQLBuilderBase sqlbuilder = this.createSQLBuilder();
             sqlbuilder.select().column().all();
-            sqlbuilder.select().from().table().database(database).schema(schema).name(table);
+            sqlbuilder.select().from().table()
+                .database(this.table.getDatabase())
+                .schema(this.table.getSchema())
+                .name(this.table.getTable());
+            sqlbuilder.select().from().subquery(this.table.getSubquery());
             sqlbuilder.select().limit(1);
 
             st = conn.createStatement();
@@ -236,6 +225,36 @@
             String schema,
             String table) throws SQLException {
 
+        String sql = getSQLToRetrievePrimaryKeysFromInformationSchema(catalog, schema, table);
+
+        Statement st = null;
+        ResultSet rs = null;
+        List<String> pks = new ArrayList();
+        try {
+            st = conn.createStatement();
+            rs = JDBCUtils.executeQuery(st, sql);
+            while (rs.next()) {
+                pks.add(rs.getString(1));
+            }
+            if (pks.isEmpty()) {
+                return null;
+            }
+            return pks;
+
+        } catch (Exception ex) {
+            return pks;
+            
+        } finally {
+            JDBCUtils.closeQuietly(rs);
+            JDBCUtils.closeQuietly(st);
+        }
+    }
+
+    protected String getSQLToRetrievePrimaryKeysFromInformationSchema(
+            String catalog,
+            String schema,
+            String table
+        ) throws SQLException {
         JDBCSQLBuilderBase sqlbuilder = this.createSQLBuilder();
 
         sqlbuilder.select().column().name("COLUMN_NAME");
@@ -276,30 +295,10 @@
                         sqlbuilder.constant("PRIMARY KEY")
                 )
         );
-
-        Statement st = null;
-        ResultSet rs = null;
-        List<String> pks = new ArrayList();
-        try {
-            st = conn.createStatement();
-            rs = JDBCUtils.executeQuery(st, sqlbuilder.toString());
-            while (rs.next()) {
-                pks.add(rs.getString(1));
-            }
-            if (pks.isEmpty()) {
-                return null;
-            }
-            return pks;
-
-        } catch (Exception ex) {
-            return pks;
-            
-        } finally {
-            JDBCUtils.closeQuietly(rs);
-            JDBCUtils.closeQuietly(st);
-        }
+        return sqlbuilder.toString();
     }
-
+    
+    
     protected EditableFeatureAttributeDescriptor getAttributeFromMetadata(
             EditableFeatureType type,
             Connection conn,
@@ -420,7 +419,7 @@
             attr.setGeometryType(geomType);
             attr.setSRS(null);
         } catch (Exception ex) {
-            logger.warn("Can't get default geometry type.",ex);
+            LOGGER.warn("Can't get default geometry type.",ex);
         }
     }
     
Index: trunk/org.gvsig.desktop/org.gvsig.desktop.compat.cdc/org.gvsig.fmap.dal/org.gvsig.fmap.dal.db/org.gvsig.fmap.dal.db.jdbc/src/main/java/org/gvsig/fmap/dal/store/jdbc2/spi/JDBCServerExplorerBase.java
===================================================================
--- trunk/org.gvsig.desktop/org.gvsig.desktop.compat.cdc/org.gvsig.fmap.dal/org.gvsig.fmap.dal.db/org.gvsig.fmap.dal.db.jdbc/src/main/java/org/gvsig/fmap/dal/store/jdbc2/spi/JDBCServerExplorerBase.java	(revision 44057)
+++ trunk/org.gvsig.desktop/org.gvsig.desktop.compat.cdc/org.gvsig.fmap.dal/org.gvsig.fmap.dal.db/org.gvsig.fmap.dal.db.jdbc/src/main/java/org/gvsig/fmap/dal/store/jdbc2/spi/JDBCServerExplorerBase.java	(revision 44058)
@@ -149,9 +149,7 @@
 
         JDBCStoreParameters params = (JDBCStoreParameters) theParams;
         DropTableOperation removeTable = this.getOperations().createDropTable(
-                params.getDBName(), 
-                params.getSchema(), 
-                params.getTable()
+                this.getOperations().createTableReference(params)
         );
         removeTable.perform();
     }
@@ -258,8 +256,8 @@
     @Override
     public boolean canAdd() {
         if (this.canAdd == null) {
-            CanCreateTablesOperation canAdd = this.getOperations().createCanCreateTables();
-            this.canAdd = (Boolean) canAdd.perform();
+            CanCreateTablesOperation canAdd_ = this.getOperations().createCanCreateTables();
+            this.canAdd = (Boolean) canAdd_.perform();
         }
         return this.canAdd;
     }
@@ -282,9 +280,7 @@
         
         FetchFeatureTypeOperation fetch = this.getOperations().createFetchFeatureType(
                 fetureType, 
-                params.getDBName(), 
-                params.getSchema(), 
-                params.getTable(), 
+                this.getOperations().createTableReference(params),
                 primaryKeys,
                 params.getDefaultGeometryField(),
                 params.getCRS()
@@ -339,14 +335,12 @@
                     new ImmutablePair<>(params.getUpdateRole(), Privilege.UPDATE )
             );
         }
-        List<String> additionalSQLs =  new ArrayList<>();;
+        List<String> additionalSQLs =  new ArrayList<>();
         if( !StringUtils.isEmpty(params.getPostCreatingStatement()) ) {
             additionalSQLs.add(params.getPostCreatingStatement());
         }
         CreateTableOperation createTable = this.getOperations().createTable(
-                params.getDBName(), 
-                params.getSchema(),
-                params.getTable(),
+                this.getOperations().createTableReference(params),
                 params.getDefaultFeatureType(),
                 userAndPrivileges, 
                 additionalSQLs
@@ -363,11 +357,8 @@
 
     @Override
     public void updateTableStatistics(String database, String schema, String table) throws JDBCExecuteSQLException {
-        JDBCServerExplorerParameters params = this.getParameters();
         UpdateTableStatisticsOperation updateStatistics = this.getOperations().createUpdateTableStatistics(
-                database, 
-                schema, 
-                table
+                this.getOperations().createTableReference(database, schema, table, null)
         );
         updateStatistics.perform();
     }
Index: trunk/org.gvsig.desktop/org.gvsig.desktop.compat.cdc/org.gvsig.fmap.dal/org.gvsig.fmap.dal.db/org.gvsig.fmap.dal.db.jdbc/src/main/java/org/gvsig/fmap/dal/store/jdbc2/spi/JDBCStoreProviderBase.java
===================================================================
--- trunk/org.gvsig.desktop/org.gvsig.desktop.compat.cdc/org.gvsig.fmap.dal/org.gvsig.fmap.dal.db/org.gvsig.fmap.dal.db.jdbc/src/main/java/org/gvsig/fmap/dal/store/jdbc2/spi/JDBCStoreProviderBase.java	(revision 44057)
+++ trunk/org.gvsig.desktop/org.gvsig.desktop.compat.cdc/org.gvsig.fmap.dal/org.gvsig.fmap.dal.db/org.gvsig.fmap.dal.db.jdbc/src/main/java/org/gvsig/fmap/dal/store/jdbc2/spi/JDBCStoreProviderBase.java	(revision 44058)
@@ -6,7 +6,6 @@
 import java.util.Collections;
 import java.util.Iterator;
 import java.util.List;
-import java.util.logging.Level;
 import org.apache.commons.lang3.BooleanUtils;
 import org.apache.commons.lang3.StringUtils;
 import org.cresques.cts.IProjection;
@@ -23,7 +22,6 @@
 import org.gvsig.fmap.dal.exception.ReadException;
 import org.gvsig.fmap.dal.feature.EditableFeatureAttributeDescriptor;
 import org.gvsig.fmap.dal.feature.EditableFeatureType;
-import org.gvsig.fmap.dal.feature.FeatureAttributeDescriptor;
 import org.gvsig.fmap.dal.feature.FeatureQuery;
 import org.gvsig.fmap.dal.feature.FeatureRule;
 import org.gvsig.fmap.dal.feature.FeatureRules;
@@ -39,7 +37,6 @@
 import org.gvsig.fmap.dal.resource.spi.ResourceConsumer;
 import org.gvsig.fmap.dal.resource.spi.ResourceProvider;
 import org.gvsig.fmap.dal.spi.DataStoreProviderServices;
-//import org.gvsig.fmap.dal.store.jdbc2.JDBCServerExplorerBase;
 import org.gvsig.fmap.dal.store.jdbc.JDBCServerExplorerParameters;
 import org.gvsig.fmap.dal.store.jdbc.JDBCStoreParameters;
 import org.gvsig.fmap.dal.store.jdbc2.JDBCHelper;
@@ -62,11 +59,12 @@
 import org.slf4j.Logger;
 import org.slf4j.LoggerFactory;
 
+@SuppressWarnings("UseSpecificCatch")
 public class JDBCStoreProviderBase
         extends AbstractFeatureStoreProvider
         implements ResourceConsumer, JDBCStoreProvider {
 
-    final static private Logger logger = LoggerFactory.getLogger(JDBCStoreProviderBase.class);
+    final static private Logger LOGGER = LoggerFactory.getLogger(JDBCStoreProviderBase.class);
 
     public class CountValue implements CalculatedValue<Long> {
         
@@ -76,10 +74,7 @@
         public void calculate() {
             JDBCStoreParameters params = getParameters();
             CountOperation count = getOperations().createCount(
-                    params.getDBName(),
-                    params.getSchema(),
-                    params.getTable(),
-                    params.getSQL(),
+                    getOperations().createTableReference(params),
                     params.getBaseFilter(), 
                     null
             );
@@ -121,10 +116,7 @@
                 JDBCStoreParameters params = getParameters();
                 CalculateEnvelopeOfColumnOperation calculateEnvelopeOfColumn = 
                     getOperations().createCalculateEnvelopeOfColumn(
-                        params.getSQL(), 
-                        params.getDBName(),
-                        params.getSchema(), 
-                        params.getTable(), 
+                        getOperations().createTableReference(params),
                         columnName, 
                         params.getBaseFilter(), 
                         params.getWorkingArea(), 
@@ -164,9 +156,7 @@
                 JDBCStoreParameters params = getParameters();
                 CanModifyTableOperation canModifyTable = 
                     getOperations().createCanModifyTableOperation(
-                        params.getDBName(),
-                        params.getSchema(), 
-                        params.getTable()
+                        getOperations().createTableReference(params)
                     );
                 this.value = (boolean) canModifyTable.perform();
             } catch(Exception ex) {
@@ -198,6 +188,7 @@
 
     protected AppendOperation appendOperation = null;
     
+    @SuppressWarnings({"OverridableMethodCallInConstructor", "CallToThreadStartDuringObjectConstruction"})
     protected JDBCStoreProviderBase(
             JDBCStoreParameters params,
             DataStoreProviderServices storeServices,
@@ -214,7 +205,7 @@
                     Thread thread = new Thread(new Runnable() {
                         @Override
                         public void run() {
-                            logger.debug("Precalculating envelope of '"+getSourceId()+"'.");
+                            LOGGER.debug("Precalculating envelope of '"+getSourceId()+"'.");
                             getEnvelopeValue().get();
                         }
                     }, "PrecalculateEnvelopeOfDBTable");
@@ -223,7 +214,7 @@
                 }
            }
         } catch(Exception ex) {
-            logger.warn("Probems precalculating the envelope of table '"+this.getSourceId()+"'.", ex);
+            LOGGER.warn("Probems precalculating the envelope of table '"+this.getSourceId()+"'.", ex);
         }
     }
 
@@ -425,7 +416,7 @@
             try {
                 r = new DummyResource(this.getName());
             } catch (InitializeException ex) {
-                logger.warn("Can't create DummyResource",ex);
+                LOGGER.warn("Can't create DummyResource",ex);
                 // Do nothing
             }
         }
@@ -463,9 +454,7 @@
         FetchFeatureTypeOperation fetchFeatureType = 
              this.getOperations().createFetchFeatureType(
                 type,
-                params.getDBName(),
-                params.getSchema(),
-                params.getTable(),
+                this.getOperations().createTableReference(params),
                 primaryKeys,
                 params.getDefaultGeometryField(),
                 params.getCRS()
@@ -494,9 +483,7 @@
             this.getOperations().createFetchFeatureProviderByReference(
                 reference, 
                 featureType, 
-                params.getDBName(),
-                params.getSchema(), 
-                params.getTable()
+                this.getOperations().createTableReference(params)
             );
         FeatureProvider feature = (FeatureProvider) fetchFeatureProviderByReference.perform();
         return feature;
@@ -515,9 +502,7 @@
         FeatureType type = this.getFeatureStore().getDefaultFeatureType();
         JDBCStoreParameters params = this.getParameters();
         PerformChangesOperation performChanges = this.getOperations().createPerformChanges(
-                params.getDBName(),
-                params.getSchema(), 
-                params.getTable(), 
+                this.getOperations().createTableReference(params),
                 type, 
                 deleteds, 
                 inserteds, 
@@ -554,9 +539,7 @@
             FeatureType type = this.getFeatureStore().getDefaultFeatureType();
             JDBCStoreParameters params = this.getParameters();
             this.appendOperation = this.getOperations().createAppend(
-                params.getDBName(),
-                params.getSchema(), 
-                params.getTable(), 
+                this.getOperations().createTableReference(params),
                 type 
             );
         }
Index: trunk/org.gvsig.desktop/org.gvsig.desktop.compat.cdc/org.gvsig.fmap.dal/org.gvsig.fmap.dal.db/org.gvsig.fmap.dal.db.jdbc/src/main/java/org/gvsig/fmap/dal/store/jdbc2/impl/JDBCSetProvider.java
===================================================================
--- trunk/org.gvsig.desktop/org.gvsig.desktop.compat.cdc/org.gvsig.fmap.dal/org.gvsig.fmap.dal.db/org.gvsig.fmap.dal.db.jdbc/src/main/java/org/gvsig/fmap/dal/store/jdbc2/impl/JDBCSetProvider.java	(revision 44057)
+++ trunk/org.gvsig.desktop/org.gvsig.desktop.compat.cdc/org.gvsig.fmap.dal/org.gvsig.fmap.dal.db/org.gvsig.fmap.dal.db.jdbc/src/main/java/org/gvsig/fmap/dal/store/jdbc2/impl/JDBCSetProvider.java	(revision 44058)
@@ -55,7 +55,7 @@
 
 public class JDBCSetProvider extends AbstractFeatureSetProvider {
 
-    final static protected Logger logger = LoggerFactory.getLogger(JDBCSetProvider.class);
+    final static protected Logger LOGGER = LoggerFactory.getLogger(JDBCSetProvider.class);
 
     private class EmptyJDBCIterator extends JDBCIterator {
 
@@ -248,10 +248,7 @@
                 filtersql = filter.getSQL();
             }
             CountOperation selectCount = this.getOperations().createCount(
-                    params.getDBName(),
-                    params.getSchema(),
-                    params.getTable(),
-                    params.getSQL(),
+                    this.getOperations().createTableReference(params),
                     params.getBaseFilter(), 
                     filtersql
             );
@@ -270,15 +267,12 @@
                 if( filter != null ) {
                     filtersql = filter.getSQL();
                 }
-                TableIsEmptyOperation isEmpty = this.getOperations().createTableIsEmpty(
-                        params.getDBName(),
-                        params.getSchema(),
-                        params.getTable(),
-                        params.getSQL(),
+                TableIsEmptyOperation isEmpty_ = this.getOperations().createTableIsEmpty(
+                        this.getOperations().createTableReference(params),
                         params.getBaseFilter(), 
                         filtersql
                 );
-                this.isEmpty = (Boolean) isEmpty.perform();   
+                this.isEmpty = (Boolean) isEmpty_.perform();   
             } else {
                 this.isEmpty = (this.size < 1);
             }
@@ -303,10 +297,7 @@
 		.getProviderFeatureType(this.getFeatureType().getId());
         ResultSetForSetProviderOperation createResultSet 
             = getOperations().createResultSetForSetProvider(
-                    params.getDBName(),
-                    params.getSchema(), 
-                    params.getTable(), 
-                    params.getSQL(), 
+                    this.getOperations().createTableReference(params),
                     params.getBaseFilter(), 
                     params.getBaseOrder(), 
                     this.getQuery(), 
@@ -344,10 +335,7 @@
 		.getProviderFeatureType(this.getFeatureType().getId());
         ResultSetForSetProviderOperation createResultSet 
             = getOperations().createResultSetForSetProvider(
-                    params.getDBName(),
-                    params.getSchema(), 
-                    params.getTable(), 
-                    params.getSQL(), 
+                    this.getOperations().createTableReference(params),
                     params.getBaseFilter(), 
                     params.getBaseOrder(), 
                     this.getQuery(), 
Index: trunk/org.gvsig.desktop/org.gvsig.desktop.compat.cdc/org.gvsig.fmap.dal/org.gvsig.fmap.dal.db/org.gvsig.fmap.dal.db.h2/src/main/java/org/gvsig/fmap/dal/store/h2/operations/H2SpatialAppendOperation.java
===================================================================
--- trunk/org.gvsig.desktop/org.gvsig.desktop.compat.cdc/org.gvsig.fmap.dal/org.gvsig.fmap.dal.db/org.gvsig.fmap.dal.db.h2/src/main/java/org/gvsig/fmap/dal/store/h2/operations/H2SpatialAppendOperation.java	(revision 44057)
+++ trunk/org.gvsig.desktop/org.gvsig.desktop.compat.cdc/org.gvsig.fmap.dal/org.gvsig.fmap.dal.db/org.gvsig.fmap.dal.db.h2/src/main/java/org/gvsig/fmap/dal/store/h2/operations/H2SpatialAppendOperation.java	(revision 44058)
@@ -12,21 +12,21 @@
 import org.gvsig.fmap.dal.store.jdbc.exception.JDBCPreparingSQLException;
 import org.gvsig.fmap.dal.store.jdbc2.JDBCHelper;
 import org.gvsig.fmap.dal.store.jdbc2.JDBCUtils;
+import org.gvsig.fmap.dal.store.jdbc2.OperationsFactory.TableReference;
 import org.gvsig.fmap.dal.store.jdbc2.spi.operations.AppendOperation;
 import org.gvsig.tools.dispose.Disposable;
 import org.gvsig.tools.dispose.DisposeUtils;
 
 
+@SuppressWarnings("UseSpecificCatch")
 public class H2SpatialAppendOperation extends AppendOperation {
     
     public H2SpatialAppendOperation(
             JDBCHelper helper, 
-            String database,
-            String schema, 
-            String table, 
+            TableReference table, 
             FeatureType type
         ) {
-        super(helper, database, schema, table, type);
+        super(helper, table, type);
     }
     
     @Override
@@ -40,7 +40,10 @@
             
             this.sqlbuilder = this.helper.createSQLBuilder();
 
-            this.sqlbuilder.insert().table().database(this.database).schema(this.schema).name(this.table);
+            this.sqlbuilder.insert().table()
+                .database(this.table.getDatabase())
+                .schema(this.table.getSchema())
+                .name(this.table.getTable());
             for (FeatureAttributeDescriptor attr : type) {
                 if( attr.isAutomatic() ) {
                     continue;
Index: trunk/org.gvsig.desktop/org.gvsig.desktop.compat.cdc/org.gvsig.fmap.dal/org.gvsig.fmap.dal.db/org.gvsig.fmap.dal.db.h2/src/main/java/org/gvsig/fmap/dal/store/h2/operations/H2SpatialFetchFeatureTypeOperation.java
===================================================================
--- trunk/org.gvsig.desktop/org.gvsig.desktop.compat.cdc/org.gvsig.fmap.dal/org.gvsig.fmap.dal.db/org.gvsig.fmap.dal.db.h2/src/main/java/org/gvsig/fmap/dal/store/h2/operations/H2SpatialFetchFeatureTypeOperation.java	(revision 44057)
+++ trunk/org.gvsig.desktop/org.gvsig.desktop.compat.cdc/org.gvsig.fmap.dal/org.gvsig.fmap.dal.db/org.gvsig.fmap.dal.db.h2/src/main/java/org/gvsig/fmap/dal/store/h2/operations/H2SpatialFetchFeatureTypeOperation.java	(revision 44058)
@@ -9,7 +9,6 @@
 import java.util.HashMap;
 import java.util.List;
 import java.util.Map;
-import org.apache.commons.lang3.StringUtils;
 import org.cresques.cts.IProjection;
 import org.gvsig.fmap.dal.DataTypes;
 import org.gvsig.fmap.dal.exception.DataException;
@@ -17,6 +16,7 @@
 import org.gvsig.fmap.dal.feature.EditableFeatureType;
 import org.gvsig.fmap.dal.store.jdbc2.JDBCHelper;
 import org.gvsig.fmap.dal.store.jdbc2.JDBCUtils;
+import org.gvsig.fmap.dal.store.jdbc2.OperationsFactory.TableReference;
 import org.gvsig.fmap.dal.store.jdbc2.spi.SRSSolver;
 import org.gvsig.fmap.dal.store.jdbc2.spi.operations.FetchFeatureTypeOperation;
 import org.gvsig.fmap.geom.Geometry;
@@ -24,6 +24,7 @@
 import org.gvsig.fmap.geom.GeometryManager;
 import org.gvsig.fmap.geom.type.GeometryType;
 
+@SuppressWarnings("UseSpecificCatch")
 public class H2SpatialFetchFeatureTypeOperation extends FetchFeatureTypeOperation {
 
     private static Map<String,GeometryType>h2spatialGeometryTypes = null;
@@ -68,52 +69,50 @@
     public H2SpatialFetchFeatureTypeOperation(
             JDBCHelper helper,
             EditableFeatureType featureType,
-            String dbname,
-            String schema,
-            String table,
+            TableReference table,
             List<String> primaryKeys,
             String defaultGeometryColumn,
             IProjection crs
         ) {
-        super(helper, featureType, dbname, schema, table, primaryKeys, defaultGeometryColumn, crs);
+        super(helper, featureType, table, primaryKeys, defaultGeometryColumn, crs);
     }            
 
     @Override
-    public void fetch(EditableFeatureType featureType, Connection conn, String dbname, String schema, String table, List<String> pks, String defaultGeometryColumn, IProjection crs) throws DataException {
+    public void fetch(EditableFeatureType featureType, Connection conn, TableReference table, List<String> pks, String defaultGeometryColumn, IProjection crs) throws DataException {
         geometry_column = new HashMap<>();
         try {
             //
             // https://github.com/orbisgis/h2gis/wiki/1.-Spatial-data#geometry-columns-view
             //
             StringBuilder where = null;
-            if( !StringUtils.isEmpty(dbname) ) {
+            if( table.hasDatabase() ) {
                 if( where == null ) {
                     where = new StringBuilder();
                 } else {
                     where.append(" AND ");
                 }
                 where.append("UPPER(F_TABLE_CATALOG) = '");
-                where.append(dbname.toUpperCase());
+                where.append(table.getDatabase().toUpperCase());
                 where.append("'");
             }
-            if( !StringUtils.isEmpty(schema) ) {
+            if( table.hasSchema()) {
                 if( where == null ) {
                     where = new StringBuilder();
                 } else {
                     where.append(" AND ");
                 }
                 where.append("UPPER(F_TABLE_SCHEMA) = '");
-                where.append(schema.toUpperCase());
+                where.append(table.getSchema().toUpperCase());
                 where.append("'");
             }
-            if( !StringUtils.isEmpty(table) ) {
+            if( table.hasTable()) {
                 if( where == null ) {
                     where = new StringBuilder();
                 } else {
                     where.append(" AND ");
                 }
                 where.append("UPPER(F_TABLE_NAME) = '");
-                where.append(table.toUpperCase());
+                where.append(table.getTable().toUpperCase());
                 where.append("'");
             }            
             String sql = "SELECT F_GEOMETRY_COLUMN, GEOMETRY_TYPE, COORD_DIMENSION, SRID, TYPE FROM GEOMETRY_COLUMNS WHERE " + where;
@@ -132,9 +131,9 @@
                 );
             }
         } catch (SQLException ex) {
-            logger.warn("Can't read metadata from table '"+table+"'.",ex);
+            LOGGER.warn("Can't read metadata from table '"+table+"'.",ex);
         }
-        super.fetch(featureType, conn, dbname, schema, table, pks, defaultGeometryColumn, crs);
+        super.fetch(featureType, conn, table, pks, defaultGeometryColumn, crs);
     }
         
     @Override
Index: trunk/org.gvsig.desktop/org.gvsig.desktop.compat.cdc/org.gvsig.fmap.dal/org.gvsig.fmap.dal.db/org.gvsig.fmap.dal.db.h2/src/main/java/org/gvsig/fmap/dal/store/h2/operations/H2SpatialOperationsFactory.java
===================================================================
--- trunk/org.gvsig.desktop/org.gvsig.desktop.compat.cdc/org.gvsig.fmap.dal/org.gvsig.fmap.dal.db/org.gvsig.fmap.dal.db.h2/src/main/java/org/gvsig/fmap/dal/store/h2/operations/H2SpatialOperationsFactory.java	(revision 44057)
+++ trunk/org.gvsig.desktop/org.gvsig.desktop.compat.cdc/org.gvsig.fmap.dal/org.gvsig.fmap.dal.db/org.gvsig.fmap.dal.db.h2/src/main/java/org/gvsig/fmap/dal/store/h2/operations/H2SpatialOperationsFactory.java	(revision 44058)
@@ -20,9 +20,9 @@
     }
 
     @Override
-    public FetchFeatureTypeOperation createFetchFeatureType(EditableFeatureType type, String database, String schema, String table, List<String> primaryKeys, String defaultGeometryField, IProjection crs) {
+    public FetchFeatureTypeOperation createFetchFeatureType(EditableFeatureType type, TableReference table, List<String> primaryKeys, String defaultGeometryField, IProjection crs) {
         return new H2SpatialFetchFeatureTypeOperation(
-                helper, type, database, schema, table, primaryKeys, 
+                helper, type, table, primaryKeys, 
                 defaultGeometryField, crs
         );
     }  
@@ -33,8 +33,8 @@
     }
 
     @Override
-    public AppendOperation createAppend(String database, String schema, String table, FeatureType type) {
-        return new H2SpatialAppendOperation(helper, database, schema, table, type);
+    public AppendOperation createAppend(TableReference table, FeatureType type) {
+        return new H2SpatialAppendOperation(helper, table, type);
     }
     
     
Index: trunk/org.gvsig.desktop/org.gvsig.desktop.compat.cdc/org.gvsig.fmap.dal/org.gvsig.fmap.dal.api/src/main/java/org/gvsig/fmap/dal/SQLBuilder.java
===================================================================
--- trunk/org.gvsig.desktop/org.gvsig.desktop.compat.cdc/org.gvsig.fmap.dal/org.gvsig.fmap.dal.api/src/main/java/org/gvsig/fmap/dal/SQLBuilder.java	(revision 44057)
+++ trunk/org.gvsig.desktop/org.gvsig.desktop.compat.cdc/org.gvsig.fmap.dal/org.gvsig.fmap.dal.api/src/main/java/org/gvsig/fmap/dal/SQLBuilder.java	(revision 44058)
@@ -204,6 +204,7 @@
         public OrderByBuilder order_by();
         public SelectBuilder distinct();
         public SelectBuilder limit(long limit);
+        public SelectBuilder limit(Long limit);
         
         /**
          * Specifies an offset to be applied to the SQL statement.
Index: trunk/org.gvsig.desktop/org.gvsig.desktop.compat.cdc/org.gvsig.fmap.dal/org.gvsig.fmap.dal.spi/src/main/java/org/gvsig/fmap/dal/feature/spi/SQLBuilderBase.java
===================================================================
--- trunk/org.gvsig.desktop/org.gvsig.desktop.compat.cdc/org.gvsig.fmap.dal/org.gvsig.fmap.dal.spi/src/main/java/org/gvsig/fmap/dal/feature/spi/SQLBuilderBase.java	(revision 44057)
+++ trunk/org.gvsig.desktop/org.gvsig.desktop.compat.cdc/org.gvsig.fmap.dal/org.gvsig.fmap.dal.spi/src/main/java/org/gvsig/fmap/dal/feature/spi/SQLBuilderBase.java	(revision 44058)
@@ -1313,6 +1313,16 @@
         }
 
         @Override
+        public SelectBuilder limit(Long limit) {
+            if( limit == null ) {
+                this.limit = 0;
+            } else {
+                this.limit = limit;
+            }
+            return this;
+        }
+
+        @Override
         public boolean has_limit() {
             return this.limit > 0;
         }
