01: /*
02: * Enhydra Java Application Server Project
03: *
04: * The contents of this file are subject to the Enhydra Public License
05: * Version 1.1 (the "License"); you may not use this file except in
06: * compliance with the License. You may obtain a copy of the License on
07: * the Enhydra web site ( http://www.enhydra.org/ ).
08: *
09: * Software distributed under the License is distributed on an "AS IS"
10: * basis, WITHOUT WARRANTY OF ANY KIND, either express or implied. See
11: * the License for the specific terms governing rights and limitations
12: * under the License.
13: *
14: * The Initial Developer of the Enhydra Application Server is Lutris
15: * Technologies, Inc. The Enhydra Application Server and portions created
16: * by Lutris Technologies, Inc. are Copyright Lutris Technologies, Inc.
17: * All Rights Reserved.
18: *
19: * Contributor(s):
20: *
21: * $Id: Transaction.java,v 1.1 2007-01-24 16:59:09 sinisa Exp $
22: */
23: package com.lutris.appserver.server.sql;
24:
25: import java.sql.SQLException;
26:
27: /**
28: * Interface that must be implemented by objects accessed by DBTransaction.
29: *
30: * @author Kyle Clark
31: * @version $Revision: 1.1 $
32: * @see DBTransaction
33: */
34: public interface Transaction {
35:
36: /**
37: * Method to insert a new object into the database.
38: *
39: * @param conn Database connection.
40: * @exception java.sql.SQLException If a database access error
41: * occurs.
42: */
43: public void executeInsert(DBConnection conn) throws SQLException;
44:
45: /**
46: * If this object's <code>executeInsert</code> method was
47: * called then <code>finalizeInsert</code> is called with
48: * the status of the database transaction. This method
49: * allows the data object to perform any post processing
50: * if the transaction succeeded or failed.
51: *
52: * @param success true if the transaction succeeded
53: * and this object was successfully inserted into the database.
54: */
55: public void finalizeInsert(boolean success);
56:
57: /**
58: * Method to update contents of object in database.
59: *
60: * @param conn Database connection.
61: * @exception java.sql.SQLException If a database access error
62: * occurs.
63: */
64: public void executeUpdate(DBConnection conn) throws SQLException;
65:
66: /**
67: * If this object's <code>executeUpdate</code> method was
68: * called then <code>finalizeUpdate</code> is called with
69: * the status of the database transaction.
70: * For instance the data object may want to
71: * increment its version number once it has successfully
72: * been commited to the database.
73: *
74: * @param success true if the transaction succeeded
75: * and this object was successfully updated in the database.
76: */
77: public void finalizeUpdate(boolean success);
78:
79: /**
80: * Method to delete an object from the database.
81: *
82: * @param conn Database connection.
83: * @exception java.sql.SQLException If a database access error
84: * occurs.
85: */
86: public void executeDelete(DBConnection conn) throws SQLException;
87:
88: /**
89: * If this object's <code>executeDelete</code> method was
90: * called then <code>finalizeDelete</code> is called with
91: * the status of the database transaction.
92: *
93: * @param success true if the transaction succeeded
94: * and this object was successfully deleted from the
95: * database.
96: */
97: public void finalizeDelete(boolean success);
98: }
|