KickJava   Java API By Example, From Geeks To Geeks.

Java > Open Source Codes > com > caucho > amber > field > AssociationField


1 /*
2  * Copyright (c) 1998-2006 Caucho Technology -- all rights reserved
3  *
4  * This file is part of Resin(R) Open Source
5  *
6  * Each copy or derived work must preserve the copyright notice and this
7  * notice unmodified.
8  *
9  * Resin Open Source is free software; you can redistribute it and/or modify
10  * it under the terms of the GNU General Public License as published by
11  * the Free Software Foundation; either version 2 of the License, or
12  * (at your option) any later version.
13  *
14  * Resin Open Source is distributed in the hope that it will be useful,
15  * but WITHOUT ANY WARRANTY; without even the implied warranty of
16  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE, or any warranty
17  * of NON-INFRINGEMENT. See the GNU General Public License for more
18  * details.
19  *
20  * You should have received a copy of the GNU General Public License
21  * along with Resin Open Source; if not, write to the
22  * Free Software Foundation, Inc.
23  * 59 Temple Place, Suite 330
24  * Boston, MA 02111-1307 USA
25  *
26  * @author Scott Ferguson
27  */

28
29 package com.caucho.amber.field;
30
31 import com.caucho.amber.table.LinkColumns;
32 import com.caucho.amber.type.RelatedType;
33 import com.caucho.config.ConfigException;
34 import com.caucho.log.Log;
35 import com.caucho.util.L10N;
36
37 import javax.persistence.CascadeType;
38 import java.util.logging.Logger JavaDoc;
39
40
41 /**
42  * Configuration for a bean's field
43  */

44 public class AssociationField extends CollectionField {
45   private static final L10N L = new L10N(AssociationField.class);
46   protected static final Logger JavaDoc log = Log.open(AssociationField.class);
47
48   private LinkColumns _linkColumns;
49
50   private boolean _hasJoinColumns;
51
52   private boolean _hasInverseJoinColumns;
53
54   public AssociationField(RelatedType relatedType,
55                           String JavaDoc name,
56                           CascadeType[] cascadeTypes)
57     throws ConfigException
58   {
59     super(relatedType, name, cascadeTypes);
60   }
61
62   public AssociationField(RelatedType relatedType)
63   {
64     super(relatedType);
65   }
66
67   /**
68    * Returns true if this field is annotated with
69    * @JoinTable and the attribute joinColumns.
70    */

71   public boolean hasJoinColumns()
72   {
73     return _hasJoinColumns;
74   }
75
76   /**
77    * Sets true if this field is annotated with
78    * @JoinTable and the attribute joinColumns.
79    */

80   public void setJoinColumns(boolean hasJoinColumns)
81   {
82     _hasJoinColumns = hasJoinColumns;
83   }
84
85   /**
86    * Returns true if this field is annotated with
87    * @JoinTable and the attribute inverseJoinColumns.
88    */

89   public boolean hasInverseJoinColumns()
90   {
91     return _hasInverseJoinColumns;
92   }
93
94   /**
95    * Sets true if this field is annotated with
96    * @JoinTable and the attribute inverseJoinColumns.
97    */

98   public void setInverseJoinColumns(boolean hasInverseJoinColumns)
99   {
100     _hasInverseJoinColumns = hasInverseJoinColumns;
101   }
102   /**
103    * Sets the result columns.
104    */

105   public void setColumn(LinkColumns columns)
106   {
107     _linkColumns = columns;
108   }
109
110   /**
111    * Gets the result.
112    */

113   public LinkColumns getColumn()
114   {
115     return _linkColumns;
116   }
117
118   /**
119    * Generates the target select.
120    */

121   public String JavaDoc generateTargetSelect(String JavaDoc id)
122   {
123     return getColumn().generateSelectSQL(id);
124   }
125 }
126
Popular Tags