You are viewing a plain text version of this content. The canonical link for it is here.
Posted to jaxme-dev@ws.apache.org by jo...@apache.org on 2004/12/20 12:08:17 UTC
cvs commit: ws-jaxme/src/js/org/apache/ws/jaxme/sqls/impl SelectStatementImpl.java SQLGeneratorImpl.java
jochen 2004/12/20 03:08:17
Modified: src/js/org/apache/ws/jaxme/sqls/oracle
OraSQLGeneratorImpl.java
OraSelectStatementImpl.java OraSelectStatement.java
src/js/org/apache/ws/jaxme/sqls/impl
SelectStatementImpl.java SQLGeneratorImpl.java
Log:
Added support for Oracles NULLS FIRST clause in ORDER BY
Revision Changes Path
1.13 +14 -0 ws-jaxme/src/js/org/apache/ws/jaxme/sqls/oracle/OraSQLGeneratorImpl.java
Index: OraSQLGeneratorImpl.java
===================================================================
RCS file: /home/cvs/ws-jaxme/src/js/org/apache/ws/jaxme/sqls/oracle/OraSQLGeneratorImpl.java,v
retrieving revision 1.12
retrieving revision 1.13
diff -u -r1.12 -r1.13
--- OraSQLGeneratorImpl.java 7 Oct 2004 20:42:27 -0000 1.12
+++ OraSQLGeneratorImpl.java 20 Dec 2004 11:08:16 -0000 1.13
@@ -27,6 +27,9 @@
import org.apache.ws.jaxme.sqls.impl.StatementMetaData;
+/** Oracle specific extension of
+ * {@link org.apache.ws.jaxme.sqls.impl.SQLGeneratorImpl}.
+ */
public class OraSQLGeneratorImpl extends SQLGeneratorImpl implements OraSQLGenerator {
private boolean isOracle8Compatibility;
@@ -149,6 +152,17 @@
OraJoinReferenceImpl oraJoin = (OraJoinReferenceImpl) pColumn.getTableReference();
if (oraJoin.isOracle8LeftOuterJoin()) {
return s + "(+)";
+ }
+ }
+ return s;
+ }
+
+ protected String getOrderColumn(StatementMetaData pData, SelectStatement.OrderColumn pColumn) {
+ String s = super.getOrderColumn(pData, pColumn);
+ if (pColumn instanceof OraSelectStatement.OraOrderColumn) {
+ OraSelectStatement.OraOrderColumn ooc = (OraSelectStatement.OraOrderColumn) pColumn;
+ if (ooc.isNullsFirst()) {
+ s += " NULLS FIRST";
}
}
return s;
1.2 +30 -1 ws-jaxme/src/js/org/apache/ws/jaxme/sqls/oracle/OraSelectStatementImpl.java
Index: OraSelectStatementImpl.java
===================================================================
RCS file: /home/cvs/ws-jaxme/src/js/org/apache/ws/jaxme/sqls/oracle/OraSelectStatementImpl.java,v
retrieving revision 1.1
retrieving revision 1.2
diff -u -r1.1 -r1.2
--- OraSelectStatementImpl.java 11 Mar 2004 11:03:12 -0000 1.1
+++ OraSelectStatementImpl.java 20 Dec 2004 11:08:16 -0000 1.2
@@ -26,9 +26,30 @@
* @author <a href="mailto:joe@ispsoft.de">Jochen Wiedmann</a>
*/
public class OraSelectStatementImpl extends SelectStatementImpl
- implements OraSelectStatement {
+ implements OraSelectStatement {
+ /** Default implementation of
+ * {@link OraSelectStatement.OraOrderColumn}.
+ */
+ public static class OraOrderColumnImpl extends OrderColumnImpl
+ implements OraOrderColumn {
+ private final boolean nullsFirst;
+ /** Creates a new instance with the given values for
+ * {@link org.apache.ws.jaxme.sqls.SelectStatement.OrderColumn#getColumn()},
+ * {@link org.apache.ws.jaxme.sqls.SelectStatement.OrderColumn#isDescending()},
+ * and
+ * {@link OraSelectStatement.OraOrderColumn#isNullsFirst()}.
+ */
+ public OraOrderColumnImpl(Object pObject, boolean pDescending,
+ boolean pNullsFirst) {
+ super(pObject, pDescending);
+ nullsFirst = pNullsFirst;
+ }
+ public boolean isNullsFirst() { return nullsFirst; }
+ }
private CombinedConstraint startWith, connectByPrior;
+ /** Creates a new instance with the given object factory.
+ */
public OraSelectStatementImpl(SQLFactory pFactory) {
super(pFactory);
}
@@ -48,4 +69,12 @@
}
return connectByPrior;
}
+
+ /* (non-Javadoc)
+ * @see org.apache.ws.jaxme.sqls.oracle.OraSelectStatement#addOrderColumn(java.lang.Object, boolean, boolean)
+ */
+ public void addOrderColumn(Object pObject, boolean pDescending, boolean pNullsFirst) {
+ OraOrderColumn ooc = new OraOrderColumnImpl(pObject, pDescending, pNullsFirst);
+ super.addOrderColumn(ooc);
+ }
}
1.2 +21 -4 ws-jaxme/src/js/org/apache/ws/jaxme/sqls/oracle/OraSelectStatement.java
Index: OraSelectStatement.java
===================================================================
RCS file: /home/cvs/ws-jaxme/src/js/org/apache/ws/jaxme/sqls/oracle/OraSelectStatement.java,v
retrieving revision 1.1
retrieving revision 1.2
diff -u -r1.1 -r1.2
--- OraSelectStatement.java 11 Mar 2004 11:03:12 -0000 1.1
+++ OraSelectStatement.java 20 Dec 2004 11:08:16 -0000 1.2
@@ -20,16 +20,33 @@
import org.apache.ws.jaxme.sqls.SelectStatement;
+/** Oracle specific interface of {@link org.apache.ws.jaxme.sqls.SelectStatement}.
+ */
public interface OraSelectStatement extends SelectStatement {
- /** <p>Implements the <code>START WITH</code> part of a
- * <code>START WITH ... CONNECT BY PRIOR ...</code> clause.</p>
+ /** An extension of {@link SelectStatement} with the
+ * ability to specify, whether NULL comes first or last.
+ */
+ public interface OraOrderColumn extends OrderColumn {
+ /** Returns, whether nulls should appear first or last.
+ */
+ public boolean isNullsFirst();
+ }
+ /** Implements the <code>START WITH</code> part of a
+ * <code>START WITH ... CONNECT BY PRIOR ...</code> clause.
* @see #getConnectByPrior()
*/
public CombinedConstraint getStartWith();
- /** <p>Implements the <code>CONNECT BY PRIOR</code> part of a
- * <code>START WITH ... CONNECT BY PRIOR ...</code> clause.</p>
+ /** Implements the <code>CONNECT BY PRIOR</code> part of a
+ * <code>START WITH ... CONNECT BY PRIOR ...</code> clause.
* @see #getStartWith()
*/
public CombinedConstraint getConnectByPrior();
+
+ /** Adds the given order column with the given values for
+ * {@link org.apache.ws.jaxme.sqls.SelectStatement.OrderColumn#isDescending()}
+ * and
+ * {@link OraSelectStatement.OraOrderColumn#isNullsFirst()}.
+ */
+ public void addOrderColumn(Object pObject, boolean pDescending, boolean pNullsFirst);
}
1.7 +2 -2 ws-jaxme/src/js/org/apache/ws/jaxme/sqls/impl/SelectStatementImpl.java
Index: SelectStatementImpl.java
===================================================================
RCS file: /home/cvs/ws-jaxme/src/js/org/apache/ws/jaxme/sqls/impl/SelectStatementImpl.java,v
retrieving revision 1.6
retrieving revision 1.7
diff -u -r1.6 -r1.7
--- SelectStatementImpl.java 27 May 2004 10:15:40 -0000 1.6
+++ SelectStatementImpl.java 20 Dec 2004 11:08:16 -0000 1.7
@@ -33,8 +33,8 @@
*/
public class SelectStatementImpl extends ConstrainedStatementImpl implements SelectStatement {
public static class OrderColumnImpl implements SelectStatement.OrderColumn {
- private Object columnReference;
- private boolean descending;
+ private final Object columnReference;
+ private final boolean descending;
public OrderColumnImpl(Object pColumnReference, boolean pDescending) {
columnReference = pColumnReference;
descending = pDescending;
1.25 +10 -5 ws-jaxme/src/js/org/apache/ws/jaxme/sqls/impl/SQLGeneratorImpl.java
Index: SQLGeneratorImpl.java
===================================================================
RCS file: /home/cvs/ws-jaxme/src/js/org/apache/ws/jaxme/sqls/impl/SQLGeneratorImpl.java,v
retrieving revision 1.24
retrieving revision 1.25
diff -u -r1.24 -r1.25
--- SQLGeneratorImpl.java 25 Nov 2004 09:56:38 -0000 1.24
+++ SQLGeneratorImpl.java 20 Dec 2004 11:08:16 -0000 1.25
@@ -904,7 +904,15 @@
}
return sb.toString();
}
-
+
+ protected String getOrderColumn(StatementMetaData pData, SelectStatement.OrderColumn pColumn) {
+ String s = getBooleanConstraintPart(pData, pColumn.getColumn());
+ if (pColumn.isDescending()) {
+ s += " DESC";
+ }
+ return s;
+ }
+
protected String getSelectQueryOrderClause(StatementMetaData pData, SelectStatement pQuery) {
StringBuffer sb = new StringBuffer();
for (Iterator iter = pQuery.getOrderColumns(); iter.hasNext(); ) {
@@ -914,10 +922,7 @@
} else {
sb.append(", ");
}
- sb.append(getBooleanConstraintPart(pData, col.getColumn()));
- if (col.isDescending()) {
- sb.append(" DESC");
- }
+ sb.append(getOrderColumn(pData, col));
}
return sb.toString();
}
---------------------------------------------------------------------
To unsubscribe, e-mail: jaxme-dev-unsubscribe@ws.apache.org
For additional commands, e-mail: jaxme-dev-help@ws.apache.org