001: /*
002: * Licensed to the Apache Software Foundation (ASF) under one
003: * or more contributor license agreements. See the NOTICE file
004: * distributed with this work for additional information
005: * regarding copyright ownership. The ASF licenses this file
006: * to you under the Apache License, Version 2.0 (the
007: * "License"); you may not use this file except in compliance
008: * with the License. You may obtain a copy of the License at
009: *
010: * http://www.apache.org/licenses/LICENSE-2.0
011: *
012: * Unless required by applicable law or agreed to in writing,
013: * software distributed under the License is distributed on an
014: * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
015: * KIND, either express or implied. See the License for the
016: * specific language governing permissions and limitations
017: * under the License.
018: */
019: package org.apache.openjpa.jdbc.kernel;
020:
021: import java.util.Collection;
022: import java.util.Set;
023:
024: import org.apache.openjpa.jdbc.meta.ClassMapping;
025: import org.apache.openjpa.kernel.DelegatingFetchConfiguration;
026: import org.apache.openjpa.meta.FieldMetaData;
027: import org.apache.openjpa.util.RuntimeExceptionTranslator;
028:
029: ///////////////////////////////////////////////////////////////
030: // NOTE: when adding a public API method, be sure to add it to
031: // JDO and JPA facades!
032: ///////////////////////////////////////////////////////////////
033:
034: /**
035: * Delegating fetch configuration that can also perform exception
036: * transation for use in facades.
037: *
038: * @author Abe White
039: * @nojavadoc
040: * @since 0.4.0
041: */
042: public class DelegatingJDBCFetchConfiguration extends
043: DelegatingFetchConfiguration implements JDBCFetchConfiguration {
044:
045: /**
046: * Constructor; supply delegate.
047: */
048: public DelegatingJDBCFetchConfiguration(
049: JDBCFetchConfiguration delegate) {
050: super (delegate);
051: }
052:
053: /**
054: * Constructor; supply delegate and exception translator.
055: */
056: public DelegatingJDBCFetchConfiguration(
057: JDBCFetchConfiguration delegate,
058: RuntimeExceptionTranslator trans) {
059: super (delegate, trans);
060: }
061:
062: /**
063: * Return the JDBC delegate.
064: */
065: public JDBCFetchConfiguration getJDBCDelegate() {
066: return (JDBCFetchConfiguration) getDelegate();
067: }
068:
069: public int getEagerFetchMode() {
070: try {
071: return getJDBCDelegate().getEagerFetchMode();
072: } catch (RuntimeException re) {
073: throw translate(re);
074: }
075: }
076:
077: public JDBCFetchConfiguration setEagerFetchMode(int mode) {
078: try {
079: getJDBCDelegate().setEagerFetchMode(mode);
080: return this ;
081: } catch (RuntimeException re) {
082: throw translate(re);
083: }
084: }
085:
086: public int getSubclassFetchMode() {
087: try {
088: return getJDBCDelegate().getSubclassFetchMode();
089: } catch (RuntimeException re) {
090: throw translate(re);
091: }
092: }
093:
094: public int getSubclassFetchMode(ClassMapping cls) {
095: try {
096: return getJDBCDelegate().getSubclassFetchMode(cls);
097: } catch (RuntimeException re) {
098: throw translate(re);
099: }
100: }
101:
102: public JDBCFetchConfiguration setSubclassFetchMode(int mode) {
103: try {
104: getJDBCDelegate().setSubclassFetchMode(mode);
105: return this ;
106: } catch (RuntimeException re) {
107: throw translate(re);
108: }
109: }
110:
111: public int getResultSetType() {
112: try {
113: return getJDBCDelegate().getResultSetType();
114: } catch (RuntimeException re) {
115: throw translate(re);
116: }
117: }
118:
119: public JDBCFetchConfiguration setResultSetType(int type) {
120: try {
121: getJDBCDelegate().setResultSetType(type);
122: return this ;
123: } catch (RuntimeException re) {
124: throw translate(re);
125: }
126: }
127:
128: public int getFetchDirection() {
129: try {
130: return getJDBCDelegate().getFetchDirection();
131: } catch (RuntimeException re) {
132: throw translate(re);
133: }
134: }
135:
136: public JDBCFetchConfiguration setFetchDirection(int direction) {
137: try {
138: getJDBCDelegate().setFetchDirection(direction);
139: return this ;
140: } catch (RuntimeException re) {
141: throw translate(re);
142: }
143: }
144:
145: public int getLRSSize() {
146: try {
147: return getJDBCDelegate().getLRSSize();
148: } catch (RuntimeException re) {
149: throw translate(re);
150: }
151: }
152:
153: public JDBCFetchConfiguration setLRSSize(int lrsSize) {
154: try {
155: getJDBCDelegate().setLRSSize(lrsSize);
156: return this ;
157: } catch (RuntimeException re) {
158: throw translate(re);
159: }
160: }
161:
162: public int getJoinSyntax() {
163: try {
164: return getJDBCDelegate().getJoinSyntax();
165: } catch (RuntimeException re) {
166: throw translate(re);
167: }
168: }
169:
170: public JDBCFetchConfiguration setJoinSyntax(int syntax) {
171: try {
172: getJDBCDelegate().setJoinSyntax(syntax);
173: return this ;
174: } catch (RuntimeException re) {
175: throw translate(re);
176: }
177: }
178:
179: public Set getJoins() {
180: try {
181: return getJDBCDelegate().getJoins();
182: } catch (RuntimeException re) {
183: throw translate(re);
184: }
185: }
186:
187: public boolean hasJoin(String field) {
188: try {
189: return getJDBCDelegate().hasJoin(field);
190: } catch (RuntimeException re) {
191: throw translate(re);
192: }
193: }
194:
195: public JDBCFetchConfiguration addJoin(String field) {
196: try {
197: getJDBCDelegate().addJoin(field);
198: return this ;
199: } catch (RuntimeException re) {
200: throw translate(re);
201: }
202: }
203:
204: public JDBCFetchConfiguration addJoins(Collection fields) {
205: try {
206: getJDBCDelegate().addJoins(fields);
207: return this ;
208: } catch (RuntimeException re) {
209: throw translate(re);
210: }
211: }
212:
213: public JDBCFetchConfiguration removeJoin(String field) {
214: try {
215: getJDBCDelegate().removeJoin(field);
216: return this ;
217: } catch (RuntimeException re) {
218: throw translate(re);
219: }
220: }
221:
222: public JDBCFetchConfiguration removeJoins(Collection fields) {
223: try {
224: getJDBCDelegate().removeJoins(fields);
225: return this ;
226: } catch (RuntimeException re) {
227: throw translate(re);
228: }
229: }
230:
231: public JDBCFetchConfiguration clearJoins() {
232: try {
233: getJDBCDelegate().clearJoins();
234: return this ;
235: } catch (RuntimeException re) {
236: throw translate(re);
237: }
238: }
239:
240: public int getIsolation() {
241: try {
242: return getJDBCDelegate().getIsolation();
243: } catch (RuntimeException re) {
244: throw translate(re);
245: }
246: }
247:
248: public JDBCFetchConfiguration setIsolation(int level) {
249: try {
250: getJDBCDelegate().setIsolation(level);
251: return this ;
252: } catch (RuntimeException re) {
253: throw translate(re);
254: }
255: }
256:
257: public JDBCFetchConfiguration traverseJDBC(FieldMetaData fm) {
258: try {
259: return getJDBCDelegate().traverseJDBC(fm);
260: } catch (RuntimeException re) {
261: throw translate(re);
262: }
263: }
264: }
|