01: package org.apache.ojb.broker.query;
02:
03: /* Copyright 2002-2005 The Apache Software Foundation
04: *
05: * Licensed under the Apache License, Version 2.0 (the "License");
06: * you may not use this file except in compliance with the License.
07: * You may obtain a copy of the License at
08: *
09: * http://www.apache.org/licenses/LICENSE-2.0
10: *
11: * Unless required by applicable law or agreed to in writing, software
12: * distributed under the License is distributed on an "AS IS" BASIS,
13: * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
14: * See the License for the specific language governing permissions and
15: * limitations under the License.
16: */
17:
18: /**
19: * represents a search by criteria.
20: * "find all articles where article.price > 100"
21: * could be represented as:
22: *
23: * Criteria crit = new Criteria();
24: * crit.addGreaterThan("price", new Double(100));
25: * Query qry = new QueryByCriteria(Article.class, crit);
26: *
27: * The PersistenceBroker can retrieve Objects by Queries as follows:
28: *
29: * PersistenceBroker broker = PersistenceBrokerFactory.createPersistenceBroker();
30: * Collection col = broker.getCollectionByQuery(qry);
31: *
32: * @author <a href="mailto:thma@apache.org">Thomas Mahler<a>
33: * @version $Id: QueryByMtoNCriteria.java,v 1.7.2.1 2005/12/21 22:27:09 tomdz Exp $
34: */
35:
36: public class QueryByMtoNCriteria extends QueryByCriteria implements
37: MtoNQuery {
38: private String indirectionTable;
39:
40: /**
41: * return indirectionTable
42: */
43: public String getIndirectionTable() {
44: return indirectionTable;
45: }
46:
47: /**
48: * Build a Query for class targetClass with criteria.
49: * Criteriy may be null (will result in a query returning ALL objects from a table)
50: */
51: public QueryByMtoNCriteria(Class targetClass,
52: String indirectionTable, Criteria criteria) {
53: this (targetClass, indirectionTable, criteria, false);
54: }
55:
56: /**
57: * Build a Query for class targetClass with criteria.
58: * Criteriy may be null (will result in a query returning ALL objects from a table)
59: */
60: public QueryByMtoNCriteria(Class targetClass,
61: String indirectionTable, Criteria criteria, boolean distinct) {
62: super (targetClass, criteria, distinct);
63: this .indirectionTable = indirectionTable;
64: }
65:
66: /**
67: * Insert the method's description here.
68: * Creation date: (07.02.2001 22:01:55)
69: * @return java.lang.String
70: */
71: public String toString() {
72: return "Query from " + indirectionTable + " where "
73: + getCriteria();
74: }
75:
76: }
|