KickJava   Java API By Example, From Geeks To Geeks.

Java > Open Source Codes > org > apache > ojb > broker > query > QueryByMtoNCriteria


1 package org.apache.ojb.broker.query;
2
3 /* Copyright 2002-2005 The Apache Software Foundation
4  *
5  * Licensed under the Apache License, Version 2.0 (the "License");
6  * you may not use this file except in compliance with the License.
7  * You may obtain a copy of the License at
8  *
9  * 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 /**
20  * represents a search by criteria.
21  * "find all articles where article.price > 100"
22  * could be represented as:
23  *
24  * Criteria crit = new Criteria();
25  * crit.addGreaterThan("price", new Double(100));
26  * Query qry = new QueryByCriteria(Article.class, crit);
27  *
28  * The PersistenceBroker can retrieve Objects by Queries as follows:
29  *
30  * PersistenceBroker broker = PersistenceBrokerFactory.createPersistenceBroker();
31  * Collection col = broker.getCollectionByQuery(qry);
32  *
33  * @author <a HREF="mailto:thma@apache.org">Thomas Mahler<a>
34  * @version $Id: QueryByMtoNCriteria.java,v 1.7.2.1 2005/12/21 22:27:09 tomdz Exp $
35  */

36
37 public class QueryByMtoNCriteria extends QueryByCriteria implements MtoNQuery
38 {
39     private String JavaDoc indirectionTable;
40
41     /**
42      * return indirectionTable
43      */

44     public String JavaDoc getIndirectionTable()
45     {
46         return indirectionTable;
47     }
48
49     /**
50      * Build a Query for class targetClass with criteria.
51      * Criteriy may be null (will result in a query returning ALL objects from a table)
52      */

53     public QueryByMtoNCriteria(Class JavaDoc targetClass, String JavaDoc indirectionTable, Criteria criteria)
54     {
55         this(targetClass, indirectionTable, criteria, false);
56     }
57
58     /**
59      * Build a Query for class targetClass with criteria.
60      * Criteriy may be null (will result in a query returning ALL objects from a table)
61      */

62     public QueryByMtoNCriteria(Class JavaDoc targetClass, String JavaDoc indirectionTable, Criteria criteria, boolean distinct)
63     {
64         super(targetClass , criteria, distinct);
65         this.indirectionTable = indirectionTable;
66     }
67
68     /**
69      * Insert the method's description here.
70      * Creation date: (07.02.2001 22:01:55)
71      * @return java.lang.String
72      */

73     public String JavaDoc toString()
74     {
75         return "Query from " + indirectionTable + " where " + getCriteria();
76     }
77
78 }
79
Popular Tags