KickJava   Java API By Example, From Geeks To Geeks.

Java > Open Source Codes > oracle > toplink > essentials > queryframework > UpdateObjectQuery


1 /*
2  * The contents of this file are subject to the terms
3  * of the Common Development and Distribution License
4  * (the "License"). You may not use this file except
5  * in compliance with the License.
6  *
7  * You can obtain a copy of the license at
8  * glassfish/bootstrap/legal/CDDLv1.0.txt or
9  * https://glassfish.dev.java.net/public/CDDLv1.0.html.
10  * See the License for the specific language governing
11  * permissions and limitations under the License.
12  *
13  * When distributing Covered Code, include this CDDL
14  * HEADER in each file and include the License file at
15  * glassfish/bootstrap/legal/CDDLv1.0.txt. If applicable,
16  * add the following below this CDDL HEADER, with the
17  * fields enclosed by brackets "[]" replaced with your
18  * own identifying information: Portions Copyright [yyyy]
19  * [name of copyright owner]
20  */

21 // Copyright (c) 1998, 2005, Oracle. All rights reserved.
22
package oracle.toplink.essentials.queryframework;
23
24 import oracle.toplink.essentials.exceptions.*;
25
26 /**
27  * <p><b>Purpose</b>:
28  * Used for updating existing objects into the database.
29  * This class does not have much behavior.
30  * It inherits most of it's behavior from WriteObjectQuery
31  *
32  * @author Yvon Lavoie
33  * @since TOPLink/Java 1.0
34  */

35 public class UpdateObjectQuery extends WriteObjectQuery {
36
37     /**
38      * PUBLIC:
39      * Default constructor.
40      */

41     public UpdateObjectQuery() {
42         super();
43     }
44
45     /**
46      * PUBLIC:
47      * Create an update query with the object being updated.
48      */

49     public UpdateObjectQuery(Object JavaDoc objectToUpdate) {
50         this();
51         setObject(objectToUpdate);
52     }
53
54     /**
55      * PUBLIC:
56      * Create an update query with the custom call.
57      */

58     public UpdateObjectQuery(Call call) {
59         this();
60         setCall(call);
61     }
62
63     /**
64      * INTERNAL:
65      * Perform an update.
66      */

67     public void executeCommit() throws DatabaseException, OptimisticLockException {
68         getQueryMechanism().updateObjectForWrite();
69     }
70     
71     /**
72      * INTERNAL:
73      * Perform an update.
74      */

75     public void executeCommitWithChangeSet() throws DatabaseException, OptimisticLockException {
76         getQueryMechanism().updateObjectForWriteWithChangeSet();
77     }
78
79     /**
80      * INTERNAL:
81      * Prepare the receiver for execution in a session.
82      */

83     protected void prepare() {
84         super.prepare();
85
86         getQueryMechanism().prepareUpdateObject();
87     }
88
89     /**
90      * PUBLIC:
91      * Return if this is an update object query.
92      */

93     public boolean isUpdateObjectQuery() {
94         return true;
95     }
96 }
97
Popular Tags