001: package org.apache.ojb.odmg;
002:
003: /* Copyright 2003-2005 The Apache Software Foundation
004: *
005: * Licensed under the Apache License, Version 2.0 (the "License");
006: * you may not use this file except in compliance with the License.
007: * You may obtain a copy of the License at
008: *
009: * http://www.apache.org/licenses/LICENSE-2.0
010: *
011: * Unless required by applicable law or agreed to in writing, software
012: * distributed under the License is distributed on an "AS IS" BASIS,
013: * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
014: * See the License for the specific language governing permissions and
015: * limitations under the License.
016: */
017:
018: import org.odmg.Transaction;
019: import org.apache.ojb.broker.Identity;
020:
021: /**
022: * Offers useful none odmg-standard methods of the odmg {@link org.odmg.Transaction} interface.
023: * <p>
024: * Note: All listed methods are <strong>not</strong> part of the standard ODMG-api -
025: * they are special (proprietary) OJB extensions.
026: * </p>
027: *
028: * @version $Id: TransactionExt.java,v 1.4.2.8 2005/12/21 22:29:21 tomdz Exp $
029: */
030: public interface TransactionExt extends Transaction, HasBroker {
031: /**
032: * Marks an object for deletion without
033: * locking the object. If the object wasn't locked before,
034: * OJB will ask for a WRITE lock at commit.
035: *
036: * @param anObject Object to be marked
037: */
038: public void markDelete(Object anObject);
039:
040: /**
041: * Marks an object as dirty without
042: * locking the object. If the object wasn't locked before,
043: * OJB will ask for a WRITE lock at commit.
044: *
045: * @param anObject Object to be marked
046: */
047: public void markDirty(Object anObject);
048:
049: /**
050: * <p>
051: * Calling <code>flush</code> flushes persistent object modifications
052: * made within the ODMG transaction since the last checkpoint to the underlying
053: * database transaction, but does <b<not</b> commit the database transaction.
054: * The ODMG transaction retains all locks it held on those objects at the time the flush
055: * was invoked.
056: * <p/>
057: * This method is very similair to {@link org.odmg.Transaction#checkpoint}.
058: */
059: public void flush();
060:
061: /**
062: * This method can be used to activate or deactivate the implicit
063: * locking mechanism for the current transaction.
064: * <br/>
065: * If set <em>true</em> OJB implicitly locks objects to ODMG transactions
066: * after performing OQL queries. Also if implicit locking is used
067: * locking objects is recursive, that is associated objects are also
068: * locked. If ImplicitLocking is set to 'false', no locks are obtained
069: * in OQL queries, lookup objects and there is also no recursive locking.
070: * <p/>
071: * Turning off implicit locking may improve performance but requires
072: * additional care to make sure all changed objects are properly
073: * registered to the transaction.
074: *
075: * @param value If set <em>true</em> implicit locking is enabled,
076: * if <em>false</em>, implicit locking is disabled.
077: * @see ImplementationExt#setImplicitLocking(boolean)
078: **/
079: public void setImplicitLocking(boolean value);
080:
081: /**
082: * Returns <em>true</em> if implicite locking is enabled.
083: * @see #setImplicitLocking(boolean)
084: */
085: public boolean isImplicitLocking();
086:
087: /**
088: * Allows to change the <em>cascading delete</em> behavior of the target class's
089: * reference field while this transaction is in use.
090: *
091: * @param target The class to change cascading delete behavior of the references.
092: * @param referenceField The field name of the 1:1, 1:n or m:n reference.
093: * @param doCascade If <em>true</em> cascading delete is enabled, <em>false</em> disabled.
094: */
095: public void setCascadingDelete(Class target, String referenceField,
096: boolean doCascade);
097:
098: /**
099: * 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 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: }
|