01: /*
02: * Licensed to the Apache Software Foundation (ASF) under one
03: * or more contributor license agreements. See the NOTICE file
04: * distributed with this work for additional information
05: * regarding copyright ownership. The ASF licenses this file
06: * to you under the Apache License, Version 2.0 (the
07: * "License"); you may not use this file except in compliance
08: * with the License. You may obtain a copy of the License at
09: *
10: * http://www.apache.org/licenses/LICENSE-2.0
11: *
12: * Unless required by applicable law or agreed to in writing,
13: * software distributed under the License is distributed on an
14: * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
15: * KIND, either express or implied. See the License for the
16: * specific language governing permissions and limitations
17: * under the License.
18: */
19: package org.apache.openjpa.jdbc.meta;
20:
21: import java.util.Comparator;
22:
23: import org.apache.openjpa.jdbc.sql.Joins;
24: import org.apache.openjpa.jdbc.sql.Select;
25: import org.apache.openjpa.meta.Order;
26:
27: /**
28: * Order by value columns, which are the primary key columns in the case
29: * of a relation field.
30: *
31: * @author Abe White
32: */
33: class JDBCValueOrder implements JDBCOrder {
34:
35: private final FieldMapping _fm;
36: private final boolean _asc;
37:
38: public JDBCValueOrder(FieldMapping fm, boolean asc) {
39: _fm = fm;
40: _asc = asc;
41: }
42:
43: public String getName() {
44: return Order.ELEMENT;
45: }
46:
47: public boolean isAscending() {
48: return _asc;
49: }
50:
51: public Comparator getComparator() {
52: return null;
53: }
54:
55: public boolean isInRelation() {
56: return _fm.getElement().getTypeMetaData() != null;
57: }
58:
59: public void order(Select sel, ClassMapping elem, Joins joins) {
60: if (elem != null)
61: sel
62: .orderBy(elem.getPrimaryKeyColumns(), _asc, joins,
63: false);
64: else
65: sel.orderBy(_fm.getElementMapping().getColumns(), _asc,
66: joins, false);
67: }
68: }
|