001: /*
002: * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS HEADER.
003: *
004: * Copyright 1997-2007 Sun Microsystems, Inc. All rights reserved.
005: *
006: * The contents of this file are subject to the terms of either the GNU
007: * General Public License Version 2 only ("GPL") or the Common Development
008: * and Distribution License("CDDL") (collectively, the "License"). You
009: * may not use this file except in compliance with the License. You can obtain
010: * a copy of the License at https://glassfish.dev.java.net/public/CDDL+GPL.html
011: * or glassfish/bootstrap/legal/LICENSE.txt. See the License for the specific
012: * language governing permissions and limitations under the License.
013: *
014: * When distributing the software, include this License Header Notice in each
015: * file and include the License file at glassfish/bootstrap/legal/LICENSE.txt.
016: * Sun designates this particular file as subject to the "Classpath" exception
017: * as provided by Sun in the GPL Version 2 section of the License file that
018: * accompanied this code. If applicable, add the following below the License
019: * Header, with the fields enclosed by brackets [] replaced by your own
020: * identifying information: "Portions Copyrighted [year]
021: * [name of copyright owner]"
022: *
023: * Contributor(s):
024: *
025: * If you wish your version of this file to be governed by only the CDDL or
026: * only the GPL Version 2, indicate your decision by adding "[Contributor]
027: * elects to include this software in this distribution under the [CDDL or GPL
028: * Version 2] license." If you don't indicate a single choice of license, a
029: * recipient has the option to distribute your version of this file under
030: * either the CDDL, the GPL Version 2 or to extend the choice of license to
031: * its licensees as provided above. However, if you add GPL Version 2 code
032: * and therefore, elected the GPL Version 2 license, then the option applies
033: * only if the new code is made subject to such option by the copyright
034: * holder.
035: */
036: package javax.persistence;
037:
038: /**
039: * Thrown by the persistence provider when an optimistic locking conflict
040: * occurs. This exception may be thrown as part of an API call, a flush or at
041: * commit time. The current transaction, if one is active, will be marked for
042: * rollback.
043: *
044: * @since Java Persistence 1.0
045: */
046: public class OptimisticLockException extends PersistenceException {
047:
048: /** The object that caused the exception */
049: Object entity;
050:
051: /**
052: * Constructs a new <code>OptimisticLockException</code> exception
053: * with <code>null</code> as its detail message.
054: */
055: public OptimisticLockException() {
056: super ();
057: }
058:
059: /**
060: * Constructs a new <code>OptimisticLockException</code> exception
061: * with the specified detail message.
062: * @param message the detail message.
063: */
064: public OptimisticLockException(String message) {
065: super (message);
066: }
067:
068: /**
069: * Constructs a new <code>OptimisticLockException</code> exception
070: * with the specified detail message and cause.
071: * @param message the detail message.
072: * @param cause the cause.
073: */
074: public OptimisticLockException(String message, Throwable cause) {
075: super (message, cause);
076: }
077:
078: /**
079: * Constructs a new <code>OptimisticLockException</code> exception
080: * with the specified cause.
081: * @param cause the cause.
082: */
083: public OptimisticLockException(Throwable cause) {
084: super (cause);
085: }
086:
087: /**
088: * Constructs a new <code>OptimisticLockException</code> exception
089: * with the specified entity.
090: * @param entity the entity.
091: */
092: public OptimisticLockException(Object entity) {
093: this .entity = entity;
094: }
095:
096: /**
097: * Constructs a new <code>OptimisticLockException</code> exception
098: * with the specified detail message, cause, and entity.
099: * @param message the detail message.
100: * @param cause the cause.
101: * @param entity the entity.
102: */
103: public OptimisticLockException(String message, Throwable cause,
104: Object entity) {
105: super (message, cause);
106: this .entity = entity;
107: }
108:
109: /**
110: * Returns the entity that caused this exception.
111: * @return the entity.
112: */
113: public Object getEntity() {
114: return this.entity;
115: }
116:
117: };
|