KickJava   Java API By Example, From Geeks To Geeks.

Java > Open Source Codes > org > jboss > ejb > plugins > cmp > jdbc > bridge > JDBCCMPFieldBridge


1 /*
2 * JBoss, Home of Professional Open Source
3 * Copyright 2005, JBoss Inc., and individual contributors as indicated
4 * by the @authors tag. See the copyright.txt in the distribution for a
5 * full listing of individual contributors.
6 *
7 * This is free software; you can redistribute it and/or modify it
8 * under the terms of the GNU Lesser General Public License as
9 * published by the Free Software Foundation; either version 2.1 of
10 * the License, or (at your option) any later version.
11 *
12 * This software is distributed in the hope that it will be useful,
13 * but WITHOUT ANY WARRANTY; without even the implied warranty of
14 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
15 * Lesser General Public License for more details.
16 *
17 * You should have received a copy of the GNU Lesser General Public
18 * License along with this software; if not, write to the Free
19 * Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA
20 * 02110-1301 USA, or see the FSF site: http://www.fsf.org.
21 */

22 package org.jboss.ejb.plugins.cmp.jdbc.bridge;
23
24
25 import java.lang.reflect.Field JavaDoc;
26 import java.sql.PreparedStatement JavaDoc;
27 import java.sql.ResultSet JavaDoc;
28
29 import org.jboss.ejb.plugins.cmp.bridge.CMPFieldBridge;
30 import org.jboss.ejb.plugins.cmp.jdbc.JDBCStoreManager;
31 import org.jboss.ejb.plugins.cmp.jdbc.LockingStrategy;
32 import org.jboss.ejb.EntityEnterpriseContext;
33
34 /**
35  * JDBCCMPFieldBridge represents one CMP field. This implementations of
36  * this interface handles setting are responsible for setting statement
37  * parameters and loading results for instance values and primary
38  * keys.
39  *
40  * Life-cycle:
41  * Tied to the EntityBridge.
42  *
43  * Multiplicity:
44  * One for each entity bean cmp field.
45  *
46  * @author <a HREF="mailto:dain@daingroup.com">Dain Sundstrom</a>
47  * @author <a HREF="mailto:loubyansky@hotmail.com">Alex Loubyansky</a>
48  *
49  * @version $Revision: 37459 $
50  */

51 public interface JDBCCMPFieldBridge extends JDBCFieldBridge, CMPFieldBridge
52 {
53    /**
54     * The index of the field among the table fields.
55     */

56    int getTableIndex();
57
58    /**
59     * Returns the default field flags.
60     */

61    byte getDefaultFlags();
62
63    /**
64     * TODO: Get rid of it
65     * @param flag
66     */

67    void addDefaultFlag(byte flag);
68
69    /**
70     * @param ctx instance's context
71     * @return field value that was locked.
72     */

73    Object JavaDoc getLockedValue(EntityEnterpriseContext ctx);
74
75    /**
76     * Optimistically locks field value.
77     */

78    public void lockInstanceValue(EntityEnterpriseContext ctx);
79
80    /**
81     * @param lockingStrategy locking strategy assigned to the field
82     */

83    void setLockingStrategy(LockingStrategy lockingStrategy);
84
85    /**
86     * Gets the field of the primary key object in which the value of this
87     * field is stored.
88     */

89    public Field JavaDoc getPrimaryKeyField();
90
91    /**
92     * Gets the value of this field in the specified primaryKey object.
93     * @param primaryKey the primary key object from which this fields value
94     * will be extracted
95     * @return the value of this field in the primaryKey object
96     */

97    public Object JavaDoc getPrimaryKeyValue(Object JavaDoc primaryKey)
98          throws IllegalArgumentException JavaDoc;
99
100    /**
101     * @return true if the field belongs to a relation table
102     */

103    boolean isRelationTableField();
104
105    /**
106     * Sets the value of this field to the specified value in the
107     * specified primaryKey object.
108     * @param primaryKey the primary key object which the value
109     * will be inserted
110     * @param value the value for field that will be set in the pk
111     * @return the updated primary key object; the actual object may
112     * change not just the value
113     */

114     public Object JavaDoc setPrimaryKeyValue(Object JavaDoc primaryKey, Object JavaDoc value)
115          throws IllegalArgumentException JavaDoc;
116    
117    /**
118     * Sets the prepared statement parameters with the data from the
119     * primary key.
120     */

121    public int setPrimaryKeyParameters(PreparedStatement JavaDoc ps, int parameterIndex, Object JavaDoc primaryKey) throws IllegalArgumentException JavaDoc;
122    
123    /**
124     * Sets the prepared statement parameters with the data from the
125     * object. The object must be the type of this field.
126     */

127    public int setArgumentParameters(PreparedStatement JavaDoc ps, int parameterIndex, Object JavaDoc arg);
128
129    /**
130     * Loads the data from result set into the primary key object.
131     */

132    public int loadPrimaryKeyResults(ResultSet JavaDoc rs, int parameterIndex, Object JavaDoc[] pkRef) throws IllegalArgumentException JavaDoc;
133 }
134
Popular Tags