1
2
3
4
5
6
7
8
9
10
11
12
13
14
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 import olr.om.RdfUser;
25
26 import org.apache.torque.util.Criteria;
27
28 /***
29 * Example showing how to retrieve collections of objects
30 * referenced by a foreign key using the Torque object model.
31 * @version $Id: ForeignKeySample.java,v 1.3 2004/08/02 18:36:43 roku Exp $
32 */
33 public class ForeignKeySample
34 {
35 public static void main(String[] args)
36 {
37 try
38 {
39 Olr.initTorque();
40 Criteria criteria = new Criteria();
41 criteria.add(RdfGroupPeer.NAME, "Administrator");
42 List groups = RdfGroupPeer.doSelect(criteria);
43
44 assert(groups.size() == 1);
45
46 RdfGroup group = (RdfGroup)groups.get(0);
47 List members = group.getRdfUsers();
48
49 System.out.println("Members of group "
50 + group.getName() + ":\n");
51
52 for(int i=0; i<members.size(); i++)
53 System.out.println(((RdfUser)members.get(i)).getLogin());
54 }
55 catch(Exception e)
56 {
57 e.printStackTrace();
58 }
59 }
60 }