KickJava   Java API By Example, From Geeks To Geeks.

Java > Open Source Codes > com > caucho > amber > entity > Entity


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  *
23  * Free Software Foundation, Inc.
24  * 59 Temple Place, Suite 330
25  * Boston, MA 02111-1307 USA
26  *
27  * @author Scott Ferguson
28  */

29
30 package com.caucho.amber.entity;
31
32 import com.caucho.amber.manager.AmberConnection;
33 import com.caucho.amber.type.EntityType;
34
35 import java.sql.PreparedStatement JavaDoc;
36 import java.sql.ResultSet JavaDoc;
37 import java.sql.SQLException JavaDoc;
38 import java.util.Map JavaDoc;
39
40 /**
41  * An entity instance
42  */

43 public interface Entity {
44   public static final int TRANSIENT = 0;
45   public static final int P_NEW = 1;
46   public static final int P_NON_TRANSACTIONAL = 2;
47   public static final int P_TRANSACTIONAL = 3;
48   public static final int P_DELETING = 4;
49   public static final int P_DELETED = 5;
50
51   /**
52    * Makes the entity persistent.
53    */

54   public boolean __caucho_makePersistent(AmberConnection aConn,
55                                          EntityType entityType)
56     throws SQLException JavaDoc;
57
58   /**
59    * Makes the entity persistent.
60    */

61   public void __caucho_makePersistent(AmberConnection aConn,
62                                       EntityItem item)
63     throws SQLException JavaDoc;
64
65   /**
66    * Pre-cascades the persist operation to child entities.
67    */

68   public void __caucho_cascadePrePersist(AmberConnection aConn)
69     throws SQLException JavaDoc;
70
71   /**
72    * Pre-cascades the remove operation to child entities.
73    */

74   public void __caucho_cascadePreRemove(AmberConnection aConn)
75     throws SQLException JavaDoc;
76
77   /**
78    * Post-cascades the persist operation to child entities.
79    */

80   public void __caucho_cascadePostPersist(AmberConnection aConn)
81     throws SQLException JavaDoc;
82
83   /**
84    * Post-cascades the remove operation to child entities.
85    */

86   public void __caucho_cascadePostRemove(AmberConnection aConn)
87     throws SQLException JavaDoc;
88
89   /**
90    * Detatch the entity
91    */

92   public void __caucho_detach();
93
94   /**
95    * Creates the entity in the database, making it persistent-new.
96    */

97   public boolean __caucho_create(AmberConnection aConn,
98                                  EntityType entityType)
99     throws SQLException JavaDoc;
100
101   /**
102    * Set the primary key.
103    */

104   public void __caucho_setPrimaryKey(Object JavaDoc key);
105
106   /**
107    * Get the primary key.
108    */

109   public Object JavaDoc __caucho_getPrimaryKey();
110
111   /**
112    * Get the entity type.
113    */

114   public EntityType __caucho_getEntityType();
115
116   /**
117    * Get the entity state.
118    */

119   public int __caucho_getEntityState();
120
121   /**
122    * Sets the connection.
123    */

124   public void __caucho_setConnection(AmberConnection aConn);
125
126   /**
127    * Returns the connection.
128    */

129   public AmberConnection __caucho_getConnection();
130
131   /**
132    * Returns true if the entity matches.
133    */

134   public boolean __caucho_match(String JavaDoc className, Object JavaDoc key);
135
136   /**
137    * Loads the entity from the database.
138    */

139   public EntityItem __caucho_home_find(AmberConnection aConn,
140                                        AmberEntityHome home,
141                                        ResultSet JavaDoc rs, int index)
142     throws SQLException JavaDoc;
143
144   /**
145    * Returns a new entity.
146    */

147   public Entity __caucho_home_new(AmberConnection aConn,
148                                   AmberEntityHome home,
149                                   Object JavaDoc key)
150     throws SQLException JavaDoc;
151
152   /**
153    * Returns a new entity.
154    */

155   public Entity __caucho_home_new(AmberConnection aConn,
156                                   AmberEntityHome home,
157                                   Object JavaDoc key,
158                                   boolean loadFromResultSet)
159     throws SQLException JavaDoc;
160
161   /**
162    * Creates a new instance based the current entity
163    */

164   public Entity __caucho_copy(AmberConnection aConn, EntityItem cacheItem);
165
166   /**
167    * Retrieves data from the data store.
168    */

169   public void __caucho_retrieve(AmberConnection aConn)
170     throws SQLException JavaDoc;
171
172   /**
173    * Retrieves data from the data store.
174    */

175   public void __caucho_retrieve(AmberConnection aConn, Map JavaDoc preloadedProperties)
176     throws SQLException JavaDoc;
177
178   /**
179    * Loads the entity from the database and
180    * returns the number of columns consumed
181    * from the result set.
182    */

183   public int __caucho_load(AmberConnection aConn, ResultSet JavaDoc rs, int index)
184     throws SQLException JavaDoc;
185
186   /**
187    * Loads the entity from the database.
188    */

189   public void __caucho_setKey(PreparedStatement JavaDoc pstmt, int index)
190     throws SQLException JavaDoc;
191
192   /**
193    * Expires data
194    */

195   public void __caucho_expire();
196
197   /**
198    * Deletes the entity from the database.
199    */

200   public void __caucho_delete();
201
202   /**
203    * Called when a foreign object is created/deleted.
204    */

205   public void __caucho_invalidate_foreign(String JavaDoc table, Object JavaDoc key);
206
207   /**
208    * Flushes changes to the backing store.
209    */

210   public boolean __caucho_flush()
211     throws SQLException JavaDoc;
212
213   /**
214    * After a commit.
215    */

216   public void __caucho_afterCommit();
217
218   /**
219    * After a rollback.
220    */

221   public void __caucho_afterRollback();
222
223   /**
224    * Loads the values from the object.
225    */

226   // public void __caucho_loadFromObject(Object src);
227
}
228
Popular Tags