diff --git a/api/src/main/java/jakarta/persistence/ExcludeFromVersioning.java b/api/src/main/java/jakarta/persistence/ExcludeFromVersioning.java new file mode 100644 index 00000000..1607c632 --- /dev/null +++ b/api/src/main/java/jakarta/persistence/ExcludeFromVersioning.java @@ -0,0 +1,42 @@ +/* + * Copyright (c) 2008, 2024 Oracle and/or its affiliates. All rights reserved. + * + * This program and the accompanying materials are made available under the + * terms of the Eclipse Public License v. 2.0 which is available at + * http://www.eclipse.org/legal/epl-2.0, + * or the Eclipse Distribution License v. 1.0 which is available at + * http://www.eclipse.org/org/documents/edl-v10.php. + * + * SPDX-License-Identifier: EPL-2.0 OR BSD-3-Clause + */ + +// Contributors: +// Gavin King - 4.0 + +package jakarta.persistence; + +import java.lang.annotation.Retention; +import java.lang.annotation.Target; + +import static java.lang.annotation.ElementType.FIELD; +import static java.lang.annotation.ElementType.METHOD; +import static java.lang.annotation.RetentionPolicy.RUNTIME; + +/** + * Specifies that mutation of the annotated field or property does + * not result in incrementation of the {@linkplain Version version + * field or property} of the entity. + *

+ * This annotation indicates that the application tolerates lost + * updates to the annotated field or property when concurrent + * optimistic transactions modify the same entity instance, and + * that no {@link OptimisticLockException} should occur in this + * scenario. + * + * @see Version + * + * @since 4.0 + */ +@Target({METHOD, FIELD}) +@Retention(RUNTIME) +public @interface ExcludeFromVersioning {} diff --git a/api/src/main/java/jakarta/persistence/Version.java b/api/src/main/java/jakarta/persistence/Version.java index 5fdda757..eb45d780 100644 --- a/api/src/main/java/jakarta/persistence/Version.java +++ b/api/src/main/java/jakarta/persistence/Version.java @@ -67,6 +67,7 @@ * * @see LockModeType * @see PersistenceUnitUtil#getVersion(Object) + * @see ExcludeFromVersioning * * @since 1.0 */