improve javadoc for @JoinFormula-related stuff

This commit is contained in:
Gavin King 2022-01-19 13:33:25 +01:00
parent 47c695bace
commit 101de70289
3 changed files with 22 additions and 9 deletions

View File

@ -16,8 +16,14 @@ import static java.lang.annotation.ElementType.METHOD;
import static java.lang.annotation.RetentionPolicy.RUNTIME; import static java.lang.annotation.RetentionPolicy.RUNTIME;
/** /**
* Allows joins based on column or a formula. One of {@link #formula()} or {@link #column()} should be * Specifies one element of a {@linkplain JoinColumnsOrFormulas composite join condition}
* specified, but not both. * involving both {@linkplain JoinFormula formulas} and {@linkplain JoinColumn columns}.
* One of {@link #formula()} or {@link #column()} must be specified, but not both. If a
* composite join condition involves only columns, this annotation is unnecessary.
*
* @see JoinColumnsOrFormulas
* @see JoinFormula
* @see JoinColumn
* *
* @author Sharath Reddy * @author Sharath Reddy
*/ */
@ -26,12 +32,12 @@ import static java.lang.annotation.RetentionPolicy.RUNTIME;
@Repeatable(JoinColumnsOrFormulas.class) @Repeatable(JoinColumnsOrFormulas.class)
public @interface JoinColumnOrFormula { public @interface JoinColumnOrFormula {
/** /**
* The formula to use in joining. * The formula to use in the join condition.
*/ */
JoinFormula formula() default @JoinFormula(value="", referencedColumnName=""); JoinFormula formula() default @JoinFormula(value="", referencedColumnName="");
/** /**
* The column to use in joining. * The column to use in the join condition.
*/ */
JoinColumn column() default @JoinColumn(); JoinColumn column() default @JoinColumn();
} }

View File

@ -6,6 +6,8 @@
*/ */
package org.hibernate.annotations; package org.hibernate.annotations;
import jakarta.persistence.JoinColumn;
import java.lang.annotation.Retention; import java.lang.annotation.Retention;
import java.lang.annotation.Target; import java.lang.annotation.Target;
@ -14,15 +16,20 @@ import static java.lang.annotation.ElementType.METHOD;
import static java.lang.annotation.RetentionPolicy.RUNTIME; import static java.lang.annotation.RetentionPolicy.RUNTIME;
/** /**
* Collection of {@code @JoinColumnOrFormula} definitions. * Specifies a composite join condition involving one or more {@linkplain JoinFormula formulas}
* and, optionally, one or more {@linkplain JoinColumn columns}. If a join condition has just
* one column or formula, or involves only columns, this annotation is unnecessary.
* *
* @author Sharath Reddy * @author Sharath Reddy
*
* @see JoinColumnOrFormula
* @see jakarta.persistence.JoinColumns
*/ */
@Target({METHOD, FIELD}) @Target({METHOD, FIELD})
@Retention(RUNTIME) @Retention(RUNTIME)
public @interface JoinColumnsOrFormulas { public @interface JoinColumnsOrFormulas {
/** /**
* The aggregated values. * A list of columns and formulas to use in the join condition.
*/ */
JoinColumnOrFormula[] value(); JoinColumnOrFormula[] value();
} }

View File

@ -14,8 +14,8 @@ import static java.lang.annotation.ElementType.METHOD;
import static java.lang.annotation.RetentionPolicy.RUNTIME; import static java.lang.annotation.RetentionPolicy.RUNTIME;
/** /**
* To be used as a replacement for {@code @JoinColumn} in most places. The formula has to be a valid * Specifies a join condition based on an arbitrary native SQL formula
* SQL fragment * instead of a {@linkplain jakarta.persistence.JoinColumn column name}.
* *
* @author Sharath Reddy * @author Sharath Reddy
*/ */
@ -23,7 +23,7 @@ import static java.lang.annotation.RetentionPolicy.RUNTIME;
@Retention(RUNTIME) @Retention(RUNTIME)
public @interface JoinFormula { public @interface JoinFormula {
/** /**
* The formula. * The formula, in native SQL.
*/ */
String value(); String value();