01: /*
02: * Licensed to the Apache Software Foundation (ASF) under one
03: * or more contributor license agreements. See the NOTICE file
04: * distributed with this work for additional information
05: * regarding copyright ownership. The ASF licenses this file
06: * to you under the Apache License, Version 2.0 (the
07: * "License"); you may not use this file except in compliance
08: * with the License. You may obtain a copy of the License at
09: *
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: package org.apache.openjpa.persistence.jdbc.annotations;
20:
21: import javax.persistence.*;
22:
23: @Entity
24: @Table(name="EMIDENTITY")
25: @SqlResultSetMapping(name="EmbeddedIdMapping",entities={@EntityResult(entityClass=EmbeddedIdEntity.class,fields={@FieldResult(name="id.pk1",column="OWNER_PK1"),@FieldResult(name="id.pk2",column="OWNER_PK2"),@FieldResult(name="id.pk3",column="OWNER_PK3"),@FieldResult(name="value",column="OWNER_VAL"),@FieldResult(name="relation.id.pk1",column="REL_PK1"),@FieldResult(name="relation.id.pk2",column="REL_PK2"),@FieldResult(name="relation.id.pk3",column="REL_PK3")}),@EntityResult(entityClass=EmbeddedIdEntity.class,fields={@FieldResult(name="id.pk1",column="REL_PK1"),@FieldResult(name="id.pk2",column="REL_PK2"),@FieldResult(name="id.pk3",column="REL_PK3"),@FieldResult(name="value",column="REL_VAL")})})
26: public class EmbeddedIdEntity {
27:
28: @EmbeddedId
29: private EmbeddedIdClass id;
30:
31: @Column(name="VAL")
32: private String value;
33:
34: @ManyToOne
35: private EmbeddedIdEntity relation;
36:
37: @ManyToOne
38: @JoinColumns({@JoinColumn(name="MREL_PK1",referencedColumnName="EPK1"),@JoinColumn(name="MREL_PK2",referencedColumnName="EPK2")})
39: private EmbeddedIdEntity mapOverrideRelation;
40:
41: public EmbeddedIdClass getId() {
42: return id;
43: }
44:
45: public void setId(EmbeddedIdClass id) {
46: this .id = id;
47: }
48:
49: public String getValue() {
50: return value;
51: }
52:
53: public void setValue(String value) {
54: this .value = value;
55: }
56:
57: public EmbeddedIdEntity getRelation() {
58: return relation;
59: }
60:
61: public void setRelation(EmbeddedIdEntity relation) {
62: this .relation = relation;
63: }
64:
65: public EmbeddedIdEntity getMappingOverrideRelation() {
66: return mapOverrideRelation;
67: }
68: }
|