KickJava   Java API By Example, From Geeks To Geeks.

Java > Open Source Codes > org > apache > ojb > odmg > TransactionExt


1 package org.apache.ojb.odmg;
2
3 /* Copyright 2003-2005 The Apache Software Foundation
4  *
5  * Licensed under the Apache License, Version 2.0 (the "License");
6  * you may not use this file except in compliance with the License.
7  * You may obtain a copy of the License at
8  *
9  * http://www.apache.org/licenses/LICENSE-2.0
10  *
11  * Unless required by applicable law or agreed to in writing, software
12  * distributed under the License is distributed on an "AS IS" BASIS,
13  * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
14  * See the License for the specific language governing permissions and
15  * limitations under the License.
16  */

17
18 import org.odmg.Transaction;
19 import org.apache.ojb.broker.Identity;
20
21 /**
22  * Offers useful none odmg-standard methods of the odmg {@link org.odmg.Transaction} interface.
23  * <p>
24  * Note: All listed methods are <strong>not</strong> part of the standard ODMG-api -
25  * they are special (proprietary) OJB extensions.
26  * </p>
27  *
28  * @version $Id: TransactionExt.java,v 1.4.2.8 2005/12/21 22:29:21 tomdz Exp $
29  */

30 public interface TransactionExt extends Transaction, HasBroker
31 {
32     /**
33      * Marks an object for deletion without
34      * locking the object. If the object wasn't locked before,
35      * OJB will ask for a WRITE lock at commit.
36      *
37      * @param anObject Object to be marked
38      */

39     public void markDelete(Object JavaDoc anObject);
40
41     /**
42      * Marks an object as dirty without
43      * locking the object. If the object wasn't locked before,
44      * OJB will ask for a WRITE lock at commit.
45      *
46      * @param anObject Object to be marked
47      */

48     public void markDirty(Object JavaDoc anObject);
49
50     /**
51      * <p>
52      * Calling <code>flush</code> flushes persistent object modifications
53      * made within the ODMG transaction since the last checkpoint to the underlying
54      * database transaction, but does <b<not</b> commit the database transaction.
55      * The ODMG transaction retains all locks it held on those objects at the time the flush
56      * was invoked.
57      * <p/>
58      * This method is very similair to {@link org.odmg.Transaction#checkpoint}.
59      */

60     public void flush();
61
62     /**
63      * This method can be used to activate or deactivate the implicit
64      * locking mechanism for the current transaction.
65      * <br/>
66      * If set <em>true</em> OJB implicitly locks objects to ODMG transactions
67      * after performing OQL queries. Also if implicit locking is used
68      * locking objects is recursive, that is associated objects are also
69      * locked. If ImplicitLocking is set to 'false', no locks are obtained
70      * in OQL queries, lookup objects and there is also no recursive locking.
71      * <p/>
72      * Turning off implicit locking may improve performance but requires
73      * additional care to make sure all changed objects are properly
74      * registered to the transaction.
75      *
76      * @param value If set <em>true</em> implicit locking is enabled,
77      * if <em>false</em>, implicit locking is disabled.
78      * @see ImplementationExt#setImplicitLocking(boolean)
79      **/

80     public void setImplicitLocking(boolean value);
81
82     /**
83      * Returns <em>true</em> if implicite locking is enabled.
84      * @see #setImplicitLocking(boolean)
85      */

86     public boolean isImplicitLocking();
87
88     /**
89      * Allows to change the <em>cascading delete</em> behavior of the target class's
90      * reference field while this transaction is in use.
91      *
92      * @param target The class to change cascading delete behavior of the references.
93      * @param referenceField The field name of the 1:1, 1:n or m:n reference.
94      * @param doCascade If <em>true</em> cascading delete is enabled, <em>false</em> disabled.
95      */

96     public void setCascadingDelete(Class JavaDoc target, String JavaDoc referenceField, boolean doCascade);
97
98     /**
99      * Allows to change the <em>cascading delete</em> behavior of all references of the
100      * specified class while this transaction is in use.
101      *
102      * @param target The class to change cascading delete behavior of all references.
103      * @param doCascade If <em>true</em> cascading delete is enabled, <em>false</em> disabled.
104      */

105     public void setCascadingDelete(Class JavaDoc target, boolean doCascade);
106
107     /**
108      * Return <em>true</em> if the OJB ordering algorithm is enabled.
109      * @see #setOrdering(boolean)
110      */

111     public boolean isOrdering();
112
113     /**
114      * Allows to enable/disable the OJB persistent object ordering algorithm. If
115      * <em>true</em> OJB try to order the modified/new/deleted objects in a correct order
116      * (based on a algorithm) before the objects are written to the persistent storage.
117      * <br/>
118      * If the used databases support 'deferred checks' it's recommended to
119      * use this feature and to disable OJB's object ordering.
120      * <p/>
121      * If <em>false</em> the order of the objects rely on the order specified by
122      * the user and on settings like {@link #setImplicitLocking(boolean)}.
123      *
124      * @param ordering Set <em>true</em> to enable object ordering on commit.
125      * @see ImplementationExt#setOrdering(boolean)
126      */

127     public void setOrdering(boolean ordering);
128
129 // /**
130
// * Returns whether or not the persistent method calls determine
131
// * the persistent object order on commit.
132
// *
133
// * @see #setNoteUserOrder(boolean)
134
// */
135
// public boolean isNoteUserOrder();
136
//
137
// /**
138
// * If <em>true</em> the order of persisting method calls like
139
// * <br/> - {@link org.odmg.Transaction#lock(Object, int)}).
140
// * <br/> - {@link org.odmg.Database#deletePersistent(Object)}).
141
// * <br/> - {@link org.odmg.Database#makePersistent(Object)})
142
// * determine the order of objects before commit.
143
// * <br/>
144
// * If <em>false</em> the ordering was determined by OJB's internal
145
// * method calls and user calls.
146
// * <br/>
147
// * However it's possible to set this value as a global property
148
// * for all transactions using {@link ImplementationExt#setNoteUserOrder(boolean)}.
149
// * <p/>
150
// * <strong>NOTE:</strong> If OJB's ordering algorithm (see
151
// * {@link #setOrdering(boolean)}) is enabled, the
152
// * order of objects may change on commit.
153
// *
154
// * @param noteUserOrder If <em>true</em> the order of persisting
155
// * method calls determine the order of objects.
156
// * @see ImplementationExt#setNoteUserOrder(boolean)
157
// */
158
// public void setNoteUserOrder(boolean noteUserOrder);
159

160     /**
161      * Checks if the object with the given {@link org.apache.ojb.broker.Identity}
162      * has been deleted within the transaction using
163      * {@link org.odmg.Database#deletePersistent(Object)} or {@link #markDelete(Object)}.
164      *
165      * @param id The identity of the object.
166      * @return <em>true</em> if the object has been deleted within the transaction.
167      */

168     public boolean isDeleted(Identity id);
169 }
170
Popular Tags