b6c45e69fc8a8b4b940b1990936879ff20b82ccb
[mir.git] / source / org / codecoop / mir / core / dao / hibernate / HibernateQueryFactory.java
1 /*
2  * $Id: HibernateQueryFactory.java,v 1.1 2004/11/06 16:20:48 idfx Exp $
3  * 
4  * Copyright (C) 2001, 2002, 2003, 2004 The Mir-coders group
5  *
6  * This file is part of Mir.
7  *
8  * Mir is free software; you can redistribute it and/or modify
9  * it under the terms of the GNU General Public License as published by
10  * the Free Software Foundation; either version 2 of the License, or
11  * (at your option) any later version.
12  *
13  * Mir is distributed in the hope that it will be useful,
14  * but WITHOUT ANY WARRANTY; without even the implied warranty of
15  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
16  * GNU General Public License for more details.
17  *
18  * You should have received a copy of the GNU General Public License
19  * along with Mir; if not, write to the Free Software
20  * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA  02111-1307  USA
21  *
22  * In addition, as a special exception, The Mir-coders gives permission to link
23  * the code of this program with  any library licensed under the Apache Software License,
24  * The Sun (tm) Java Advanced Imaging library (JAI), The Sun JIMI library
25  * (or with modified versions of the above that use the same license as the above),
26  * and distribute linked combinations including the two.  You must obey the
27  * GNU General Public License in all respects for all of the code used other than
28  * the above mentioned libraries.  If you modify this file, you may extend this
29  * exception to your version of the file, but you are not obligated to do so.
30  * If you do not wish to do so, delete this exception statement from your version.
31  */
32 package org.codecoop.mir.core.dao.hibernate;
33
34 import java.util.Map;
35
36 import org.codecoop.mir.core.dao.IQueryCriteria;
37 import org.codecoop.mir.core.dao.IQueryExpression;
38 import org.codecoop.mir.core.dao.IQueryFactory;
39 import org.codecoop.mir.core.dao.IQueryOrder;
40 import org.codecoop.mir.core.dao.QueryFailure;
41
42 /**
43  * HibernateQueryFactory
44  * @author idefix
45  * @version $Revision: 1.1 $
46  */
47 public class HibernateQueryFactory implements IQueryFactory {
48
49   /**
50    * @see org.codecoop.mir.core.dao.IQueryFactory#createCriteria(java.lang.Class)
51    */
52   public IQueryCriteria createCriteria(Class persistentClass) throws QueryFailure {
53     return new QueryCriteria(persistentClass);
54   }
55
56   /**
57    * @see org.codecoop.mir.core.dao.IQueryFactory#descOrder(java.lang.String)
58    */
59   public IQueryOrder descOrder(String property) {
60     return new QueryOrder(property, QueryOrder.DESC);
61   }
62
63   /**
64    * @see org.codecoop.mir.core.dao.IQueryFactory#ascOrder(java.lang.String)
65    */
66   public IQueryOrder ascOrder(String property) {
67     return new QueryOrder(property, QueryOrder.ASC);
68   }
69
70   /**
71    * @see org.codecoop.mir.core.dao.IQueryFactory#allEq(java.util.Map)
72    */
73   public IQueryExpression allEq(Map propertyNameValue) {
74     return new AllEqExpression(propertyNameValue);
75   }
76
77   /**
78    * @see org.codecoop.mir.core.dao.IQueryFactory#eq(java.lang.String, java.lang.Object, boolean)
79    */
80   public IQueryExpression eq(String property, Object value, boolean ignoreCase) {
81     return new EqExpression(property, value, ignoreCase);
82   }
83   
84   /**
85    * @see org.codecoop.mir.core.dao.IQueryFactory#eq(java.lang.String, java.lang.Object, boolean)
86    */
87   public IQueryExpression eq(String property, Object value) {
88     return new EqExpression(property, value);
89   }
90
91   /**
92    * @see org.codecoop.mir.core.dao.IQueryFactory#not(org.codecoop.mir.core.query.IQueryExpression)
93    */
94   public IQueryExpression not(IQueryExpression expression) {
95     return new NotExpression(expression);
96   }
97
98   /**
99    * @see org.codecoop.mir.core.dao.IQueryFactory#gt(java.lang.String, java.lang.Object)
100    */
101   public IQueryExpression gt(String property, Object value) {
102     return new GtExpression(property, value);
103   }
104
105   /**
106    * @see org.codecoop.mir.core.dao.IQueryFactory#ge(java.lang.String, java.lang.Object)
107    */
108   public IQueryExpression ge(String property, Object value) {
109     return new GeExpression(property, value);
110   }
111
112   /**
113    * @see org.codecoop.mir.core.dao.IQueryFactory#lt(java.lang.String, java.lang.Object)
114    */
115   public IQueryExpression lt(String property, Object value) {
116     return new LtExpression(property, value);
117   }
118
119   /**
120    * @see org.codecoop.mir.core.dao.IQueryFactory#le(java.lang.String, java.lang.Object)
121    */
122   public IQueryExpression le(String property, Object value) {
123     return new LeExpression(property, value);
124   }
125
126   /**
127    * @see org.codecoop.mir.core.dao.IQueryFactory#like(java.lang.String, java.lang.Object)
128    */
129   public IQueryExpression like(String property, Object value) {
130     return new LikeExpression(property, value);
131   }
132
133 }