Revision 43358 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
ResultSetForSetProviderOperation.java | ||
---|---|---|
3 | 3 |
import java.sql.Connection; |
4 | 4 |
import java.util.ArrayList; |
5 | 5 |
import java.util.List; |
6 |
import org.apache.commons.lang3.ArrayUtils; |
|
6 | 7 |
import org.apache.commons.lang3.StringUtils; |
7 | 8 |
import org.gvsig.fmap.dal.ExpressionBuilder.Config; |
8 | 9 |
import org.gvsig.fmap.dal.exception.DataException; |
... | ... | |
84 | 85 |
long offset, |
85 | 86 |
int fetchSize |
86 | 87 |
) throws DataException { |
88 |
List<FeatureAttributeDescriptor> columns = new ArrayList<>(); |
|
87 | 89 |
|
88 | 90 |
double tolerance = -1 ; //query.getScale(); |
89 | 91 |
JDBCSQLBuilderBase sqlbuilder = createSQLBuilder(); |
... | ... | |
96 | 98 |
// Ordenamos siempre por las claves primarias para garantizar |
97 | 99 |
// un orden predecible. Ademas se precisa indicar un orden para |
98 | 100 |
// usar OFFSET. |
99 |
sqlbuilder.select().order_by().column(sqlbuilder.identifier(attrName)); |
|
101 |
sqlbuilder.select().order_by().column(sqlbuilder.identifier(attrName)).ascending();
|
|
100 | 102 |
} |
103 |
String[] constantsAttributeNames = null; |
|
104 |
if(query !=null && query.hasConstantsAttributeNames() ) { |
|
105 |
constantsAttributeNames = query.getConstantsAttributeNames(); |
|
106 |
} |
|
101 | 107 |
for(FeatureAttributeDescriptor attr : setType ) { |
108 |
if( ArrayUtils.contains(constantsAttributeNames, attr.getName()) ) { |
|
109 |
continue; |
|
110 |
} |
|
102 | 111 |
if( attr.isPrimaryKey() ) { |
103 | 112 |
primaryKeys.remove(attr.getName()); |
104 | 113 |
} |
... | ... | |
113 | 122 |
) |
114 | 123 |
).as_geometry(); |
115 | 124 |
} |
125 |
columns.add(attr); |
|
116 | 126 |
} else { |
117 | 127 |
sqlbuilder.select().column().name(attr.getName()); |
128 |
columns.add(attr); |
|
118 | 129 |
} |
119 | 130 |
} |
120 | 131 |
for(String attrName : primaryKeys ) { |
121 | 132 |
sqlbuilder.select().column().name(attrName); |
133 |
columns.add(setType.getAttributeDescriptor(attrName)); |
|
122 | 134 |
} |
123 | 135 |
|
124 | 136 |
if( StringUtils.isEmpty(subquery) ) { |
... | ... | |
170 | 182 |
|
171 | 183 |
String sql = sqlbuilder.toString(); |
172 | 184 |
ResultSetEntry resultSetEntry = this.helper.getResulSetControler().create( |
173 |
sql, fetchSize |
|
185 |
sql, fetchSize, columns.toArray(new FeatureAttributeDescriptor[columns.size()])
|
|
174 | 186 |
); |
175 | 187 |
return resultSetEntry; |
176 | 188 |
} |
Also available in: Unified diff