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