HHH-16666 give @FetchOverride.mode a default (the only supported value!)

Talk about low-hanging fruit!
This commit is contained in:
Gavin 2023-05-22 17:07:51 +02:00 committed by Gavin King
parent f2dbe7a9cb
commit 36a77785e8
12 changed files with 24 additions and 24 deletions

View File

@ -13,6 +13,7 @@ import java.lang.annotation.Target;
import static java.lang.annotation.ElementType.PACKAGE;
import static java.lang.annotation.ElementType.TYPE;
import static java.lang.annotation.RetentionPolicy.RUNTIME;
import static org.hibernate.annotations.FetchMode.JOIN;
/**
* Defines a fetch profile, by specifying its {@link #name}, together
@ -112,6 +113,6 @@ public @interface FetchProfile {
* The {@linkplain FetchMode fetching strategy} to apply to
* the association in the fetch profile being defined.
*/
FetchMode mode();
FetchMode mode() default JOIN;
}
}

View File

@ -26,13 +26,13 @@ import org.hibernate.annotations.FetchProfile;
*/
@Entity
@FetchProfile(name = "customer-with-orders", fetchOverrides = {
@FetchProfile.FetchOverride(entity = Customer.class, association = "orders", mode = FetchMode.JOIN)
@FetchProfile.FetchOverride(entity = Customer.class, association = "orders")
})
@FetchProfile(name = "customer-with-orders-and-country",
fetchOverrides = {
@FetchProfile.FetchOverride(entity = Customer.class, association = "orders", mode = FetchMode.JOIN),
@FetchProfile.FetchOverride(entity = Customer.class, association = "lastOrder", mode = FetchMode.JOIN),
@FetchProfile.FetchOverride(entity = Order.class, association = "country", mode = FetchMode.JOIN)
@FetchProfile.FetchOverride(entity = Customer.class, association = "orders"),
@FetchProfile.FetchOverride(entity = Customer.class, association = "lastOrder"),
@FetchProfile.FetchOverride(entity = Order.class, association = "country")
})
public class Customer {
@Id

View File

@ -23,7 +23,7 @@ import org.hibernate.annotations.FetchProfile;
*/
@Entity
@FetchProfile(name = "customer-with-orders", fetchOverrides = {
@FetchProfile.FetchOverride(entity = Customer2.class, association = "foo", mode = FetchMode.JOIN)
@FetchProfile.FetchOverride(entity = Customer2.class, association = "foo")
})
public class Customer2 {
@Id

View File

@ -23,7 +23,7 @@ import org.hibernate.annotations.FetchProfile;
*/
@Entity
@FetchProfile(name = "wrong-class-name", fetchOverrides = {
@FetchProfile.FetchOverride(entity = Order.class, association = "orders", mode = FetchMode.JOIN)
@FetchProfile.FetchOverride(entity = Order.class, association = "orders")
})
public class Customer3 {
@Id

View File

@ -23,7 +23,7 @@ import org.hibernate.annotations.FetchProfile;
*/
@Entity
@FetchProfile(name = "orders-profile", fetchOverrides = {
@FetchProfile.FetchOverride(entity = Customer5.class, association = "foo", mode = FetchMode.JOIN)
@FetchProfile.FetchOverride(entity = Customer5.class, association = "foo")
})
public class Customer5 {
@Id

View File

@ -12,7 +12,7 @@ import jakarta.persistence.OneToOne;
@Entity
@FetchProfile(name = "customer-with-address", fetchOverrides = {
@FetchProfile.FetchOverride(entity = Customer6.class, association = "address", mode = FetchMode.JOIN)
@FetchProfile.FetchOverride(entity = Customer6.class, association = "address")
})
public class Customer6 {

View File

@ -24,7 +24,7 @@ import static org.junit.jupiter.api.Assertions.assertTrue;
@DomainModel(annotatedClasses = {NewFetchTest.class,NewFetchTest.E.class, NewFetchTest.F.class, NewFetchTest.G.class})
@FetchProfile(name = NewFetchTest.NEW_PROFILE)
@FetchProfile(name = NewFetchTest.OLD_PROFILE,
fetchOverrides = @FetchProfile.FetchOverride(entity = NewFetchTest.E.class, association = "f", mode = JOIN))
fetchOverrides = @FetchProfile.FetchOverride(entity = NewFetchTest.E.class, association = "f"))
public class NewFetchTest {
public static final String NEW_PROFILE = "new-profile";

View File

@ -1,11 +1,10 @@
@FetchProfile(name = "mappedBy-package-profile-1", fetchOverrides = {
@FetchProfile.FetchOverride(entity = Address.class, association = "customer", mode = FetchMode.JOIN)
@FetchProfile.FetchOverride(entity = Address.class, association = "customer")
})
@FetchProfile(name = "mappedBy-package-profile-2", fetchOverrides = {
@FetchProfile.FetchOverride(entity = Customer6.class, association = "address", mode = FetchMode.JOIN)
@FetchProfile.FetchOverride(entity = Customer6.class, association = "address")
})
package org.hibernate.orm.test.annotations.fetchprofile.mappedby;
import org.hibernate.annotations.FetchMode;
import org.hibernate.annotations.FetchProfile;
import org.hibernate.orm.test.annotations.fetchprofile.Customer6;

View File

@ -8,10 +8,10 @@
// $Id$
@FetchProfile(name = "package-profile-1", fetchOverrides = {
@FetchProfile.FetchOverride(entity = Customer.class, association = "orders", mode = FetchMode.JOIN)
@FetchProfile.FetchOverride(entity = Customer.class, association = "orders")
})
@FetchProfile(name = "package-profile-2", fetchOverrides = {
@FetchProfile.FetchOverride(entity = Customer.class, association = "tickets", mode = FetchMode.JOIN)
@FetchProfile.FetchOverride(entity = Customer.class, association = "tickets")
})
package org.hibernate.orm.test.annotations.fetchprofile;

View File

@ -105,7 +105,7 @@ public class CollectionLoadedInTwoPhaseLoadTest extends BaseCoreFunctionalTestCa
@Entity(name = "OrgUnit")
@FetchProfile(name = FETCH_PROFILE_NAME, fetchOverrides = {
@FetchProfile.FetchOverride(entity = OrgUnit.class, association = "people", mode = FetchMode.JOIN)
@FetchProfile.FetchOverride(entity = OrgUnit.class, association = "people")
})
public static class OrgUnit {
@ -194,7 +194,7 @@ public class CollectionLoadedInTwoPhaseLoadTest extends BaseCoreFunctionalTestCa
@Entity(name = "Person")
@FetchProfile(name = FETCH_PROFILE_NAME_2, fetchOverrides = {
@FetchProfile.FetchOverride(entity = Person.class, association = "orgUnits", mode = FetchMode.JOIN)
@FetchProfile.FetchOverride(entity = Person.class, association = "orgUnits")
})
public static class Person {

View File

@ -119,7 +119,7 @@ public class EntityLoadedInTwoPhaseLoadTest extends BaseCoreFunctionalTestCase {
@Entity(name = "MidEntity")
@FetchProfile(name = FETCH_PROFILE_NAME, fetchOverrides = {
@FetchProfile.FetchOverride(entity = Mid.class, association = "finish", mode = FetchMode.JOIN)
@FetchProfile.FetchOverride(entity = Mid.class, association = "finish")
})
public static class Mid {
@ -157,8 +157,8 @@ public class EntityLoadedInTwoPhaseLoadTest extends BaseCoreFunctionalTestCase {
@Entity(name = "StartEntity")
@FetchProfile(name = FETCH_PROFILE_NAME, fetchOverrides = {
@FetchProfile.FetchOverride(entity = Start.class, association = "via1", mode = FetchMode.JOIN),
@FetchProfile.FetchOverride(entity = Start.class, association = "via2", mode = FetchMode.JOIN)
@FetchProfile.FetchOverride(entity = Start.class, association = "via1"),
@FetchProfile.FetchOverride(entity = Start.class, association = "via2")
})
public static class Start {
@ -208,7 +208,7 @@ public class EntityLoadedInTwoPhaseLoadTest extends BaseCoreFunctionalTestCase {
@Entity(name = "Via1Entity")
@FetchProfile(name = FETCH_PROFILE_NAME, fetchOverrides = {
@FetchProfile.FetchOverride(entity = Via1.class, association = "mid", mode = FetchMode.JOIN)
@FetchProfile.FetchOverride(entity = Via1.class, association = "mid")
})
public static class Via1 {
@ -246,7 +246,7 @@ public class EntityLoadedInTwoPhaseLoadTest extends BaseCoreFunctionalTestCase {
@Entity(name = "Via2Entity")
@FetchProfile(name = FETCH_PROFILE_NAME, fetchOverrides = {
@FetchProfile.FetchOverride(entity = Via2.class, association = "mid", mode = FetchMode.JOIN)
@FetchProfile.FetchOverride(entity = Via2.class, association = "mid")
})
public static class Via2 {

View File

@ -25,8 +25,8 @@ import org.hibernate.annotations.FetchProfile;
@FetchProfile(
name = Employee.FETCH_PROFILE_TREE,
fetchOverrides = {
@FetchProfile.FetchOverride(entity = Employee.class, association = "manager", mode = FetchMode.JOIN),
@FetchProfile.FetchOverride(entity = Employee.class, association = "minions", mode = FetchMode.JOIN)
@FetchProfile.FetchOverride(entity = Employee.class, association = "manager"),
@FetchProfile.FetchOverride(entity = Employee.class, association = "minions")
}
)
public class Employee {