KickJava   Java API By Example, From Geeks To Geeks.

Java > Open Source Codes > javax > persistence > OptimisticLockException


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 in
5  * compliance with the License.
6  *
7  * You can obtain a copy of the license at
8  * https://glassfish.dev.java.net/public/CDDLv1.0.html or
9  * glassfish/bootstrap/legal/CDDLv1.0.txt.
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 Notice in each file and include the License file
15  * at glassfish/bootstrap/legal/CDDLv1.0.txt.
16  * If applicable, add the following below the CDDL Header,
17  * with the fields enclosed by brackets [] replaced by
18  * you own identifying information:
19  * "Portions Copyrighted [year] [name of copyright owner]"
20  *
21  * Copyright 2006 Sun Microsystems, Inc. All rights reserved.
22  */

23 package javax.persistence;
24
25 /**
26  * Thrown by the persistence provider when an optimistic locking conflict
27  * occurs. This exception may be thrown as part of an API call, a flush or at
28  * commit time. The current transaction, if one is active, will be marked for
29  * rollback.
30  *
31  * @since Java Persistence 1.0
32  */

33 public class OptimisticLockException extends PersistenceException {
34     
35     /** The object that caused the exception */
36     Object JavaDoc entity;
37
38     /**
39      * Constructs a new <code>OptimisticLockException</code> exception
40      * with <code>null</code> as its detail message.
41      */

42     public OptimisticLockException() {
43         super();
44     }
45
46     /**
47      * Constructs a new <code>OptimisticLockException</code> exception
48      * with the specified detail message.
49      * @param message the detail message.
50      */

51     public OptimisticLockException(String JavaDoc message) {
52         super(message);
53     }
54
55     /**
56      * Constructs a new <code>OptimisticLockException</code> exception
57      * with the specified detail message and cause.
58      * @param message the detail message.
59      * @param cause the cause.
60      */

61     public OptimisticLockException(String JavaDoc message, Throwable JavaDoc cause) {
62         super(message, cause);
63     }
64
65     /**
66      * Constructs a new <code>OptimisticLockException</code> exception
67      * with the specified cause.
68      * @param cause the cause.
69      */

70     public OptimisticLockException(Throwable JavaDoc cause) {
71         super(cause);
72     }
73
74     /**
75      * Constructs a new <code>OptimisticLockException</code> exception
76      * with the specified entity.
77      * @param entity the entity.
78      */

79     public OptimisticLockException(Object JavaDoc entity) {
80         this.entity = entity;
81     }
82
83     /**
84      * Constructs a new <code>OptimisticLockException</code> exception
85      * with the specified detail message, cause, and entity.
86      * @param message the detail message.
87      * @param cause the cause.
88      * @param entity the entity.
89      */

90     public OptimisticLockException(String JavaDoc message, Throwable JavaDoc cause, Object JavaDoc entity) {
91         super(message, cause);
92         this.entity = entity;
93     }
94     
95     /**
96      * Returns the entity that caused this exception.
97      * @return the entity.
98      */

99     public Object JavaDoc getEntity() {
100         return this.entity;
101     }
102
103 };
104
105
Popular Tags