1 /*
2 * Copyright 2004 University of Hannover
3 *
4 * Licensed under the Apache License, Version 2.0 (the "License");
5 * you may not use this file except in compliance with the License.
6 * You may obtain a copy of the License at
7 *
8 * http://www.apache.org/licenses/LICENSE-2.0
9 *
10 * Unless required by applicable law or agreed to in writing, software
11 * distributed under the License is distributed on an "AS IS" BASIS,
12 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13 * See the License for the specific language governing permissions and
14 * limitations under the License.
15 */
16
17 package olr.samples;
18
19 import java.util.List;
20
21 import olr.Olr;
22 import olr.om.RdfGroup;
23 import olr.om.RdfGroupPeer;
24
25 import org.apache.torque.util.Criteria;
26
27 /***
28 * Example showing a simple query using the Torque Criteria class.
29 * @version $Id: CriteriaSample.java,v 1.4 2004/08/02 18:36:43 roku Exp $
30 */
31 public class CriteriaSample
32 {
33 public static void main(String[] args)
34 {
35 try
36 {
37 Olr.initTorque();
38 Criteria criteria = new Criteria();
39 criteria.add(RdfGroupPeer.NAME, "Administrator");
40 List groups = RdfGroupPeer.doSelect(criteria);
41
42 assert(groups.size() == 1);
43
44 RdfGroup group = (RdfGroup)groups.get(0);
45
46 System.out.println("Selected group "
47 + group.getName()
48 + " with id="
49 + group.getId());
50 }
51 catch(Exception e)
52 {
53 e.printStackTrace();
54 }
55 }
56 }