001/*
002 * Copyright (c) 2008, 2009, 2011 Oracle, Inc. All rights reserved.
003 *
004 * This program and the accompanying materials are made available under the
005 * terms of the Eclipse Public License v1.0 and Eclipse Distribution License v. 1.0
006 * which accompanies this distribution.  The Eclipse Public License is available
007 * at http://www.eclipse.org/legal/epl-v10.html and the Eclipse Distribution License
008 * is available at http://www.eclipse.org/org/documents/edl-v10.php.
009 */
010package javax.persistence;
011
012/**
013 * Thrown by the persistence provider when {@link EntityManager#persist(Object)
014 * EntityManager.persist(Object)} is called and the entity already exists. The
015 * current transaction, if one is active, will be marked for rollback.
016 * <p>
017 * If the entity already exists, the <code>EntityExistsException</code> may be thrown when
018 * the persist operation is invoked, or the <code>EntityExistsException</code> or another
019 * <code>PersistenceException</code> may be thrown at flush or commit time.
020 * <p> The current transaction, if one is active, will be marked for rollback.
021 *
022 * @see javax.persistence.EntityManager#persist(Object)
023 * @since Java Persistence 1.0
024 */
025public class EntityExistsException extends PersistenceException {
026
027  /**
028   * Constructs a new <code>EntityExistsException</code> exception with
029   * <code>null</code> as its detail message.
030   */
031  public EntityExistsException() {
032    super();
033  }
034
035  /**
036   * Constructs a new <code>EntityExistsException</code> exception with the
037   * specified detail message.
038   *
039   * @param message the detail message.
040   */
041  public EntityExistsException(String message) {
042    super(message);
043  }
044
045  /**
046   * Constructs a new <code>EntityExistsException</code> exception with the
047   * specified detail message and cause.
048   *
049   * @param message the detail message.
050   * @param cause   the cause.
051   */
052  public EntityExistsException(String message, Throwable cause) {
053    super(message, cause);
054  }
055
056  /**
057   * Constructs a new <code>EntityExistsException</code> exception with the
058   * specified cause.
059   *
060   * @param cause the cause.
061   */
062  public EntityExistsException(Throwable cause) {
063    super(cause);
064  }
065}