01: /*
02: * TestFetchGroupsExtent.java
03: *
04: * Created on October 12, 2006, 9:54 AM
05: *
06: * To change this template, choose Tools | Template Manager
07: * and open the template in the editor.
08: */
09: /*
10: * Licensed to the Apache Software Foundation (ASF) under one
11: * or more contributor license agreements. See the NOTICE file
12: * distributed with this work for additional information
13: * regarding copyright ownership. The ASF licenses this file
14: * to you under the Apache License, Version 2.0 (the
15: * "License"); you may not use this file except in compliance
16: * with the License. You may obtain a copy of the License at
17: *
18: * http://www.apache.org/licenses/LICENSE-2.0
19: *
20: * Unless required by applicable law or agreed to in writing,
21: * software distributed under the License is distributed on an
22: * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
23: * KIND, either express or implied. See the License for the
24: * specific language governing permissions and limitations
25: * under the License.
26: */
27: package org.apache.openjpa.persistence.kernel;
28:
29: import java.util.Collection;
30: import java.util.List;
31:
32: import org.apache.openjpa.persistence.kernel.common.apps.FetchGroupTestObject;
33: import org.apache.openjpa.persistence.kernel.common.apps.FetchGroupTestObjectChild;
34:
35: import org.apache.openjpa.persistence.Extent;
36: import org.apache.openjpa.persistence.OpenJPAEntityManager;
37: import org.apache.openjpa.persistence.OpenJPAQuery;
38:
39: public class TestFetchGroupsExtent extends TestFetchGroups {
40:
41: /**
42: * Creates a new instance of TestFetchGroupsExtent
43: */
44: public TestFetchGroupsExtent() {
45: }
46:
47: public TestFetchGroupsExtent(String s) {
48: super (s);
49: }
50:
51: protected FetchGroupTestObject getO1(OpenJPAEntityManager pm) {
52: Extent e = (Extent) pm.createExtent(FetchGroupTestObject.class,
53: true);
54: List l = e.list();
55:
56: OpenJPAQuery q = pm
57: .createQuery("SELECT o FROM FetchGroupTestObject o WHERE o.a = 5");
58: q.setCandidateCollection(l);
59:
60: return (FetchGroupTestObject) ((Collection) q.getResultList())
61: .iterator().next();
62: }
63:
64: protected FetchGroupTestObject getO2(OpenJPAEntityManager pm) {
65: Extent e = (Extent) pm.createExtent(FetchGroupTestObject.class,
66: true);
67: List l = e.list();
68:
69: OpenJPAQuery q = pm
70: .createQuery("SELECT o FROM FetchGroupTestObject o WHERE o.a = 3");
71: q.setCandidateCollection(l);
72:
73: return (FetchGroupTestObject) ((Collection) q.getResultList())
74: .iterator().next();
75: }
76:
77: protected FetchGroupTestObjectChild getC1(OpenJPAEntityManager pm) {
78: Extent e = (Extent) pm.createExtent(FetchGroupTestObject.class,
79: true);
80: List l = e.list();
81:
82: OpenJPAQuery q = pm
83: .createQuery("SELECT o FROM FetchGroupTestObjectChild o WHERE o.a = 4");
84: q.setCandidateCollection(l);
85:
86: return (FetchGroupTestObjectChild) ((Collection) q
87: .getResultList()).iterator().next();
88: }
89: }
|