KickJava   Java API By Example, From Geeks To Geeks.

Java > Open Source Codes > org > apache > cayenne > jpa > map > JpaSqlResultSetMapping


1 /*****************************************************************
2  * Licensed to the Apache Software Foundation (ASF) under one
3  * or more contributor license agreements. See the NOTICE file
4  * distributed with this work for additional information
5  * regarding copyright ownership. The ASF licenses this file
6  * to you under the Apache License, Version 2.0 (the
7  * "License"); you may not use this file except in compliance
8  * with the License. You may obtain a copy of the License at
9  *
10  * http://www.apache.org/licenses/LICENSE-2.0
11  *
12  * Unless required by applicable law or agreed to in writing,
13  * software distributed under the License is distributed on an
14  * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
15  * KIND, either express or implied. See the License for the
16  * specific language governing permissions and limitations
17  * under the License.
18  ****************************************************************/

19
20
21 package org.apache.cayenne.jpa.map;
22
23 import java.util.ArrayList JavaDoc;
24 import java.util.Collection JavaDoc;
25
26 import javax.persistence.SqlResultSetMapping;
27
28 import org.apache.cayenne.util.TreeNodeChild;
29
30 public class JpaSqlResultSetMapping {
31
32     protected String JavaDoc name;
33     protected Collection JavaDoc<JpaEntityResult> entityResults;
34     protected Collection JavaDoc<JpaColumnResult> columnResults;
35
36     public JpaSqlResultSetMapping() {
37
38     }
39
40     public JpaSqlResultSetMapping(SqlResultSetMapping annotation) {
41         name = annotation.name();
42
43         getEntityResults();
44         for (int i = 0; i < annotation.entities().length; i++) {
45             entityResults.add(new JpaEntityResult(annotation.entities()[i]));
46         }
47
48         getColumnResults();
49         for (int i = 0; i < annotation.columns().length; i++) {
50             columnResults.add(new JpaColumnResult(annotation.columns()[i]));
51         }
52     }
53
54     public String JavaDoc getName() {
55         return name;
56     }
57
58     public void setName(String JavaDoc name) {
59         this.name = name;
60     }
61
62     @TreeNodeChild(type=JpaColumnResult.class)
63     public Collection JavaDoc<JpaColumnResult> getColumnResults() {
64         if (columnResults == null) {
65             columnResults = new ArrayList JavaDoc<JpaColumnResult>(5);
66         }
67         return columnResults;
68     }
69
70     @TreeNodeChild(type=JpaEntityResult.class)
71     public Collection JavaDoc<JpaEntityResult> getEntityResults() {
72         if (entityResults == null) {
73             entityResults = new ArrayList JavaDoc<JpaEntityResult>(5);
74         }
75
76         return entityResults;
77     }
78 }
79
Popular Tags