HHH-16163 update tests to use new annotations

This commit is contained in:
Gavin 2023-04-08 01:43:08 +02:00 committed by Gavin King
parent e6c8fbc7af
commit 7b8cd14052
44 changed files with 158 additions and 157 deletions

View File

@ -13,7 +13,7 @@ import jakarta.persistence.Enumerated;
import jakarta.persistence.GeneratedValue; import jakarta.persistence.GeneratedValue;
import jakarta.persistence.Id; import jakarta.persistence.Id;
import org.hibernate.annotations.Where; import org.hibernate.annotations.SQLRestriction;
/** /**
* *
@ -21,7 +21,7 @@ import org.hibernate.annotations.Where;
* *
*/ */
@Entity @Entity
@Where(clause = "yearsExperience > 3") @SQLRestriction("yearsExperience > 3")
public class Doctor { public class Doctor {
private Integer id; private Integer id;
private String name; private String name;

View File

@ -17,7 +17,7 @@ import jakarta.persistence.Id;
import jakarta.persistence.OneToMany; import jakarta.persistence.OneToMany;
import jakarta.persistence.OneToOne; import jakarta.persistence.OneToOne;
import org.hibernate.annotations.Where; import org.hibernate.annotations.SQLRestriction;
@Entity @Entity
public class SoccerTeam { public class SoccerTeam {
@ -28,7 +28,7 @@ public class SoccerTeam {
String name; String name;
@OneToMany @OneToMany
@Where(clause = "activeLicense = true") @SQLRestriction("activeLicense = true")
private List<Doctor> physiologists = new ArrayList<Doctor>(); private List<Doctor> physiologists = new ArrayList<Doctor>();
@OneToMany(mappedBy="team", @OneToMany(mappedBy="team",

View File

@ -18,8 +18,8 @@ import jakarta.persistence.Table;
import org.hibernate.annotations.Filter; import org.hibernate.annotations.Filter;
import org.hibernate.annotations.FilterDef; import org.hibernate.annotations.FilterDef;
import org.hibernate.annotations.FilterJoinTable; import org.hibernate.annotations.FilterJoinTable;
import org.hibernate.annotations.Where; import org.hibernate.annotations.SQLJoinTableRestriction;
import org.hibernate.annotations.WhereJoinTable; import org.hibernate.annotations.SQLRestriction;
/** /**
* @author Emmanuel Bernard * @author Emmanuel Bernard
@ -42,8 +42,8 @@ public class Group {
@ManyToMany(cascade = CascadeType.PERSIST) @ManyToMany(cascade = CascadeType.PERSIST)
@OrderBy("expirationDate") @OrderBy("expirationDate")
@Where(clause = "1=1") @SQLRestriction("1=1")
@WhereJoinTable(clause = "2=2") @SQLJoinTableRestriction("2=2")
@Filter(name="Groupfilter", condition = "3=3") @Filter(name="Groupfilter", condition = "3=3")
@FilterJoinTable(name="Groupfilter", condition = "4=4") @FilterJoinTable(name="Groupfilter", condition = "4=4")
public Collection<Permission> getPermissions() { public Collection<Permission> getPermissions() {

View File

@ -17,10 +17,9 @@ import jakarta.persistence.OrderBy;
import jakarta.persistence.Table; import jakarta.persistence.Table;
import org.hibernate.annotations.Filter; import org.hibernate.annotations.Filter;
import org.hibernate.annotations.FilterDef;
import org.hibernate.annotations.FilterJoinTable; import org.hibernate.annotations.FilterJoinTable;
import org.hibernate.annotations.Where; import org.hibernate.annotations.SQLJoinTableRestriction;
import org.hibernate.annotations.WhereJoinTable; import org.hibernate.annotations.SQLRestriction;
/** /**
* @author Emmanuel Bernard * @author Emmanuel Bernard
@ -42,8 +41,8 @@ public class GroupWithSet {
@ManyToMany(cascade = CascadeType.PERSIST) @ManyToMany(cascade = CascadeType.PERSIST)
@OrderBy("expirationDate") @OrderBy("expirationDate")
@Where(clause = "1=1") @SQLRestriction("1=1")
@WhereJoinTable(clause = "2=2") @SQLJoinTableRestriction("2=2")
@Filter(name="Groupfilter", condition = "3=3") @Filter(name="Groupfilter", condition = "3=3")
@FilterJoinTable(name="Groupfilter", condition = "4=4") @FilterJoinTable(name="Groupfilter", condition = "4=4")
public Set<Permission> getPermissions() { public Set<Permission> getPermissions() {

View File

@ -18,7 +18,7 @@ import jakarta.persistence.OneToMany;
import org.hibernate.annotations.OnDelete; import org.hibernate.annotations.OnDelete;
import org.hibernate.annotations.OnDeleteAction; import org.hibernate.annotations.OnDeleteAction;
import org.hibernate.annotations.OrderBy; import org.hibernate.annotations.SQLOrder;
/** /**
* Shows a default one to many * Shows a default one to many
@ -32,7 +32,7 @@ public class Troop {
private Set<Soldier> soldiers; private Set<Soldier> soldiers;
@OneToMany(mappedBy = "troop", cascade = {CascadeType.ALL}, fetch = FetchType.LAZY) @OneToMany(mappedBy = "troop", cascade = {CascadeType.ALL}, fetch = FetchType.LAZY)
@OrderBy(clause = "name desc") @SQLOrder("name desc")
@org.hibernate.annotations.Cascade(org.hibernate.annotations.CascadeType.DELETE_ORPHAN) @org.hibernate.annotations.Cascade(org.hibernate.annotations.CascadeType.DELETE_ORPHAN)
@OnDelete(action = OnDeleteAction.CASCADE) @OnDelete(action = OnDeleteAction.CASCADE)
public Set<Soldier> getSoldiers() { public Set<Soldier> getSoldiers() {

View File

@ -14,6 +14,7 @@ import jakarta.persistence.GeneratedValue;
import jakarta.persistence.Id; import jakarta.persistence.Id;
import jakarta.persistence.JoinColumn; import jakarta.persistence.JoinColumn;
import jakarta.persistence.OneToMany; import jakarta.persistence.OneToMany;
import org.hibernate.annotations.SQLOrder;
/** /**
* Entity used to test {@code NULL} values ordering in SQL {@code ORDER BY} clause. * Entity used to test {@code NULL} values ordering in SQL {@code ORDER BY} clause.
@ -30,7 +31,7 @@ public class Zoo implements Serializable {
@OneToMany @OneToMany
@JoinColumn(name = "zoo_id") @JoinColumn(name = "zoo_id")
@org.hibernate.annotations.OrderBy(clause = "name asc nulls last") // By default H2 places NULL values first. @SQLOrder("name asc nulls last") // By default H2 places NULL values first.
private Set<Tiger> tigers = new HashSet<Tiger>(); private Set<Tiger> tigers = new HashSet<Tiger>();
@OneToMany @OneToMany

View File

@ -16,6 +16,7 @@ import java.util.HashSet;
import java.util.Set; import java.util.Set;
import org.hibernate.annotations.GenericGenerator; import org.hibernate.annotations.GenericGenerator;
import org.hibernate.annotations.SQLOrder;
/** /**
* @author Steve Ebersole * @author Steve Ebersole
@ -69,7 +70,7 @@ public class Zoo {
@OneToMany @OneToMany
@JoinColumn @JoinColumn
@org.hibernate.annotations.OrderBy( clause = "weight" ) @SQLOrder( "weight" )
public Set<Lion> getLions() { public Set<Lion> getLions() {
return lions; return lions;
} }

View File

@ -24,6 +24,7 @@ import jakarta.persistence.TypedQuery;
import org.hibernate.annotations.ResultCheckStyle; import org.hibernate.annotations.ResultCheckStyle;
import org.hibernate.annotations.SQLDelete; import org.hibernate.annotations.SQLDelete;
import org.hibernate.annotations.SQLRestriction;
import org.hibernate.annotations.Where; import org.hibernate.annotations.Where;
import org.hibernate.dialect.H2Dialect; import org.hibernate.dialect.H2Dialect;
import org.hibernate.dialect.PostgreSQLDialect; import org.hibernate.dialect.PostgreSQLDialect;
@ -141,7 +142,7 @@ public class WhereClauseOrderBySizeTest extends BaseEntityManagerFunctionalTestC
@Entity(name = "Book") @Entity(name = "Book")
@SQLDelete(sql = "UPDATE Book SET deleted = true WHERE id = ?", check = ResultCheckStyle.COUNT) @SQLDelete(sql = "UPDATE Book SET deleted = true WHERE id = ?", check = ResultCheckStyle.COUNT)
@Where(clause = "deleted = false") @SQLRestriction("deleted = false")
public static class Book { public static class Book {
@Id @Id
@GeneratedValue @GeneratedValue

View File

@ -10,10 +10,10 @@ import jakarta.persistence.Entity;
import jakarta.persistence.Id; import jakarta.persistence.Id;
import jakarta.persistence.ManyToOne; import jakarta.persistence.ManyToOne;
import org.hibernate.annotations.Where; import org.hibernate.annotations.SQLRestriction;
@Entity @Entity
@Where(clause = "deleted = false") @SQLRestriction("deleted = false")
public class City { public class City {
@Id @Id

View File

@ -19,6 +19,7 @@ import org.hibernate.annotations.Cache;
import org.hibernate.annotations.CacheConcurrencyStrategy; import org.hibernate.annotations.CacheConcurrencyStrategy;
import org.hibernate.annotations.Fetch; import org.hibernate.annotations.Fetch;
import org.hibernate.annotations.FetchMode; import org.hibernate.annotations.FetchMode;
import org.hibernate.annotations.SQLRestriction;
import org.hibernate.annotations.SortNatural; import org.hibernate.annotations.SortNatural;
import org.hibernate.annotations.Where; import org.hibernate.annotations.Where;
@ -104,7 +105,7 @@ public class InsertOrderingSelfReferenceTest extends BaseInsertOrderingTest {
@OneToMany(cascade = CascadeType.ALL, orphanRemoval = true, mappedBy = "parent") @OneToMany(cascade = CascadeType.ALL, orphanRemoval = true, mappedBy = "parent")
@SortNatural @SortNatural
@Where(clause = "TYPE = 'INPUT'") @SQLRestriction("TYPE = 'INPUT'")
@Fetch(FetchMode.SUBSELECT) @Fetch(FetchMode.SUBSELECT)
List<InputParameter> children = new ArrayList<>(); List<InputParameter> children = new ArrayList<>();
} }
@ -118,7 +119,7 @@ public class InsertOrderingSelfReferenceTest extends BaseInsertOrderingTest {
@OneToMany(cascade = CascadeType.ALL, orphanRemoval = true, mappedBy = "parent") @OneToMany(cascade = CascadeType.ALL, orphanRemoval = true, mappedBy = "parent")
@SortNatural @SortNatural
@Where(clause = "TYPE = 'OUTPUT'") @SQLRestriction("TYPE = 'OUTPUT'")
@Fetch(FetchMode.SUBSELECT) @Fetch(FetchMode.SUBSELECT)
@Cache(usage = CacheConcurrencyStrategy.READ_WRITE) @Cache(usage = CacheConcurrencyStrategy.READ_WRITE)
List<OutputParameter> children = new ArrayList<>(); List<OutputParameter> children = new ArrayList<>();

View File

@ -18,7 +18,7 @@ import jakarta.persistence.GeneratedValue;
import jakarta.persistence.Id; import jakarta.persistence.Id;
import jakarta.persistence.OneToMany; import jakarta.persistence.OneToMany;
import org.hibernate.annotations.OrderBy; import org.hibernate.annotations.SQLOrder;
/** /**
* @author Emmanuel Bernard * @author Emmanuel Bernard
@ -30,7 +30,7 @@ public class Troop implements Serializable {
private Set<Soldier> soldiers; private Set<Soldier> soldiers;
@OneToMany(mappedBy = "troop", cascade = {CascadeType.ALL}, fetch = FetchType.LAZY) @OneToMany(mappedBy = "troop", cascade = {CascadeType.ALL}, fetch = FetchType.LAZY)
@OrderBy(clause = "name desc") @SQLOrder("name desc")
@org.hibernate.annotations.Cascade({org.hibernate.annotations.CascadeType.DELETE_ORPHAN}) @org.hibernate.annotations.Cascade({org.hibernate.annotations.CascadeType.DELETE_ORPHAN})
public Set<Soldier> getSoldiers() { public Set<Soldier> getSoldiers() {
return soldiers; return soldiers;

View File

@ -6,7 +6,7 @@
*/ */
package org.hibernate.orm.test.manytomany; package org.hibernate.orm.test.manytomany;
import org.hibernate.annotations.Where; import org.hibernate.annotations.SQLRestriction;
import jakarta.persistence.Entity; import jakarta.persistence.Entity;
import jakarta.persistence.FetchType; import jakarta.persistence.FetchType;
@ -25,7 +25,7 @@ public class Advertisement {
@GeneratedValue @GeneratedValue
private Integer id; private Integer id;
@Where(clause = "deleted <> 'true'") @SQLRestriction("deleted <> 'true'")
@ManyToMany(fetch = FetchType.EAGER, mappedBy = "advertisements") @ManyToMany(fetch = FetchType.EAGER, mappedBy = "advertisements")
@OrderBy("id asc") @OrderBy("id asc")
private Set<Attachment> attachments; private Set<Attachment> attachments;

View File

@ -18,6 +18,7 @@ import jakarta.persistence.Id;
import jakarta.persistence.ManyToOne; import jakarta.persistence.ManyToOne;
import jakarta.persistence.OneToMany; import jakarta.persistence.OneToMany;
import org.hibernate.annotations.SQLOrder;
import org.hibernate.dialect.H2Dialect; import org.hibernate.dialect.H2Dialect;
import org.hibernate.metamodel.CollectionClassification; import org.hibernate.metamodel.CollectionClassification;
import org.hibernate.orm.test.jpa.BaseEntityManagerFunctionalTestCase; import org.hibernate.orm.test.jpa.BaseEntityManagerFunctionalTestCase;
@ -94,9 +95,7 @@ public class OrderedBySQLTest extends BaseEntityManagerFunctionalTestCase {
mappedBy = "person", mappedBy = "person",
cascade = CascadeType.ALL cascade = CascadeType.ALL
) )
@org.hibernate.annotations.OrderBy( @SQLOrder("CHAR_LENGTH(name) DESC")
clause = "CHAR_LENGTH(name) DESC"
)
private List<Article> articles = new ArrayList<>(); private List<Article> articles = new ArrayList<>();
//Getters and setters are omitted for brevity //Getters and setters are omitted for brevity

View File

@ -8,7 +8,7 @@ package org.hibernate.orm.test.mapping.where;
import java.util.Set; import java.util.Set;
import org.hibernate.annotations.Where; import org.hibernate.annotations.SQLRestriction;
import org.hibernate.testing.orm.junit.DomainModel; import org.hibernate.testing.orm.junit.DomainModel;
import org.hibernate.testing.orm.junit.JiraKey; import org.hibernate.testing.orm.junit.JiraKey;
@ -71,7 +71,7 @@ public class DiscriminatorWhereTest {
@OneToMany @OneToMany
@JoinColumn(name = "allC") @JoinColumn(name = "allC")
@Where(clause = "type = 'C'") @SQLRestriction("type = 'C'")
private Set<EntityC> allMyC; private Set<EntityC> allMyC;
public Integer getId() { public Integer getId() {

View File

@ -6,7 +6,7 @@
*/ */
package org.hibernate.orm.test.mapping.where; package org.hibernate.orm.test.mapping.where;
import org.hibernate.annotations.Where; import org.hibernate.annotations.SQLRestriction;
import jakarta.persistence.Column; import jakarta.persistence.Column;
import jakarta.persistence.Entity; import jakarta.persistence.Entity;
@ -19,7 +19,7 @@ import static jakarta.persistence.FetchType.LAZY;
import static java.text.MessageFormat.format; import static java.text.MessageFormat.format;
import static java.util.Objects.hash; import static java.util.Objects.hash;
@Where(clause = "is_active = true") @SQLRestriction("is_active = true")
@Table(name = "t_user_details") @Table(name = "t_user_details")
@Entity(name = "UserDetail") @Entity(name = "UserDetail")
public class UserDetail { public class UserDetail {

View File

@ -6,7 +6,7 @@
*/ */
package org.hibernate.orm.test.mapping.where; package org.hibernate.orm.test.mapping.where;
import org.hibernate.annotations.Where; import org.hibernate.annotations.SQLRestriction;
import jakarta.persistence.Column; import jakarta.persistence.Column;
import jakarta.persistence.Entity; import jakarta.persistence.Entity;
@ -19,7 +19,7 @@ import static jakarta.persistence.FetchType.LAZY;
import static java.text.MessageFormat.format; import static java.text.MessageFormat.format;
import static java.util.Objects.hash; import static java.util.Objects.hash;
@Where(clause = "has_deleted = false") @SQLRestriction("has_deleted = false")
@Table(name = "t_user_skills") @Table(name = "t_user_skills")
@Entity(name = "UserSkill") @Entity(name = "UserSkill")
public class UserSkill { public class UserSkill {

View File

@ -18,7 +18,7 @@ import jakarta.persistence.JoinTable;
import jakarta.persistence.ManyToMany; import jakarta.persistence.ManyToMany;
import org.hibernate.Session; import org.hibernate.Session;
import org.hibernate.annotations.WhereJoinTable; import org.hibernate.annotations.SQLJoinTableRestriction;
import org.hibernate.dialect.H2Dialect; import org.hibernate.dialect.H2Dialect;
import org.hibernate.metamodel.CollectionClassification; import org.hibernate.metamodel.CollectionClassification;
import org.hibernate.orm.test.jpa.BaseEntityManagerFunctionalTestCase; import org.hibernate.orm.test.jpa.BaseEntityManagerFunctionalTestCase;
@ -127,7 +127,7 @@ public class WhereJoinTableTest extends BaseEntityManagerFunctionalTestCase {
joinColumns = @JoinColumn(name = "book_id"), joinColumns = @JoinColumn(name = "book_id"),
inverseJoinColumns = @JoinColumn(name = "reader_id") inverseJoinColumns = @JoinColumn(name = "reader_id")
) )
@WhereJoinTable(clause = "created_on > DATEADD('DAY', -7, CURRENT_TIMESTAMP())") @SQLJoinTableRestriction("created_on > DATEADD('DAY', -7, CURRENT_TIMESTAMP())")
private List<Reader> currentWeekReaders = new ArrayList<>(); private List<Reader> currentWeekReaders = new ArrayList<>();
//Getters and setters omitted for brevity //Getters and setters omitted for brevity

View File

@ -18,7 +18,7 @@ import jakarta.persistence.Id;
import jakarta.persistence.ManyToOne; import jakarta.persistence.ManyToOne;
import jakarta.persistence.OneToMany; import jakarta.persistence.OneToMany;
import org.hibernate.annotations.Where; import org.hibernate.annotations.SQLRestriction;
import org.hibernate.metamodel.CollectionClassification; import org.hibernate.metamodel.CollectionClassification;
import org.hibernate.orm.test.jpa.BaseEntityManagerFunctionalTestCase; import org.hibernate.orm.test.jpa.BaseEntityManagerFunctionalTestCase;
@ -122,11 +122,11 @@ public class WhereTest extends BaseEntityManagerFunctionalTestCase {
private String name; private String name;
@Where(clause = "account_type = 'DEBIT'") @SQLRestriction("account_type = 'DEBIT'")
@OneToMany(mappedBy = "client") @OneToMany(mappedBy = "client")
private List<Account> debitAccounts = new ArrayList<>(); private List<Account> debitAccounts = new ArrayList<>();
@Where(clause = "account_type = 'CREDIT'") @SQLRestriction("account_type = 'CREDIT'")
@OneToMany(mappedBy = "client") @OneToMany(mappedBy = "client")
private List<Account> creditAccounts = new ArrayList<>(); private List<Account> creditAccounts = new ArrayList<>();
@ -160,7 +160,7 @@ public class WhereTest extends BaseEntityManagerFunctionalTestCase {
} }
@Entity(name = "Account") @Entity(name = "Account")
@Where(clause = "active = true") @SQLRestriction("active = true")
public static class Account { public static class Account {
@Id @Id

View File

@ -7,7 +7,7 @@ import jakarta.persistence.Id;
import jakarta.persistence.Inheritance; import jakarta.persistence.Inheritance;
import jakarta.persistence.InheritanceType; import jakarta.persistence.InheritanceType;
import org.hibernate.annotations.Where; import org.hibernate.annotations.SQLRestriction;
import org.hibernate.testing.TestForIssue; import org.hibernate.testing.TestForIssue;
import org.hibernate.testing.junit4.BaseCoreFunctionalTestCase; import org.hibernate.testing.junit4.BaseCoreFunctionalTestCase;
@ -36,7 +36,7 @@ public class HHH14112Test extends BaseCoreFunctionalTestCase {
@Entity(name = "Super") @Entity(name = "Super")
@Inheritance(strategy = InheritanceType.JOINED) @Inheritance(strategy = InheritanceType.JOINED)
@Where(clause = "deleted = false") @SQLRestriction("deleted = false")
public static class Super { public static class Super {
@Id @Id
@GeneratedValue(strategy = GenerationType.AUTO) @GeneratedValue(strategy = GenerationType.AUTO)

View File

@ -24,8 +24,8 @@ import org.hibernate.annotations.ResultCheckStyle;
import org.hibernate.annotations.SQLDelete; import org.hibernate.annotations.SQLDelete;
import org.hibernate.annotations.SQLDeleteAll; import org.hibernate.annotations.SQLDeleteAll;
import org.hibernate.annotations.SQLInsert; import org.hibernate.annotations.SQLInsert;
import org.hibernate.annotations.SQLRestriction;
import org.hibernate.annotations.SQLUpdate; import org.hibernate.annotations.SQLUpdate;
import org.hibernate.annotations.Where;
import org.hibernate.dialect.H2Dialect; import org.hibernate.dialect.H2Dialect;
import org.hibernate.dialect.PostgreSQLDialect; import org.hibernate.dialect.PostgreSQLDialect;
import org.hibernate.metamodel.CollectionClassification; import org.hibernate.metamodel.CollectionClassification;
@ -142,7 +142,7 @@ public class CustomSQLTest extends BaseEntityManagerFunctionalTestCase {
sql = "INSERT INTO person_phones (person_id, phones, valid) VALUES (?, ?, true) ") sql = "INSERT INTO person_phones (person_id, phones, valid) VALUES (?, ?, true) ")
@SQLDeleteAll( @SQLDeleteAll(
sql = "UPDATE person_phones SET valid = false WHERE person_id = ?") sql = "UPDATE person_phones SET valid = false WHERE person_id = ?")
@Where(clause = "valid = true") @SQLRestriction("valid = true")
private List<String> phones = new ArrayList<>(); private List<String> phones = new ArrayList<>();
//Getters and setters are omitted for brevity //Getters and setters are omitted for brevity

View File

@ -4,7 +4,7 @@ import java.util.ArrayList;
import java.util.Date; import java.util.Date;
import java.util.List; import java.util.List;
import org.hibernate.annotations.Where; import org.hibernate.annotations.SQLRestriction;
import org.hibernate.testing.TestForIssue; import org.hibernate.testing.TestForIssue;
import org.hibernate.testing.orm.junit.EntityManagerFactoryScope; import org.hibernate.testing.orm.junit.EntityManagerFactoryScope;
@ -134,7 +134,7 @@ public class EagerManyToOne2Test {
private String name; private String name;
@OneToMany(mappedBy = "parent", cascade = CascadeType.ALL, fetch = FetchType.EAGER, orphanRemoval = true) @OneToMany(mappedBy = "parent", cascade = CascadeType.ALL, fetch = FetchType.EAGER, orphanRemoval = true)
@Where(clause = "deleted_at IS NULL") @SQLRestriction("deleted_at IS NULL")
private List<Child> children = new ArrayList<>(); private List<Child> children = new ArrayList<>();
public Parent() { public Parent() {

View File

@ -4,13 +4,11 @@ import java.util.ArrayList;
import java.util.Date; import java.util.Date;
import java.util.List; import java.util.List;
import org.hibernate.annotations.Where; import org.hibernate.annotations.SQLRestriction;
import org.hibernate.cfg.AvailableSettings;
import org.hibernate.testing.TestForIssue; import org.hibernate.testing.TestForIssue;
import org.hibernate.testing.orm.junit.EntityManagerFactoryScope; import org.hibernate.testing.orm.junit.EntityManagerFactoryScope;
import org.hibernate.testing.orm.junit.Jpa; import org.hibernate.testing.orm.junit.Jpa;
import org.hibernate.testing.orm.junit.Setting;
import org.junit.jupiter.api.AfterEach; import org.junit.jupiter.api.AfterEach;
import org.junit.jupiter.api.Test; import org.junit.jupiter.api.Test;
@ -100,7 +98,7 @@ public class EagerManyToOne3Test {
@Entity(name = "Child") @Entity(name = "Child")
@Table(name = "children") @Table(name = "children")
@Where(clause = "deleted_at IS NULL") @SQLRestriction("deleted_at IS NULL")
public static class Child { public static class Child {
@Id @Id
private Long id; private Long id;

View File

@ -23,7 +23,7 @@ import org.hibernate.annotations.Fetch;
import org.hibernate.annotations.FetchMode; import org.hibernate.annotations.FetchMode;
import org.hibernate.annotations.NotFound; import org.hibernate.annotations.NotFound;
import org.hibernate.annotations.NotFoundAction; import org.hibernate.annotations.NotFoundAction;
import org.hibernate.annotations.Where; import org.hibernate.annotations.SQLRestriction;
import org.hibernate.testing.FailureExpected; import org.hibernate.testing.FailureExpected;
import org.hibernate.testing.TestForIssue; import org.hibernate.testing.TestForIssue;
@ -131,7 +131,7 @@ public class EagerManyToOneFetchModeJoinWhereTest extends BaseNonConfigCoreFunct
@Entity(name = "Category") @Entity(name = "Category")
@Table(name = "CATEGORY") @Table(name = "CATEGORY")
@Where(clause = "inactive = 0") @SQLRestriction("inactive = 0")
public static class Category { public static class Category {
@Id @Id
@GeneratedValue @GeneratedValue

View File

@ -24,7 +24,7 @@ import org.hibernate.annotations.Fetch;
import org.hibernate.annotations.FetchMode; import org.hibernate.annotations.FetchMode;
import org.hibernate.annotations.NotFound; import org.hibernate.annotations.NotFound;
import org.hibernate.annotations.NotFoundAction; import org.hibernate.annotations.NotFoundAction;
import org.hibernate.annotations.Where; import org.hibernate.annotations.SQLRestriction;
import org.hibernate.cfg.AvailableSettings; import org.hibernate.cfg.AvailableSettings;
import org.hibernate.testing.TestForIssue; import org.hibernate.testing.TestForIssue;
@ -136,7 +136,7 @@ public class EagerManyToOneFetchModeSelectWhereTest extends BaseNonConfigCoreFun
@Entity(name = "Category") @Entity(name = "Category")
@Table(name = "CATEGORY") @Table(name = "CATEGORY")
@Where(clause = "inactive = 0") @SQLRestriction("inactive = 0")
public static class Category { public static class Category {
@Id @Id
@GeneratedValue @GeneratedValue

View File

@ -4,7 +4,7 @@ import java.util.ArrayList;
import java.util.Date; import java.util.Date;
import java.util.List; import java.util.List;
import org.hibernate.annotations.Where; import org.hibernate.annotations.SQLRestriction;
import org.hibernate.cfg.AvailableSettings; import org.hibernate.cfg.AvailableSettings;
import org.hibernate.testing.TestForIssue; import org.hibernate.testing.TestForIssue;
@ -88,7 +88,7 @@ public class EagerManyToOneTest {
@Entity(name = "Child") @Entity(name = "Child")
@Table(name = "children") @Table(name = "children")
@Where(clause = "deleted_at IS NULL") @SQLRestriction("deleted_at IS NULL")
public static class Child { public static class Child {
@Id @Id
private Long id; private Long id;

View File

@ -20,8 +20,8 @@ import jakarta.persistence.ManyToMany;
import jakarta.persistence.OneToMany; import jakarta.persistence.OneToMany;
import jakarta.persistence.Table; import jakarta.persistence.Table;
import org.hibernate.annotations.Where; import org.hibernate.annotations.SQLJoinTableRestriction;
import org.hibernate.annotations.WhereJoinTable; import org.hibernate.annotations.SQLRestriction;
import org.hibernate.cfg.AvailableSettings; import org.hibernate.cfg.AvailableSettings;
import org.hibernate.testing.TestForIssue; import org.hibernate.testing.TestForIssue;
@ -178,7 +178,7 @@ public class EagerToManyWhereDontUseClassWhereTest extends BaseNonConfigCoreFunc
@OneToMany(fetch = FetchType.EAGER) @OneToMany(fetch = FetchType.EAGER)
@JoinColumn @JoinColumn
@Where( clause = "description is not null" ) @SQLRestriction( "description is not null" )
private Set<Category> categoriesWithDescOneToMany = new HashSet<>(); private Set<Category> categoriesWithDescOneToMany = new HashSet<>();
@ManyToMany(fetch = FetchType.EAGER) @ManyToMany(fetch = FetchType.EAGER)
@ -187,19 +187,19 @@ public class EagerToManyWhereDontUseClassWhereTest extends BaseNonConfigCoreFunc
@ManyToMany(fetch = FetchType.EAGER) @ManyToMany(fetch = FetchType.EAGER)
@JoinTable(name = "categoriesWithDescManyToMany", inverseJoinColumns = { @JoinColumn( name = "categoryId" )}) @JoinTable(name = "categoriesWithDescManyToMany", inverseJoinColumns = { @JoinColumn( name = "categoryId" )})
@Where( clause = "description is not null" ) @SQLRestriction( "description is not null" )
private Set<Category> categoriesWithDescManyToMany = new HashSet<>(); private Set<Category> categoriesWithDescManyToMany = new HashSet<>();
@ManyToMany(fetch = FetchType.EAGER) @ManyToMany(fetch = FetchType.EAGER)
@JoinTable(name = "categoriesWithDescIdLt4MToM", inverseJoinColumns = { @JoinColumn( name = "categoryId" )}) @JoinTable(name = "categoriesWithDescIdLt4MToM", inverseJoinColumns = { @JoinColumn( name = "categoryId" )})
@Where( clause = "description is not null" ) @SQLRestriction( "description is not null" )
@WhereJoinTable( clause = "categoryId < 4") @SQLJoinTableRestriction( "categoryId < 4")
private Set<Category> categoriesWithDescIdLt4ManyToMany = new HashSet<>(); private Set<Category> categoriesWithDescIdLt4ManyToMany = new HashSet<>();
} }
@Entity(name = "Category") @Entity(name = "Category")
@Table(name = "CATEGORY") @Table(name = "CATEGORY")
@Where(clause = "inactive = 0") @SQLRestriction( "inactive = 0")
public static class Category { public static class Category {
@Id @Id
private int id; private int id;

View File

@ -19,8 +19,8 @@ import jakarta.persistence.ManyToMany;
import jakarta.persistence.OneToMany; import jakarta.persistence.OneToMany;
import jakarta.persistence.Table; import jakarta.persistence.Table;
import org.hibernate.annotations.Where; import org.hibernate.annotations.SQLJoinTableRestriction;
import org.hibernate.annotations.WhereJoinTable; import org.hibernate.annotations.SQLRestriction;
import org.hibernate.testing.TestForIssue; import org.hibernate.testing.TestForIssue;
import org.hibernate.testing.junit4.BaseNonConfigCoreFunctionalTestCase; import org.hibernate.testing.junit4.BaseNonConfigCoreFunctionalTestCase;
@ -172,7 +172,7 @@ public class EagerToManyWhereTest extends BaseNonConfigCoreFunctionalTestCase {
@OneToMany(fetch = FetchType.EAGER) @OneToMany(fetch = FetchType.EAGER)
@JoinColumn @JoinColumn
@Where( clause = "description is not null" ) @SQLRestriction( "description is not null" )
private Set<Category> categoriesWithDescOneToMany = new HashSet<>(); private Set<Category> categoriesWithDescOneToMany = new HashSet<>();
@ManyToMany(fetch = FetchType.EAGER) @ManyToMany(fetch = FetchType.EAGER)
@ -181,19 +181,19 @@ public class EagerToManyWhereTest extends BaseNonConfigCoreFunctionalTestCase {
@ManyToMany(fetch = FetchType.EAGER) @ManyToMany(fetch = FetchType.EAGER)
@JoinTable(name = "categoriesWithDescManyToMany", inverseJoinColumns = { @JoinColumn( name = "categoryId" )}) @JoinTable(name = "categoriesWithDescManyToMany", inverseJoinColumns = { @JoinColumn( name = "categoryId" )})
@Where( clause = "description is not null" ) @SQLRestriction( "description is not null" )
private Set<Category> categoriesWithDescManyToMany = new HashSet<>(); private Set<Category> categoriesWithDescManyToMany = new HashSet<>();
@ManyToMany(fetch = FetchType.EAGER) @ManyToMany(fetch = FetchType.EAGER)
@JoinTable(name = "categoriesWithDescIdLt4MToM", inverseJoinColumns = { @JoinColumn( name = "categoryId" )}) @JoinTable(name = "categoriesWithDescIdLt4MToM", inverseJoinColumns = { @JoinColumn( name = "categoryId" )})
@Where( clause = "description is not null" ) @SQLRestriction( "description is not null" )
@WhereJoinTable( clause = "categoryId < 4") @SQLJoinTableRestriction( "categoryId < 4")
private Set<Category> categoriesWithDescIdLt4ManyToMany = new HashSet<>(); private Set<Category> categoriesWithDescIdLt4ManyToMany = new HashSet<>();
} }
@Entity(name = "Category") @Entity(name = "Category")
@Table(name = "CATEGORY") @Table(name = "CATEGORY")
@Where(clause = "inactive = 0") @SQLRestriction("inactive = 0")
public static class Category { public static class Category {
@Id @Id
private int id; private int id;

View File

@ -20,8 +20,8 @@ import jakarta.persistence.ManyToMany;
import jakarta.persistence.OneToMany; import jakarta.persistence.OneToMany;
import jakarta.persistence.Table; import jakarta.persistence.Table;
import org.hibernate.annotations.Where; import org.hibernate.annotations.SQLJoinTableRestriction;
import org.hibernate.annotations.WhereJoinTable; import org.hibernate.annotations.SQLRestriction;
import org.hibernate.cfg.AvailableSettings; import org.hibernate.cfg.AvailableSettings;
import org.hibernate.testing.TestForIssue; import org.hibernate.testing.TestForIssue;
@ -178,7 +178,7 @@ public class EagerToManyWhereUseClassWhereTest extends BaseNonConfigCoreFunction
@OneToMany(fetch = FetchType.EAGER) @OneToMany(fetch = FetchType.EAGER)
@JoinColumn @JoinColumn
@Where( clause = "description is not null" ) @SQLRestriction( "description is not null" )
private Set<Category> categoriesWithDescOneToMany = new HashSet<>(); private Set<Category> categoriesWithDescOneToMany = new HashSet<>();
@ManyToMany(fetch = FetchType.EAGER) @ManyToMany(fetch = FetchType.EAGER)
@ -187,19 +187,19 @@ public class EagerToManyWhereUseClassWhereTest extends BaseNonConfigCoreFunction
@ManyToMany(fetch = FetchType.EAGER) @ManyToMany(fetch = FetchType.EAGER)
@JoinTable(name = "categoriesWithDescManyToMany", inverseJoinColumns = { @JoinColumn( name = "categoryId" )}) @JoinTable(name = "categoriesWithDescManyToMany", inverseJoinColumns = { @JoinColumn( name = "categoryId" )})
@Where( clause = "description is not null" ) @SQLRestriction( "description is not null" )
private Set<Category> categoriesWithDescManyToMany = new HashSet<>(); private Set<Category> categoriesWithDescManyToMany = new HashSet<>();
@ManyToMany(fetch = FetchType.EAGER) @ManyToMany(fetch = FetchType.EAGER)
@JoinTable(name = "categoriesWithDescIdLt4MToM", inverseJoinColumns = { @JoinColumn( name = "categoryId" )}) @JoinTable(name = "categoriesWithDescIdLt4MToM", inverseJoinColumns = { @JoinColumn( name = "categoryId" )})
@Where( clause = "description is not null" ) @SQLRestriction( "description is not null" )
@WhereJoinTable( clause = "categoryId < 4") @SQLJoinTableRestriction("categoryId < 4")
private Set<Category> categoriesWithDescIdLt4ManyToMany = new HashSet<>(); private Set<Category> categoriesWithDescIdLt4ManyToMany = new HashSet<>();
} }
@Entity(name = "Category") @Entity(name = "Category")
@Table(name = "CATEGORY") @Table(name = "CATEGORY")
@Where(clause = "inactive = 0") @SQLRestriction("inactive = 0")
public static class Category { public static class Category {
@Id @Id
private int id; private int id;

View File

@ -15,16 +15,14 @@ import jakarta.persistence.JoinTable;
import jakarta.persistence.ManyToMany; import jakarta.persistence.ManyToMany;
import jakarta.persistence.OneToMany; import jakarta.persistence.OneToMany;
import jakarta.persistence.Table; import jakarta.persistence.Table;
import org.hibernate.annotations.Where; import org.hibernate.annotations.SQLJoinTableRestriction;
import org.hibernate.annotations.WhereJoinTable; import org.hibernate.annotations.SQLRestriction;
import org.hibernate.cfg.AvailableSettings;
import org.hibernate.testing.TestForIssue; import org.hibernate.testing.TestForIssue;
import org.hibernate.testing.junit4.BaseNonConfigCoreFunctionalTestCase; import org.hibernate.testing.junit4.BaseNonConfigCoreFunctionalTestCase;
import org.junit.Test; import org.junit.Test;
import java.util.Arrays; import java.util.Arrays;
import java.util.HashSet; import java.util.HashSet;
import java.util.Map;
import java.util.Set; import java.util.Set;
import static org.hibernate.testing.transaction.TransactionUtil.doInHibernate; import static org.hibernate.testing.transaction.TransactionUtil.doInHibernate;
@ -172,7 +170,7 @@ public class EagerToManyWhereUseClassWhereViaAnnotationTest extends BaseNonConfi
@OneToMany(fetch = FetchType.EAGER) @OneToMany(fetch = FetchType.EAGER)
@JoinColumn @JoinColumn
@Where( clause = "description is not null" ) @SQLRestriction( "description is not null" )
private Set<Category> categoriesWithDescOneToMany = new HashSet<>(); private Set<Category> categoriesWithDescOneToMany = new HashSet<>();
@ManyToMany(fetch = FetchType.EAGER) @ManyToMany(fetch = FetchType.EAGER)
@ -181,19 +179,19 @@ public class EagerToManyWhereUseClassWhereViaAnnotationTest extends BaseNonConfi
@ManyToMany(fetch = FetchType.EAGER) @ManyToMany(fetch = FetchType.EAGER)
@JoinTable(name = "categoriesWithDescManyToMany", inverseJoinColumns = { @JoinColumn( name = "categoryId" )}) @JoinTable(name = "categoriesWithDescManyToMany", inverseJoinColumns = { @JoinColumn( name = "categoryId" )})
@Where( clause = "description is not null" ) @SQLRestriction( "description is not null" )
private Set<Category> categoriesWithDescManyToMany = new HashSet<>(); private Set<Category> categoriesWithDescManyToMany = new HashSet<>();
@ManyToMany(fetch = FetchType.EAGER) @ManyToMany(fetch = FetchType.EAGER)
@JoinTable(name = "categoriesWithDescIdLt4MToM", inverseJoinColumns = { @JoinColumn( name = "categoryId" )}) @JoinTable(name = "categoriesWithDescIdLt4MToM", inverseJoinColumns = { @JoinColumn( name = "categoryId" )})
@Where( clause = "description is not null" ) @SQLRestriction( "description is not null" )
@WhereJoinTable( clause = "categoryId < 4") @SQLJoinTableRestriction("categoryId < 4")
private Set<Category> categoriesWithDescIdLt4ManyToMany = new HashSet<>(); private Set<Category> categoriesWithDescIdLt4ManyToMany = new HashSet<>();
} }
@Entity(name = "Category") @Entity(name = "Category")
@Table(name = "CATEGORY") @Table(name = "CATEGORY")
@Where(clause = "inactive = 0") @SQLRestriction("inactive = 0")
public static class Category { public static class Category {
@Id @Id
private int id; private int id;

View File

@ -21,7 +21,7 @@ import jakarta.persistence.Table;
import org.hibernate.Hibernate; import org.hibernate.Hibernate;
import org.hibernate.Session; import org.hibernate.Session;
import org.hibernate.annotations.Immutable; import org.hibernate.annotations.Immutable;
import org.hibernate.annotations.Where; import org.hibernate.annotations.SQLRestriction;
import org.hibernate.dialect.H2Dialect; import org.hibernate.dialect.H2Dialect;
import org.hibernate.testing.RequiresDialect; import org.hibernate.testing.RequiresDialect;
import org.hibernate.testing.TestForIssue; import org.hibernate.testing.TestForIssue;
@ -195,7 +195,7 @@ public class LazyElementCollectionBasicNonUniqueIdWhereTest extends BaseCoreFunc
@Entity( name = "Material" ) @Entity( name = "Material" )
@Table( name = "MAIN_TABLE" ) @Table( name = "MAIN_TABLE" )
@Where( clause = "CODE = 'MATERIAL'" ) @SQLRestriction("CODE = 'MATERIAL'" )
public static class Material { public static class Material {
private int id; private int id;
@ -227,7 +227,7 @@ public class LazyElementCollectionBasicNonUniqueIdWhereTest extends BaseCoreFunc
joinColumns = { @JoinColumn( name = "MAIN_ID" ) } joinColumns = { @JoinColumn( name = "MAIN_ID" ) }
) )
@Column( name="VAL") @Column( name="VAL")
@Where( clause = "MAIN_CODE='MATERIAL' AND VALUE_CODE='SIZE'") @SQLRestriction("MAIN_CODE='MATERIAL' AND VALUE_CODE='SIZE'")
@Immutable @Immutable
public Set<String> getSizesFromCombined() { public Set<String> getSizesFromCombined() {
return sizesFromCombined; return sizesFromCombined;
@ -253,7 +253,7 @@ public class LazyElementCollectionBasicNonUniqueIdWhereTest extends BaseCoreFunc
@Entity( name = "Building" ) @Entity( name = "Building" )
@Table( name = "MAIN_TABLE" ) @Table( name = "MAIN_TABLE" )
@Where( clause = "CODE = 'BUILDING'" ) @SQLRestriction("CODE = 'BUILDING'" )
public static class Building { public static class Building {
private int id; private int id;
private String name; private String name;
@ -284,7 +284,7 @@ public class LazyElementCollectionBasicNonUniqueIdWhereTest extends BaseCoreFunc
joinColumns = { @JoinColumn( name = "MAIN_ID" ) } joinColumns = { @JoinColumn( name = "MAIN_ID" ) }
) )
@Column( name="VAL") @Column( name="VAL")
@Where( clause = "MAIN_CODE='BUILDING' AND VALUE_CODE='SIZE'") @SQLRestriction("MAIN_CODE='BUILDING' AND VALUE_CODE='SIZE'")
@Immutable @Immutable
public Set<String> getSizesFromCombined() { public Set<String> getSizesFromCombined() {
return sizesFromCombined; return sizesFromCombined;
@ -299,7 +299,7 @@ public class LazyElementCollectionBasicNonUniqueIdWhereTest extends BaseCoreFunc
joinColumns = { @JoinColumn( name = "MAIN_ID" ) } joinColumns = { @JoinColumn( name = "MAIN_ID" ) }
) )
@Column( name="VAL") @Column( name="VAL")
@Where( clause = "MAIN_CODE='BUILDING' AND VALUE_CODE='RATING'" ) @SQLRestriction( "MAIN_CODE='BUILDING' AND VALUE_CODE='RATING'" )
@Immutable @Immutable
public Set<String> getRatingsFromCombined() { public Set<String> getRatingsFromCombined() {
return ratingsFromCombined; return ratingsFromCombined;

View File

@ -26,7 +26,7 @@ import jakarta.persistence.Table;
import org.hibernate.Hibernate; import org.hibernate.Hibernate;
import org.hibernate.Session; import org.hibernate.Session;
import org.hibernate.annotations.Immutable; import org.hibernate.annotations.Immutable;
import org.hibernate.annotations.Where; import org.hibernate.annotations.SQLRestriction;
import org.hibernate.dialect.H2Dialect; import org.hibernate.dialect.H2Dialect;
import org.hibernate.testing.RequiresDialect; import org.hibernate.testing.RequiresDialect;
import org.hibernate.testing.TestForIssue; import org.hibernate.testing.TestForIssue;
@ -208,7 +208,7 @@ public class LazyElementCollectionWithLazyManyToOneNonUniqueIdWhereTest extends
@Entity( name = "Material" ) @Entity( name = "Material" )
@Table( name = "MAIN_TABLE" ) @Table( name = "MAIN_TABLE" )
@Where( clause = "CODE = 'MATERIAL'" ) @SQLRestriction( "CODE = 'MATERIAL'" )
public static class Material { public static class Material {
private int id; private int id;
@ -242,7 +242,7 @@ public class LazyElementCollectionWithLazyManyToOneNonUniqueIdWhereTest extends
@AssociationOverrides( @AssociationOverrides(
value = { @AssociationOverride( name = "size", joinColumns = { @JoinColumn(name = "ASSOCIATION_ID") } ) } value = { @AssociationOverride( name = "size", joinColumns = { @JoinColumn(name = "ASSOCIATION_ID") } ) }
) )
@Where( clause = "MAIN_CODE='MATERIAL' AND ASSOCIATION_CODE='SIZE'") @SQLRestriction("MAIN_CODE='MATERIAL' AND ASSOCIATION_CODE='SIZE'")
@Immutable @Immutable
public Set<ContainedSize> getContainedSizesFromCombined() { public Set<ContainedSize> getContainedSizesFromCombined() {
return containedSizesFromCombined; return containedSizesFromCombined;
@ -270,7 +270,7 @@ public class LazyElementCollectionWithLazyManyToOneNonUniqueIdWhereTest extends
@Entity( name = "Building" ) @Entity( name = "Building" )
@Table( name = "MAIN_TABLE" ) @Table( name = "MAIN_TABLE" )
@Where( clause = "CODE = 'BUILDING'" ) @SQLRestriction( "CODE = 'BUILDING'" )
public static class Building { public static class Building {
private int id; private int id;
private String name; private String name;
@ -300,7 +300,7 @@ public class LazyElementCollectionWithLazyManyToOneNonUniqueIdWhereTest extends
name = "COLLECTION_TABLE", name = "COLLECTION_TABLE",
joinColumns = { @JoinColumn( name = "MAIN_ID" ) } joinColumns = { @JoinColumn( name = "MAIN_ID" ) }
) )
@Where( clause = "MAIN_CODE='BUILDING' AND ASSOCIATION_CODE='SIZE'") @SQLRestriction("MAIN_CODE='BUILDING' AND ASSOCIATION_CODE='SIZE'")
@Immutable @Immutable
public Set<ContainedSize> getContainedSizesFromCombined() { public Set<ContainedSize> getContainedSizesFromCombined() {
return containedSizesFromCombined; return containedSizesFromCombined;
@ -314,7 +314,7 @@ public class LazyElementCollectionWithLazyManyToOneNonUniqueIdWhereTest extends
name = "COLLECTION_TABLE", name = "COLLECTION_TABLE",
joinColumns = { @JoinColumn( name = "MAIN_ID" ) } joinColumns = { @JoinColumn( name = "MAIN_ID" ) }
) )
@Where( clause = "MAIN_CODE='BUILDING' AND ASSOCIATION_CODE='RATING'" ) @SQLRestriction( "MAIN_CODE='BUILDING' AND ASSOCIATION_CODE='RATING'" )
@Immutable @Immutable
public Set<ContainedRating> getContainedRatingsFromCombined() { public Set<ContainedRating> getContainedRatingsFromCombined() {
return containedRatingsFromCombined; return containedRatingsFromCombined;
@ -327,7 +327,7 @@ public class LazyElementCollectionWithLazyManyToOneNonUniqueIdWhereTest extends
@Entity( name = "Size" ) @Entity( name = "Size" )
@Table( name = "MAIN_TABLE" ) @Table( name = "MAIN_TABLE" )
@Where( clause = "CODE = 'SIZE'" ) @SQLRestriction( "CODE = 'SIZE'" )
public static class Size { public static class Size {
private int id; private int id;
private String name; private String name;
@ -366,7 +366,7 @@ public class LazyElementCollectionWithLazyManyToOneNonUniqueIdWhereTest extends
@Entity( name = "Rating" ) @Entity( name = "Rating" )
@Table( name = "MAIN_TABLE" ) @Table( name = "MAIN_TABLE" )
@Where( clause = "CODE = 'RATING'" ) @SQLRestriction( "CODE = 'RATING'" )
public static class Rating { public static class Rating {
private int id; private int id;
private String name; private String name;

View File

@ -22,8 +22,8 @@ import jakarta.persistence.Table;
import org.hibernate.Hibernate; import org.hibernate.Hibernate;
import org.hibernate.annotations.Immutable; import org.hibernate.annotations.Immutable;
import org.hibernate.annotations.Where; import org.hibernate.annotations.SQLJoinTableRestriction;
import org.hibernate.annotations.WhereJoinTable; import org.hibernate.annotations.SQLRestriction;
import org.hibernate.cfg.Configuration; import org.hibernate.cfg.Configuration;
import org.hibernate.metamodel.CollectionClassification; import org.hibernate.metamodel.CollectionClassification;
@ -265,7 +265,7 @@ public class LazyManyToManyNonUniqueIdWhereTest extends BaseCoreFunctionalTestCa
@Entity( name = "Material" ) @Entity( name = "Material" )
@Table( name = "MAIN_TABLE" ) @Table( name = "MAIN_TABLE" )
@Where( clause = "CODE = 'MATERIAL'" ) @SQLRestriction( "CODE = 'MATERIAL'" )
public static class Material { public static class Material {
private int id; private int id;
@ -297,7 +297,7 @@ public class LazyManyToManyNonUniqueIdWhereTest extends BaseCoreFunctionalTestCa
joinColumns = { @JoinColumn( name = "MAIN_ID" ) }, joinColumns = { @JoinColumn( name = "MAIN_ID" ) },
inverseJoinColumns = { @JoinColumn( name = "ASSOCIATION_ID" ) } inverseJoinColumns = { @JoinColumn( name = "ASSOCIATION_ID" ) }
) )
@WhereJoinTable( clause = "MAIN_CODE='MATERIAL' AND ASSOCIATION_CODE='SIZE'") @SQLJoinTableRestriction("MAIN_CODE='MATERIAL' AND ASSOCIATION_CODE='SIZE'")
@Immutable @Immutable
public Set<Size> getSizesFromCombined() { public Set<Size> getSizesFromCombined() {
return sizesFromCombined; return sizesFromCombined;
@ -312,8 +312,8 @@ public class LazyManyToManyNonUniqueIdWhereTest extends BaseCoreFunctionalTestCa
joinColumns = { @JoinColumn( name = "MAIN_ID" ) }, joinColumns = { @JoinColumn( name = "MAIN_ID" ) },
inverseJoinColumns = { @JoinColumn( name = "ASSOCIATION_ID" ) } inverseJoinColumns = { @JoinColumn( name = "ASSOCIATION_ID" ) }
) )
@WhereJoinTable( clause = "MAIN_CODE='MATERIAL' AND ASSOCIATION_CODE='RATING'" ) @SQLJoinTableRestriction( "MAIN_CODE='MATERIAL' AND ASSOCIATION_CODE='RATING'" )
@Where( clause = "NAME = 'high' or NAME = 'medium'" ) @SQLRestriction( "NAME = 'high' or NAME = 'medium'" )
@Immutable @Immutable
public List<Rating> getMediumOrHighRatingsFromCombined() { public List<Rating> getMediumOrHighRatingsFromCombined() {
return mediumOrHighRatingsFromCombined; return mediumOrHighRatingsFromCombined;
@ -339,7 +339,7 @@ public class LazyManyToManyNonUniqueIdWhereTest extends BaseCoreFunctionalTestCa
@Entity( name = "Building" ) @Entity( name = "Building" )
@Table( name = "MAIN_TABLE" ) @Table( name = "MAIN_TABLE" )
@Where( clause = "CODE = 'BUILDING'" ) @SQLRestriction( "CODE = 'BUILDING'" )
public static class Building { public static class Building {
private int id; private int id;
private String name; private String name;
@ -370,7 +370,7 @@ public class LazyManyToManyNonUniqueIdWhereTest extends BaseCoreFunctionalTestCa
joinColumns = { @JoinColumn( name = "MAIN_ID" ) }, joinColumns = { @JoinColumn( name = "MAIN_ID" ) },
inverseJoinColumns = { @JoinColumn( name = "ASSOCIATION_ID" ) } inverseJoinColumns = { @JoinColumn( name = "ASSOCIATION_ID" ) }
) )
@WhereJoinTable( clause = "MAIN_CODE='BUILDING' AND ASSOCIATION_CODE='SIZE'") @SQLJoinTableRestriction("MAIN_CODE='BUILDING' AND ASSOCIATION_CODE='SIZE'")
@Immutable @Immutable
public Set<Size> getSizesFromCombined() { public Set<Size> getSizesFromCombined() {
return sizesFromCombined; return sizesFromCombined;
@ -385,7 +385,7 @@ public class LazyManyToManyNonUniqueIdWhereTest extends BaseCoreFunctionalTestCa
joinColumns = { @JoinColumn( name = "MAIN_ID" ) }, joinColumns = { @JoinColumn( name = "MAIN_ID" ) },
inverseJoinColumns = { @JoinColumn( name = "ASSOCIATION_ID" ) } inverseJoinColumns = { @JoinColumn( name = "ASSOCIATION_ID" ) }
) )
@WhereJoinTable( clause = "MAIN_CODE='BUILDING' AND ASSOCIATION_CODE='RATING'" ) @SQLJoinTableRestriction("MAIN_CODE='BUILDING' AND ASSOCIATION_CODE='RATING'" )
@Immutable @Immutable
public Set<Rating> getRatingsFromCombined() { public Set<Rating> getRatingsFromCombined() {
return ratingsFromCombined; return ratingsFromCombined;
@ -400,7 +400,7 @@ public class LazyManyToManyNonUniqueIdWhereTest extends BaseCoreFunctionalTestCa
joinColumns = { @JoinColumn( name = "BUILDING_ID") }, joinColumns = { @JoinColumn( name = "BUILDING_ID") },
inverseJoinColumns = { @JoinColumn( name = "RATING_ID" ) } inverseJoinColumns = { @JoinColumn( name = "RATING_ID" ) }
) )
@Where( clause = "NAME = 'high' or NAME = 'medium'" ) @SQLRestriction( "NAME = 'high' or NAME = 'medium'" )
@Immutable @Immutable
public List<Rating> getMediumOrHighRatings() { public List<Rating> getMediumOrHighRatings() {
return mediumOrHighRatings; return mediumOrHighRatings;
@ -412,7 +412,7 @@ public class LazyManyToManyNonUniqueIdWhereTest extends BaseCoreFunctionalTestCa
@Entity( name = "Size" ) @Entity( name = "Size" )
@Table( name = "MAIN_TABLE" ) @Table( name = "MAIN_TABLE" )
@Where( clause = "CODE = 'SIZE'" ) @SQLRestriction( "CODE = 'SIZE'" )
public static class Size { public static class Size {
private int id; private int id;
private String name; private String name;
@ -437,7 +437,7 @@ public class LazyManyToManyNonUniqueIdWhereTest extends BaseCoreFunctionalTestCa
@Entity( name = "Rating" ) @Entity( name = "Rating" )
@Table( name = "MAIN_TABLE" ) @Table( name = "MAIN_TABLE" )
@Where( clause = "CODE = 'RATING'" ) @SQLRestriction( "CODE = 'RATING'" )
public static class Rating { public static class Rating {
private int id; private int id;
private String name; private String name;

View File

@ -20,7 +20,7 @@ import jakarta.persistence.Table;
import org.hibernate.Hibernate; import org.hibernate.Hibernate;
import org.hibernate.annotations.Immutable; import org.hibernate.annotations.Immutable;
import org.hibernate.annotations.Where; import org.hibernate.annotations.SQLRestriction;
import org.hibernate.cfg.Configuration; import org.hibernate.cfg.Configuration;
import org.hibernate.metamodel.CollectionClassification; import org.hibernate.metamodel.CollectionClassification;
@ -174,7 +174,7 @@ public class LazyOneToManyNonUniqueIdWhereTest extends BaseCoreFunctionalTestCas
@Entity( name = "Material" ) @Entity( name = "Material" )
@Table( name = "MAIN_TABLE" ) @Table( name = "MAIN_TABLE" )
@Where( clause = "CODE = 'MATERIAL'" ) @SQLRestriction( "CODE = 'MATERIAL'" )
public static class Material { public static class Material {
private int id; private int id;
@ -211,7 +211,7 @@ public class LazyOneToManyNonUniqueIdWhereTest extends BaseCoreFunctionalTestCas
@OneToMany @OneToMany
@JoinColumn( name = "MATERIAL_OWNER_ID") @JoinColumn( name = "MATERIAL_OWNER_ID")
@Where( clause = "NAME = 'high' or NAME = 'medium'" ) @SQLRestriction( "NAME = 'high' or NAME = 'medium'" )
@Immutable @Immutable
public List<Rating> getMediumOrHighRatingsFromCombined() { public List<Rating> getMediumOrHighRatingsFromCombined() {
return mediumOrHighRatingsFromCombined; return mediumOrHighRatingsFromCombined;
@ -223,7 +223,7 @@ public class LazyOneToManyNonUniqueIdWhereTest extends BaseCoreFunctionalTestCas
@Entity( name = "Building" ) @Entity( name = "Building" )
@Table( name = "MAIN_TABLE" ) @Table( name = "MAIN_TABLE" )
@Where( clause = "CODE = 'BUILDING'" ) @SQLRestriction( "CODE = 'BUILDING'" )
public static class Building { public static class Building {
private int id; private int id;
private String name; private String name;
@ -271,7 +271,7 @@ public class LazyOneToManyNonUniqueIdWhereTest extends BaseCoreFunctionalTestCas
@Entity( name = "Size" ) @Entity( name = "Size" )
@Table( name = "MAIN_TABLE" ) @Table( name = "MAIN_TABLE" )
@Where( clause = "CODE = 'SIZE'" ) @SQLRestriction( "CODE = 'SIZE'" )
public static class Size { public static class Size {
private int id; private int id;
private String name; private String name;
@ -296,7 +296,7 @@ public class LazyOneToManyNonUniqueIdWhereTest extends BaseCoreFunctionalTestCas
@Entity( name = "Rating" ) @Entity( name = "Rating" )
@Table( name = "MAIN_TABLE" ) @Table( name = "MAIN_TABLE" )
@Where( clause = "CODE = 'RATING'" ) @SQLRestriction( "CODE = 'RATING'" )
public static class Rating { public static class Rating {
private int id; private int id;
private String name; private String name;

View File

@ -20,8 +20,8 @@ import jakarta.persistence.ManyToMany;
import jakarta.persistence.OneToMany; import jakarta.persistence.OneToMany;
import jakarta.persistence.Table; import jakarta.persistence.Table;
import org.hibernate.annotations.Where; import org.hibernate.annotations.SQLJoinTableRestriction;
import org.hibernate.annotations.WhereJoinTable; import org.hibernate.annotations.SQLRestriction;
import org.hibernate.cfg.AvailableSettings; import org.hibernate.cfg.AvailableSettings;
import org.hibernate.testing.TestForIssue; import org.hibernate.testing.TestForIssue;
@ -178,7 +178,7 @@ public class LazyToManyWhereDontUseClassWhereTest extends BaseNonConfigCoreFunct
@OneToMany(fetch = FetchType.LAZY) @OneToMany(fetch = FetchType.LAZY)
@JoinColumn @JoinColumn
@Where( clause = "description is not null" ) @SQLRestriction( "description is not null" )
private Set<Category> categoriesWithDescOneToMany = new HashSet<>(); private Set<Category> categoriesWithDescOneToMany = new HashSet<>();
@ManyToMany(fetch = FetchType.LAZY) @ManyToMany(fetch = FetchType.LAZY)
@ -187,19 +187,19 @@ public class LazyToManyWhereDontUseClassWhereTest extends BaseNonConfigCoreFunct
@ManyToMany(fetch = FetchType.LAZY) @ManyToMany(fetch = FetchType.LAZY)
@JoinTable(name = "categoriesWithDescManyToMany", inverseJoinColumns = { @JoinColumn( name = "categoryId" )}) @JoinTable(name = "categoriesWithDescManyToMany", inverseJoinColumns = { @JoinColumn( name = "categoryId" )})
@Where( clause = "description is not null" ) @SQLRestriction( "description is not null" )
private Set<Category> categoriesWithDescManyToMany = new HashSet<>(); private Set<Category> categoriesWithDescManyToMany = new HashSet<>();
@ManyToMany(fetch = FetchType.LAZY) @ManyToMany(fetch = FetchType.LAZY)
@JoinTable(name = "categoriesWithDescIdLt4MToM", inverseJoinColumns = { @JoinColumn( name = "categoryId" )}) @JoinTable(name = "categoriesWithDescIdLt4MToM", inverseJoinColumns = { @JoinColumn( name = "categoryId" )})
@Where( clause = "description is not null" ) @SQLRestriction( "description is not null" )
@WhereJoinTable( clause = "categoryId < 4") @SQLJoinTableRestriction( "categoryId < 4")
private Set<Category> categoriesWithDescIdLt4ManyToMany = new HashSet<>(); private Set<Category> categoriesWithDescIdLt4ManyToMany = new HashSet<>();
} }
@Entity(name = "Category") @Entity(name = "Category")
@Table(name = "CATEGORY") @Table(name = "CATEGORY")
@Where(clause = "inactive = 0") @SQLRestriction("inactive = 0")
public static class Category { public static class Category {
@Id @Id
private int id; private int id;

View File

@ -19,8 +19,8 @@ import jakarta.persistence.ManyToMany;
import jakarta.persistence.OneToMany; import jakarta.persistence.OneToMany;
import jakarta.persistence.Table; import jakarta.persistence.Table;
import org.hibernate.annotations.Where; import org.hibernate.annotations.SQLJoinTableRestriction;
import org.hibernate.annotations.WhereJoinTable; import org.hibernate.annotations.SQLRestriction;
import org.hibernate.testing.TestForIssue; import org.hibernate.testing.TestForIssue;
import org.hibernate.testing.junit4.BaseNonConfigCoreFunctionalTestCase; import org.hibernate.testing.junit4.BaseNonConfigCoreFunctionalTestCase;
@ -172,7 +172,7 @@ public class LazyToManyWhereTest extends BaseNonConfigCoreFunctionalTestCase {
@OneToMany(fetch = FetchType.LAZY) @OneToMany(fetch = FetchType.LAZY)
@JoinColumn @JoinColumn
@Where( clause = "description is not null" ) @SQLRestriction( "description is not null" )
private Set<Category> categoriesWithDescOneToMany = new HashSet<>(); private Set<Category> categoriesWithDescOneToMany = new HashSet<>();
@ManyToMany(fetch = FetchType.LAZY) @ManyToMany(fetch = FetchType.LAZY)
@ -181,19 +181,19 @@ public class LazyToManyWhereTest extends BaseNonConfigCoreFunctionalTestCase {
@ManyToMany(fetch = FetchType.LAZY) @ManyToMany(fetch = FetchType.LAZY)
@JoinTable(name = "categoriesWithDescManyToMany", inverseJoinColumns = { @JoinColumn( name = "categoryId" )}) @JoinTable(name = "categoriesWithDescManyToMany", inverseJoinColumns = { @JoinColumn( name = "categoryId" )})
@Where( clause = "description is not null" ) @SQLRestriction( "description is not null" )
private Set<Category> categoriesWithDescManyToMany = new HashSet<>(); private Set<Category> categoriesWithDescManyToMany = new HashSet<>();
@ManyToMany(fetch = FetchType.LAZY) @ManyToMany(fetch = FetchType.LAZY)
@JoinTable(name = "categoriesWithDescIdLt4MToM", inverseJoinColumns = { @JoinColumn( name = "categoryId" )}) @JoinTable(name = "categoriesWithDescIdLt4MToM", inverseJoinColumns = { @JoinColumn( name = "categoryId" )})
@Where( clause = "description is not null" ) @SQLRestriction("description is not null" )
@WhereJoinTable( clause = "categoryId < 4") @SQLJoinTableRestriction("categoryId < 4")
private Set<Category> categoriesWithDescIdLt4ManyToMany = new HashSet<>(); private Set<Category> categoriesWithDescIdLt4ManyToMany = new HashSet<>();
} }
@Entity(name = "Category") @Entity(name = "Category")
@Table(name = "CATEGORY") @Table(name = "CATEGORY")
@Where(clause = "inactive = 0") @SQLRestriction("inactive = 0")
public static class Category { public static class Category {
@Id @Id
private int id; private int id;

View File

@ -20,8 +20,8 @@ import jakarta.persistence.ManyToMany;
import jakarta.persistence.OneToMany; import jakarta.persistence.OneToMany;
import jakarta.persistence.Table; import jakarta.persistence.Table;
import org.hibernate.annotations.Where; import org.hibernate.annotations.SQLJoinTableRestriction;
import org.hibernate.annotations.WhereJoinTable; import org.hibernate.annotations.SQLRestriction;
import org.hibernate.cfg.AvailableSettings; import org.hibernate.cfg.AvailableSettings;
import org.hibernate.testing.TestForIssue; import org.hibernate.testing.TestForIssue;
@ -178,7 +178,7 @@ public class LazyToManyWhereUseClassWhereTest extends BaseNonConfigCoreFunctiona
@OneToMany(fetch = FetchType.LAZY) @OneToMany(fetch = FetchType.LAZY)
@JoinColumn @JoinColumn
@Where( clause = "description is not null" ) @SQLRestriction( "description is not null" )
private Set<Category> categoriesWithDescOneToMany = new HashSet<>(); private Set<Category> categoriesWithDescOneToMany = new HashSet<>();
@ManyToMany(fetch = FetchType.LAZY) @ManyToMany(fetch = FetchType.LAZY)
@ -187,19 +187,19 @@ public class LazyToManyWhereUseClassWhereTest extends BaseNonConfigCoreFunctiona
@ManyToMany(fetch = FetchType.LAZY) @ManyToMany(fetch = FetchType.LAZY)
@JoinTable(name = "categoriesWithDescManyToMany", inverseJoinColumns = { @JoinColumn( name = "categoryId" )}) @JoinTable(name = "categoriesWithDescManyToMany", inverseJoinColumns = { @JoinColumn( name = "categoryId" )})
@Where( clause = "description is not null" ) @SQLRestriction( "description is not null" )
private Set<Category> categoriesWithDescManyToMany = new HashSet<>(); private Set<Category> categoriesWithDescManyToMany = new HashSet<>();
@ManyToMany(fetch = FetchType.LAZY) @ManyToMany(fetch = FetchType.LAZY)
@JoinTable(name = "categoriesWithDescIdLt4MToM", inverseJoinColumns = { @JoinColumn( name = "categoryId" )}) @JoinTable(name = "categoriesWithDescIdLt4MToM", inverseJoinColumns = { @JoinColumn( name = "categoryId" )})
@Where( clause = "description is not null" ) @SQLRestriction("description is not null" )
@WhereJoinTable( clause = "categoryId < 4") @SQLJoinTableRestriction("categoryId < 4")
private Set<Category> categoriesWithDescIdLt4ManyToMany = new HashSet<>(); private Set<Category> categoriesWithDescIdLt4ManyToMany = new HashSet<>();
} }
@Entity(name = "Category") @Entity(name = "Category")
@Table(name = "CATEGORY") @Table(name = "CATEGORY")
@Where(clause = "inactive = 0") @SQLRestriction("inactive = 0")
public static class Category { public static class Category {
@Id @Id
private int id; private int id;

View File

@ -1,6 +1,6 @@
package org.hibernate.orm.test.where.annotations; package org.hibernate.orm.test.where.annotations;
import org.hibernate.annotations.Where; import org.hibernate.annotations.SQLRestriction;
import org.hibernate.cfg.AvailableSettings; import org.hibernate.cfg.AvailableSettings;
import org.hibernate.testing.TestForIssue; import org.hibernate.testing.TestForIssue;
@ -33,7 +33,7 @@ public class NullWhereClauseTest {
@Entity @Entity
@Table(name = "person") @Table(name = "person")
@Where(clause = "`used` IS NULL") @SQLRestriction("`used` IS NULL")
public static class Person { public static class Person {
@Id @Id
private Integer id; private Integer id;

View File

@ -14,7 +14,7 @@ import jakarta.persistence.JoinColumn;
import jakarta.persistence.JoinTable; import jakarta.persistence.JoinTable;
import jakarta.persistence.ManyToMany; import jakarta.persistence.ManyToMany;
import org.hibernate.annotations.WhereJoinTable; import org.hibernate.annotations.SQLJoinTableRestriction;
import org.hibernate.envers.Audited; import org.hibernate.envers.Audited;
import org.hibernate.orm.test.envers.entities.IntNoAutoIdTestEntity; import org.hibernate.orm.test.envers.entities.IntNoAutoIdTestEntity;
@ -36,7 +36,7 @@ public class WhereJoinTableEntity {
joinColumns = @JoinColumn(name = "wjte_id"), joinColumns = @JoinColumn(name = "wjte_id"),
inverseJoinColumns = @JoinColumn(name = "ite_id") inverseJoinColumns = @JoinColumn(name = "ite_id")
) )
@WhereJoinTable(clause = "ite_id < 20") @SQLJoinTableRestriction("ite_id < 20")
private List<IntNoAutoIdTestEntity> references1; private List<IntNoAutoIdTestEntity> references1;
@ManyToMany @ManyToMany
@ -45,7 +45,7 @@ public class WhereJoinTableEntity {
joinColumns = @JoinColumn(name = "wjte_id"), joinColumns = @JoinColumn(name = "wjte_id"),
inverseJoinColumns = @JoinColumn(name = "ite_id") inverseJoinColumns = @JoinColumn(name = "ite_id")
) )
@WhereJoinTable(clause = "ite_id >= 20") @SQLJoinTableRestriction("ite_id >= 20")
private List<IntNoAutoIdTestEntity> references2; private List<IntNoAutoIdTestEntity> references2;
public Integer getId() { public Integer getId() {

View File

@ -16,6 +16,7 @@ import jakarta.persistence.JoinColumn;
import jakarta.persistence.JoinTable; import jakarta.persistence.JoinTable;
import jakarta.persistence.ManyToMany; import jakarta.persistence.ManyToMany;
import org.hibernate.annotations.SQLJoinTableRestriction;
import org.hibernate.annotations.WhereJoinTable; import org.hibernate.annotations.WhereJoinTable;
import org.hibernate.envers.Audited; import org.hibernate.envers.Audited;
@ -49,7 +50,7 @@ public class Child1Entity {
joinColumns = @JoinColumn(name = "child1_id"), joinColumns = @JoinColumn(name = "child1_id"),
inverseJoinColumns = @JoinColumn(name = "parent_id", insertable = false, updatable = false) inverseJoinColumns = @JoinColumn(name = "parent_id", insertable = false, updatable = false)
) )
@WhereJoinTable(clause = "child1_id is not null") @SQLJoinTableRestriction("child1_id is not null")
private List<ParentEntity> parents = new ArrayList<ParentEntity>(); private List<ParentEntity> parents = new ArrayList<ParentEntity>();
public Integer getId() { public Integer getId() {

View File

@ -16,7 +16,7 @@ import jakarta.persistence.JoinColumn;
import jakarta.persistence.JoinTable; import jakarta.persistence.JoinTable;
import jakarta.persistence.ManyToMany; import jakarta.persistence.ManyToMany;
import org.hibernate.annotations.WhereJoinTable; import org.hibernate.annotations.SQLJoinTableRestriction;
import org.hibernate.envers.Audited; import org.hibernate.envers.Audited;
/** /**
@ -49,7 +49,7 @@ public class Child2Entity {
joinColumns = @JoinColumn(name = "child2_id"), joinColumns = @JoinColumn(name = "child2_id"),
inverseJoinColumns = @JoinColumn(name = "parent_id", insertable = false, updatable = false) inverseJoinColumns = @JoinColumn(name = "parent_id", insertable = false, updatable = false)
) )
@WhereJoinTable(clause = "child2_id is not null") @SQLJoinTableRestriction("child2_id is not null")
private List<ParentEntity> parents = new ArrayList<ParentEntity>(); private List<ParentEntity> parents = new ArrayList<ParentEntity>();
public Integer getId() { public Integer getId() {

View File

@ -16,7 +16,7 @@ import jakarta.persistence.JoinColumn;
import jakarta.persistence.JoinTable; import jakarta.persistence.JoinTable;
import jakarta.persistence.ManyToMany; import jakarta.persistence.ManyToMany;
import org.hibernate.annotations.WhereJoinTable; import org.hibernate.annotations.SQLJoinTableRestriction;
import org.hibernate.envers.Audited; import org.hibernate.envers.Audited;
/** /**
@ -49,7 +49,7 @@ public class ParentEntity {
joinColumns = @JoinColumn(name = "parent_id"), joinColumns = @JoinColumn(name = "parent_id"),
inverseJoinColumns = @JoinColumn(name = "child1_id", insertable = false, updatable = false) inverseJoinColumns = @JoinColumn(name = "child1_id", insertable = false, updatable = false)
) )
@WhereJoinTable(clause = "child1_id is not null") @SQLJoinTableRestriction("child1_id is not null")
private List<Child1Entity> children1 = new ArrayList<Child1Entity>(); private List<Child1Entity> children1 = new ArrayList<Child1Entity>();
@ManyToMany(fetch = FetchType.LAZY) @ManyToMany(fetch = FetchType.LAZY)
@ -58,7 +58,7 @@ public class ParentEntity {
joinColumns = @JoinColumn(name = "parent_id"), joinColumns = @JoinColumn(name = "parent_id"),
inverseJoinColumns = @JoinColumn(name = "child2_id", insertable = false, updatable = false) inverseJoinColumns = @JoinColumn(name = "child2_id", insertable = false, updatable = false)
) )
@WhereJoinTable(clause = "child2_id is not null") @SQLJoinTableRestriction("child2_id is not null")
private List<Child2Entity> children2 = new ArrayList<Child2Entity>(); private List<Child2Entity> children2 = new ArrayList<Child2Entity>();
public Integer getId() { public Integer getId() {

View File

@ -18,6 +18,7 @@ import jakarta.persistence.JoinColumn;
import jakarta.persistence.ManyToMany; import jakarta.persistence.ManyToMany;
import jakarta.persistence.Table; import jakarta.persistence.Table;
import org.hibernate.annotations.SQLRestriction;
import org.hibernate.annotations.Where; import org.hibernate.annotations.Where;
import org.hibernate.envers.AuditJoinTable; import org.hibernate.envers.AuditJoinTable;
import org.hibernate.envers.Audited; import org.hibernate.envers.Audited;
@ -116,7 +117,7 @@ public class BasicWhereTest extends BaseEnversJPAFunctionalTestCase {
@ManyToMany @ManyToMany
@JoinColumn(name = "allC") @JoinColumn(name = "allC")
@Where(clause = "type = 'C'") @SQLRestriction("type = 'C'")
@Audited(targetAuditMode = RelationTargetAuditMode.NOT_AUDITED) @Audited(targetAuditMode = RelationTargetAuditMode.NOT_AUDITED)
@AuditJoinTable(name = "A_C_AUD") @AuditJoinTable(name = "A_C_AUD")
private Set<EntityC> allMyC; private Set<EntityC> allMyC;
@ -190,7 +191,7 @@ public class BasicWhereTest extends BaseEnversJPAFunctionalTestCase {
private String name; private String name;
@ManyToMany @ManyToMany
@Where(clause = "type = 'Z'") @SQLRestriction("type = 'Z'")
@Audited(targetAuditMode = RelationTargetAuditMode.NOT_AUDITED) @Audited(targetAuditMode = RelationTargetAuditMode.NOT_AUDITED)
private Set<EntityZ> allMyZ; private Set<EntityZ> allMyZ;

View File

@ -18,6 +18,7 @@ import jakarta.persistence.JoinColumn;
import jakarta.persistence.OneToMany; import jakarta.persistence.OneToMany;
import jakarta.persistence.Table; import jakarta.persistence.Table;
import org.hibernate.annotations.SQLRestriction;
import org.hibernate.annotations.Where; import org.hibernate.annotations.Where;
import org.hibernate.envers.AuditJoinTable; import org.hibernate.envers.AuditJoinTable;
import org.hibernate.envers.Audited; import org.hibernate.envers.Audited;
@ -118,7 +119,7 @@ public class BasicWhereTest extends BaseEnversJPAFunctionalTestCase {
@OneToMany @OneToMany
@JoinColumn(name = "allC") @JoinColumn(name = "allC")
@Where(clause = "type = 'C'") @SQLRestriction("type = 'C'")
@Audited(targetAuditMode = RelationTargetAuditMode.NOT_AUDITED) @Audited(targetAuditMode = RelationTargetAuditMode.NOT_AUDITED)
@AuditJoinTable(name = "A_C_AUD") @AuditJoinTable(name = "A_C_AUD")
private Set<EntityC> allMyC; private Set<EntityC> allMyC;
@ -192,7 +193,7 @@ public class BasicWhereTest extends BaseEnversJPAFunctionalTestCase {
private String name; private String name;
@OneToMany @OneToMany
@Where(clause = "type = 'Z'") @SQLRestriction("type = 'Z'")
@Audited(targetAuditMode = RelationTargetAuditMode.NOT_AUDITED) @Audited(targetAuditMode = RelationTargetAuditMode.NOT_AUDITED)
private Set<EntityZ> allMyZ; private Set<EntityZ> allMyZ;

View File

@ -25,7 +25,7 @@ import jakarta.persistence.MapKeyEnumerated;
import jakarta.persistence.MapKeyJoinColumn; import jakarta.persistence.MapKeyJoinColumn;
import jakarta.persistence.OneToMany; import jakarta.persistence.OneToMany;
import org.hibernate.annotations.OrderBy; import org.hibernate.annotations.SQLOrder;
import org.hibernate.annotations.SortComparator; import org.hibernate.annotations.SortComparator;
import org.hibernate.annotations.SortNatural; import org.hibernate.annotations.SortNatural;
@ -367,7 +367,7 @@ public class EntityOfMaps {
@ElementCollection @ElementCollection
@MapKeyColumn( name = "ordered_component_key") @MapKeyColumn( name = "ordered_component_key")
@OrderBy( clause = "ordered_component_key, ordered_component_key" ) @SQLOrder( "ordered_component_key, ordered_component_key" )
@CollectionTable(name = "EntityOfMaps_comp_basic2") @CollectionTable(name = "EntityOfMaps_comp_basic2")
public Map<String, SimpleComponent> getComponentByBasicOrdered() { public Map<String, SimpleComponent> getComponentByBasicOrdered() {
return componentByBasicOrdered; return componentByBasicOrdered;