HHH-16163 update tests to use new annotations
This commit is contained in:
parent
e6c8fbc7af
commit
7b8cd14052
|
@ -13,7 +13,7 @@ import jakarta.persistence.Enumerated;
|
|||
import jakarta.persistence.GeneratedValue;
|
||||
import jakarta.persistence.Id;
|
||||
|
||||
import org.hibernate.annotations.Where;
|
||||
import org.hibernate.annotations.SQLRestriction;
|
||||
|
||||
/**
|
||||
*
|
||||
|
@ -21,7 +21,7 @@ import org.hibernate.annotations.Where;
|
|||
*
|
||||
*/
|
||||
@Entity
|
||||
@Where(clause = "yearsExperience > 3")
|
||||
@SQLRestriction("yearsExperience > 3")
|
||||
public class Doctor {
|
||||
private Integer id;
|
||||
private String name;
|
||||
|
|
|
@ -17,7 +17,7 @@ import jakarta.persistence.Id;
|
|||
import jakarta.persistence.OneToMany;
|
||||
import jakarta.persistence.OneToOne;
|
||||
|
||||
import org.hibernate.annotations.Where;
|
||||
import org.hibernate.annotations.SQLRestriction;
|
||||
|
||||
@Entity
|
||||
public class SoccerTeam {
|
||||
|
@ -28,7 +28,7 @@ public class SoccerTeam {
|
|||
String name;
|
||||
|
||||
@OneToMany
|
||||
@Where(clause = "activeLicense = true")
|
||||
@SQLRestriction("activeLicense = true")
|
||||
private List<Doctor> physiologists = new ArrayList<Doctor>();
|
||||
|
||||
@OneToMany(mappedBy="team",
|
||||
|
|
|
@ -18,8 +18,8 @@ import jakarta.persistence.Table;
|
|||
import org.hibernate.annotations.Filter;
|
||||
import org.hibernate.annotations.FilterDef;
|
||||
import org.hibernate.annotations.FilterJoinTable;
|
||||
import org.hibernate.annotations.Where;
|
||||
import org.hibernate.annotations.WhereJoinTable;
|
||||
import org.hibernate.annotations.SQLJoinTableRestriction;
|
||||
import org.hibernate.annotations.SQLRestriction;
|
||||
|
||||
/**
|
||||
* @author Emmanuel Bernard
|
||||
|
@ -42,8 +42,8 @@ public class Group {
|
|||
|
||||
@ManyToMany(cascade = CascadeType.PERSIST)
|
||||
@OrderBy("expirationDate")
|
||||
@Where(clause = "1=1")
|
||||
@WhereJoinTable(clause = "2=2")
|
||||
@SQLRestriction("1=1")
|
||||
@SQLJoinTableRestriction("2=2")
|
||||
@Filter(name="Groupfilter", condition = "3=3")
|
||||
@FilterJoinTable(name="Groupfilter", condition = "4=4")
|
||||
public Collection<Permission> getPermissions() {
|
||||
|
|
|
@ -17,10 +17,9 @@ import jakarta.persistence.OrderBy;
|
|||
import jakarta.persistence.Table;
|
||||
|
||||
import org.hibernate.annotations.Filter;
|
||||
import org.hibernate.annotations.FilterDef;
|
||||
import org.hibernate.annotations.FilterJoinTable;
|
||||
import org.hibernate.annotations.Where;
|
||||
import org.hibernate.annotations.WhereJoinTable;
|
||||
import org.hibernate.annotations.SQLJoinTableRestriction;
|
||||
import org.hibernate.annotations.SQLRestriction;
|
||||
|
||||
/**
|
||||
* @author Emmanuel Bernard
|
||||
|
@ -42,8 +41,8 @@ public class GroupWithSet {
|
|||
|
||||
@ManyToMany(cascade = CascadeType.PERSIST)
|
||||
@OrderBy("expirationDate")
|
||||
@Where(clause = "1=1")
|
||||
@WhereJoinTable(clause = "2=2")
|
||||
@SQLRestriction("1=1")
|
||||
@SQLJoinTableRestriction("2=2")
|
||||
@Filter(name="Groupfilter", condition = "3=3")
|
||||
@FilterJoinTable(name="Groupfilter", condition = "4=4")
|
||||
public Set<Permission> getPermissions() {
|
||||
|
|
|
@ -18,7 +18,7 @@ import jakarta.persistence.OneToMany;
|
|||
|
||||
import org.hibernate.annotations.OnDelete;
|
||||
import org.hibernate.annotations.OnDeleteAction;
|
||||
import org.hibernate.annotations.OrderBy;
|
||||
import org.hibernate.annotations.SQLOrder;
|
||||
|
||||
/**
|
||||
* Shows a default one to many
|
||||
|
@ -32,7 +32,7 @@ public class Troop {
|
|||
private Set<Soldier> soldiers;
|
||||
|
||||
@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)
|
||||
@OnDelete(action = OnDeleteAction.CASCADE)
|
||||
public Set<Soldier> getSoldiers() {
|
||||
|
|
|
@ -14,6 +14,7 @@ import jakarta.persistence.GeneratedValue;
|
|||
import jakarta.persistence.Id;
|
||||
import jakarta.persistence.JoinColumn;
|
||||
import jakarta.persistence.OneToMany;
|
||||
import org.hibernate.annotations.SQLOrder;
|
||||
|
||||
/**
|
||||
* Entity used to test {@code NULL} values ordering in SQL {@code ORDER BY} clause.
|
||||
|
@ -30,7 +31,7 @@ public class Zoo implements Serializable {
|
|||
|
||||
@OneToMany
|
||||
@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>();
|
||||
|
||||
@OneToMany
|
||||
|
|
|
@ -16,6 +16,7 @@ import java.util.HashSet;
|
|||
import java.util.Set;
|
||||
|
||||
import org.hibernate.annotations.GenericGenerator;
|
||||
import org.hibernate.annotations.SQLOrder;
|
||||
|
||||
/**
|
||||
* @author Steve Ebersole
|
||||
|
@ -69,7 +70,7 @@ public class Zoo {
|
|||
|
||||
@OneToMany
|
||||
@JoinColumn
|
||||
@org.hibernate.annotations.OrderBy( clause = "weight" )
|
||||
@SQLOrder( "weight" )
|
||||
public Set<Lion> getLions() {
|
||||
return lions;
|
||||
}
|
||||
|
|
|
@ -24,6 +24,7 @@ import jakarta.persistence.TypedQuery;
|
|||
|
||||
import org.hibernate.annotations.ResultCheckStyle;
|
||||
import org.hibernate.annotations.SQLDelete;
|
||||
import org.hibernate.annotations.SQLRestriction;
|
||||
import org.hibernate.annotations.Where;
|
||||
import org.hibernate.dialect.H2Dialect;
|
||||
import org.hibernate.dialect.PostgreSQLDialect;
|
||||
|
@ -141,7 +142,7 @@ public class WhereClauseOrderBySizeTest extends BaseEntityManagerFunctionalTestC
|
|||
|
||||
@Entity(name = "Book")
|
||||
@SQLDelete(sql = "UPDATE Book SET deleted = true WHERE id = ?", check = ResultCheckStyle.COUNT)
|
||||
@Where(clause = "deleted = false")
|
||||
@SQLRestriction("deleted = false")
|
||||
public static class Book {
|
||||
@Id
|
||||
@GeneratedValue
|
||||
|
|
|
@ -10,10 +10,10 @@ import jakarta.persistence.Entity;
|
|||
import jakarta.persistence.Id;
|
||||
import jakarta.persistence.ManyToOne;
|
||||
|
||||
import org.hibernate.annotations.Where;
|
||||
import org.hibernate.annotations.SQLRestriction;
|
||||
|
||||
@Entity
|
||||
@Where(clause = "deleted = false")
|
||||
@SQLRestriction("deleted = false")
|
||||
public class City {
|
||||
|
||||
@Id
|
||||
|
|
|
@ -19,6 +19,7 @@ import org.hibernate.annotations.Cache;
|
|||
import org.hibernate.annotations.CacheConcurrencyStrategy;
|
||||
import org.hibernate.annotations.Fetch;
|
||||
import org.hibernate.annotations.FetchMode;
|
||||
import org.hibernate.annotations.SQLRestriction;
|
||||
import org.hibernate.annotations.SortNatural;
|
||||
import org.hibernate.annotations.Where;
|
||||
|
||||
|
@ -104,7 +105,7 @@ public class InsertOrderingSelfReferenceTest extends BaseInsertOrderingTest {
|
|||
|
||||
@OneToMany(cascade = CascadeType.ALL, orphanRemoval = true, mappedBy = "parent")
|
||||
@SortNatural
|
||||
@Where(clause = "TYPE = 'INPUT'")
|
||||
@SQLRestriction("TYPE = 'INPUT'")
|
||||
@Fetch(FetchMode.SUBSELECT)
|
||||
List<InputParameter> children = new ArrayList<>();
|
||||
}
|
||||
|
@ -118,7 +119,7 @@ public class InsertOrderingSelfReferenceTest extends BaseInsertOrderingTest {
|
|||
|
||||
@OneToMany(cascade = CascadeType.ALL, orphanRemoval = true, mappedBy = "parent")
|
||||
@SortNatural
|
||||
@Where(clause = "TYPE = 'OUTPUT'")
|
||||
@SQLRestriction("TYPE = 'OUTPUT'")
|
||||
@Fetch(FetchMode.SUBSELECT)
|
||||
@Cache(usage = CacheConcurrencyStrategy.READ_WRITE)
|
||||
List<OutputParameter> children = new ArrayList<>();
|
||||
|
|
|
@ -18,7 +18,7 @@ import jakarta.persistence.GeneratedValue;
|
|||
import jakarta.persistence.Id;
|
||||
import jakarta.persistence.OneToMany;
|
||||
|
||||
import org.hibernate.annotations.OrderBy;
|
||||
import org.hibernate.annotations.SQLOrder;
|
||||
|
||||
/**
|
||||
* @author Emmanuel Bernard
|
||||
|
@ -30,7 +30,7 @@ public class Troop implements Serializable {
|
|||
private Set<Soldier> soldiers;
|
||||
|
||||
@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})
|
||||
public Set<Soldier> getSoldiers() {
|
||||
return soldiers;
|
||||
|
|
|
@ -6,7 +6,7 @@
|
|||
*/
|
||||
package org.hibernate.orm.test.manytomany;
|
||||
|
||||
import org.hibernate.annotations.Where;
|
||||
import org.hibernate.annotations.SQLRestriction;
|
||||
|
||||
import jakarta.persistence.Entity;
|
||||
import jakarta.persistence.FetchType;
|
||||
|
@ -25,7 +25,7 @@ public class Advertisement {
|
|||
@GeneratedValue
|
||||
private Integer id;
|
||||
|
||||
@Where(clause = "deleted <> 'true'")
|
||||
@SQLRestriction("deleted <> 'true'")
|
||||
@ManyToMany(fetch = FetchType.EAGER, mappedBy = "advertisements")
|
||||
@OrderBy("id asc")
|
||||
private Set<Attachment> attachments;
|
||||
|
|
|
@ -18,6 +18,7 @@ import jakarta.persistence.Id;
|
|||
import jakarta.persistence.ManyToOne;
|
||||
import jakarta.persistence.OneToMany;
|
||||
|
||||
import org.hibernate.annotations.SQLOrder;
|
||||
import org.hibernate.dialect.H2Dialect;
|
||||
import org.hibernate.metamodel.CollectionClassification;
|
||||
import org.hibernate.orm.test.jpa.BaseEntityManagerFunctionalTestCase;
|
||||
|
@ -94,9 +95,7 @@ public class OrderedBySQLTest extends BaseEntityManagerFunctionalTestCase {
|
|||
mappedBy = "person",
|
||||
cascade = CascadeType.ALL
|
||||
)
|
||||
@org.hibernate.annotations.OrderBy(
|
||||
clause = "CHAR_LENGTH(name) DESC"
|
||||
)
|
||||
@SQLOrder("CHAR_LENGTH(name) DESC")
|
||||
private List<Article> articles = new ArrayList<>();
|
||||
|
||||
//Getters and setters are omitted for brevity
|
||||
|
|
|
@ -8,7 +8,7 @@ package org.hibernate.orm.test.mapping.where;
|
|||
|
||||
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.JiraKey;
|
||||
|
@ -71,7 +71,7 @@ public class DiscriminatorWhereTest {
|
|||
|
||||
@OneToMany
|
||||
@JoinColumn(name = "allC")
|
||||
@Where(clause = "type = 'C'")
|
||||
@SQLRestriction("type = 'C'")
|
||||
private Set<EntityC> allMyC;
|
||||
|
||||
public Integer getId() {
|
||||
|
|
|
@ -6,7 +6,7 @@
|
|||
*/
|
||||
package org.hibernate.orm.test.mapping.where;
|
||||
|
||||
import org.hibernate.annotations.Where;
|
||||
import org.hibernate.annotations.SQLRestriction;
|
||||
|
||||
import jakarta.persistence.Column;
|
||||
import jakarta.persistence.Entity;
|
||||
|
@ -19,7 +19,7 @@ import static jakarta.persistence.FetchType.LAZY;
|
|||
import static java.text.MessageFormat.format;
|
||||
import static java.util.Objects.hash;
|
||||
|
||||
@Where(clause = "is_active = true")
|
||||
@SQLRestriction("is_active = true")
|
||||
@Table(name = "t_user_details")
|
||||
@Entity(name = "UserDetail")
|
||||
public class UserDetail {
|
||||
|
|
|
@ -6,7 +6,7 @@
|
|||
*/
|
||||
package org.hibernate.orm.test.mapping.where;
|
||||
|
||||
import org.hibernate.annotations.Where;
|
||||
import org.hibernate.annotations.SQLRestriction;
|
||||
|
||||
import jakarta.persistence.Column;
|
||||
import jakarta.persistence.Entity;
|
||||
|
@ -19,7 +19,7 @@ import static jakarta.persistence.FetchType.LAZY;
|
|||
import static java.text.MessageFormat.format;
|
||||
import static java.util.Objects.hash;
|
||||
|
||||
@Where(clause = "has_deleted = false")
|
||||
@SQLRestriction("has_deleted = false")
|
||||
@Table(name = "t_user_skills")
|
||||
@Entity(name = "UserSkill")
|
||||
public class UserSkill {
|
||||
|
|
|
@ -18,7 +18,7 @@ import jakarta.persistence.JoinTable;
|
|||
import jakarta.persistence.ManyToMany;
|
||||
|
||||
import org.hibernate.Session;
|
||||
import org.hibernate.annotations.WhereJoinTable;
|
||||
import org.hibernate.annotations.SQLJoinTableRestriction;
|
||||
import org.hibernate.dialect.H2Dialect;
|
||||
import org.hibernate.metamodel.CollectionClassification;
|
||||
import org.hibernate.orm.test.jpa.BaseEntityManagerFunctionalTestCase;
|
||||
|
@ -127,7 +127,7 @@ public class WhereJoinTableTest extends BaseEntityManagerFunctionalTestCase {
|
|||
joinColumns = @JoinColumn(name = "book_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<>();
|
||||
|
||||
//Getters and setters omitted for brevity
|
||||
|
|
|
@ -18,7 +18,7 @@ import jakarta.persistence.Id;
|
|||
import jakarta.persistence.ManyToOne;
|
||||
import jakarta.persistence.OneToMany;
|
||||
|
||||
import org.hibernate.annotations.Where;
|
||||
import org.hibernate.annotations.SQLRestriction;
|
||||
import org.hibernate.metamodel.CollectionClassification;
|
||||
import org.hibernate.orm.test.jpa.BaseEntityManagerFunctionalTestCase;
|
||||
|
||||
|
@ -122,11 +122,11 @@ public class WhereTest extends BaseEntityManagerFunctionalTestCase {
|
|||
|
||||
private String name;
|
||||
|
||||
@Where(clause = "account_type = 'DEBIT'")
|
||||
@SQLRestriction("account_type = 'DEBIT'")
|
||||
@OneToMany(mappedBy = "client")
|
||||
private List<Account> debitAccounts = new ArrayList<>();
|
||||
|
||||
@Where(clause = "account_type = 'CREDIT'")
|
||||
@SQLRestriction("account_type = 'CREDIT'")
|
||||
@OneToMany(mappedBy = "client")
|
||||
private List<Account> creditAccounts = new ArrayList<>();
|
||||
|
||||
|
@ -160,7 +160,7 @@ public class WhereTest extends BaseEntityManagerFunctionalTestCase {
|
|||
}
|
||||
|
||||
@Entity(name = "Account")
|
||||
@Where(clause = "active = true")
|
||||
@SQLRestriction("active = true")
|
||||
public static class Account {
|
||||
|
||||
@Id
|
||||
|
|
|
@ -7,7 +7,7 @@ import jakarta.persistence.Id;
|
|||
import jakarta.persistence.Inheritance;
|
||||
import jakarta.persistence.InheritanceType;
|
||||
|
||||
import org.hibernate.annotations.Where;
|
||||
import org.hibernate.annotations.SQLRestriction;
|
||||
|
||||
import org.hibernate.testing.TestForIssue;
|
||||
import org.hibernate.testing.junit4.BaseCoreFunctionalTestCase;
|
||||
|
@ -36,7 +36,7 @@ public class HHH14112Test extends BaseCoreFunctionalTestCase {
|
|||
|
||||
@Entity(name = "Super")
|
||||
@Inheritance(strategy = InheritanceType.JOINED)
|
||||
@Where(clause = "deleted = false")
|
||||
@SQLRestriction("deleted = false")
|
||||
public static class Super {
|
||||
@Id
|
||||
@GeneratedValue(strategy = GenerationType.AUTO)
|
||||
|
|
|
@ -24,8 +24,8 @@ import org.hibernate.annotations.ResultCheckStyle;
|
|||
import org.hibernate.annotations.SQLDelete;
|
||||
import org.hibernate.annotations.SQLDeleteAll;
|
||||
import org.hibernate.annotations.SQLInsert;
|
||||
import org.hibernate.annotations.SQLRestriction;
|
||||
import org.hibernate.annotations.SQLUpdate;
|
||||
import org.hibernate.annotations.Where;
|
||||
import org.hibernate.dialect.H2Dialect;
|
||||
import org.hibernate.dialect.PostgreSQLDialect;
|
||||
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) ")
|
||||
@SQLDeleteAll(
|
||||
sql = "UPDATE person_phones SET valid = false WHERE person_id = ?")
|
||||
@Where(clause = "valid = true")
|
||||
@SQLRestriction("valid = true")
|
||||
private List<String> phones = new ArrayList<>();
|
||||
|
||||
//Getters and setters are omitted for brevity
|
||||
|
|
|
@ -4,7 +4,7 @@ import java.util.ArrayList;
|
|||
import java.util.Date;
|
||||
import java.util.List;
|
||||
|
||||
import org.hibernate.annotations.Where;
|
||||
import org.hibernate.annotations.SQLRestriction;
|
||||
|
||||
import org.hibernate.testing.TestForIssue;
|
||||
import org.hibernate.testing.orm.junit.EntityManagerFactoryScope;
|
||||
|
@ -134,7 +134,7 @@ public class EagerManyToOne2Test {
|
|||
private String name;
|
||||
|
||||
@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<>();
|
||||
|
||||
public Parent() {
|
||||
|
|
|
@ -4,13 +4,11 @@ import java.util.ArrayList;
|
|||
import java.util.Date;
|
||||
import java.util.List;
|
||||
|
||||
import org.hibernate.annotations.Where;
|
||||
import org.hibernate.cfg.AvailableSettings;
|
||||
import org.hibernate.annotations.SQLRestriction;
|
||||
|
||||
import org.hibernate.testing.TestForIssue;
|
||||
import org.hibernate.testing.orm.junit.EntityManagerFactoryScope;
|
||||
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.Test;
|
||||
|
||||
|
@ -100,7 +98,7 @@ public class EagerManyToOne3Test {
|
|||
|
||||
@Entity(name = "Child")
|
||||
@Table(name = "children")
|
||||
@Where(clause = "deleted_at IS NULL")
|
||||
@SQLRestriction("deleted_at IS NULL")
|
||||
public static class Child {
|
||||
@Id
|
||||
private Long id;
|
||||
|
|
|
@ -23,7 +23,7 @@ import org.hibernate.annotations.Fetch;
|
|||
import org.hibernate.annotations.FetchMode;
|
||||
import org.hibernate.annotations.NotFound;
|
||||
import org.hibernate.annotations.NotFoundAction;
|
||||
import org.hibernate.annotations.Where;
|
||||
import org.hibernate.annotations.SQLRestriction;
|
||||
|
||||
import org.hibernate.testing.FailureExpected;
|
||||
import org.hibernate.testing.TestForIssue;
|
||||
|
@ -131,7 +131,7 @@ public class EagerManyToOneFetchModeJoinWhereTest extends BaseNonConfigCoreFunct
|
|||
|
||||
@Entity(name = "Category")
|
||||
@Table(name = "CATEGORY")
|
||||
@Where(clause = "inactive = 0")
|
||||
@SQLRestriction("inactive = 0")
|
||||
public static class Category {
|
||||
@Id
|
||||
@GeneratedValue
|
||||
|
|
|
@ -24,7 +24,7 @@ import org.hibernate.annotations.Fetch;
|
|||
import org.hibernate.annotations.FetchMode;
|
||||
import org.hibernate.annotations.NotFound;
|
||||
import org.hibernate.annotations.NotFoundAction;
|
||||
import org.hibernate.annotations.Where;
|
||||
import org.hibernate.annotations.SQLRestriction;
|
||||
import org.hibernate.cfg.AvailableSettings;
|
||||
|
||||
import org.hibernate.testing.TestForIssue;
|
||||
|
@ -136,7 +136,7 @@ public class EagerManyToOneFetchModeSelectWhereTest extends BaseNonConfigCoreFun
|
|||
|
||||
@Entity(name = "Category")
|
||||
@Table(name = "CATEGORY")
|
||||
@Where(clause = "inactive = 0")
|
||||
@SQLRestriction("inactive = 0")
|
||||
public static class Category {
|
||||
@Id
|
||||
@GeneratedValue
|
||||
|
|
|
@ -4,7 +4,7 @@ import java.util.ArrayList;
|
|||
import java.util.Date;
|
||||
import java.util.List;
|
||||
|
||||
import org.hibernate.annotations.Where;
|
||||
import org.hibernate.annotations.SQLRestriction;
|
||||
import org.hibernate.cfg.AvailableSettings;
|
||||
|
||||
import org.hibernate.testing.TestForIssue;
|
||||
|
@ -88,7 +88,7 @@ public class EagerManyToOneTest {
|
|||
|
||||
@Entity(name = "Child")
|
||||
@Table(name = "children")
|
||||
@Where(clause = "deleted_at IS NULL")
|
||||
@SQLRestriction("deleted_at IS NULL")
|
||||
public static class Child {
|
||||
@Id
|
||||
private Long id;
|
||||
|
|
|
@ -20,8 +20,8 @@ import jakarta.persistence.ManyToMany;
|
|||
import jakarta.persistence.OneToMany;
|
||||
import jakarta.persistence.Table;
|
||||
|
||||
import org.hibernate.annotations.Where;
|
||||
import org.hibernate.annotations.WhereJoinTable;
|
||||
import org.hibernate.annotations.SQLJoinTableRestriction;
|
||||
import org.hibernate.annotations.SQLRestriction;
|
||||
import org.hibernate.cfg.AvailableSettings;
|
||||
|
||||
import org.hibernate.testing.TestForIssue;
|
||||
|
@ -178,7 +178,7 @@ public class EagerToManyWhereDontUseClassWhereTest extends BaseNonConfigCoreFunc
|
|||
|
||||
@OneToMany(fetch = FetchType.EAGER)
|
||||
@JoinColumn
|
||||
@Where( clause = "description is not null" )
|
||||
@SQLRestriction( "description is not null" )
|
||||
private Set<Category> categoriesWithDescOneToMany = new HashSet<>();
|
||||
|
||||
@ManyToMany(fetch = FetchType.EAGER)
|
||||
|
@ -187,19 +187,19 @@ public class EagerToManyWhereDontUseClassWhereTest extends BaseNonConfigCoreFunc
|
|||
|
||||
@ManyToMany(fetch = FetchType.EAGER)
|
||||
@JoinTable(name = "categoriesWithDescManyToMany", inverseJoinColumns = { @JoinColumn( name = "categoryId" )})
|
||||
@Where( clause = "description is not null" )
|
||||
@SQLRestriction( "description is not null" )
|
||||
private Set<Category> categoriesWithDescManyToMany = new HashSet<>();
|
||||
|
||||
@ManyToMany(fetch = FetchType.EAGER)
|
||||
@JoinTable(name = "categoriesWithDescIdLt4MToM", inverseJoinColumns = { @JoinColumn( name = "categoryId" )})
|
||||
@Where( clause = "description is not null" )
|
||||
@WhereJoinTable( clause = "categoryId < 4")
|
||||
@SQLRestriction( "description is not null" )
|
||||
@SQLJoinTableRestriction( "categoryId < 4")
|
||||
private Set<Category> categoriesWithDescIdLt4ManyToMany = new HashSet<>();
|
||||
}
|
||||
|
||||
@Entity(name = "Category")
|
||||
@Table(name = "CATEGORY")
|
||||
@Where(clause = "inactive = 0")
|
||||
@SQLRestriction( "inactive = 0")
|
||||
public static class Category {
|
||||
@Id
|
||||
private int id;
|
||||
|
|
|
@ -19,8 +19,8 @@ import jakarta.persistence.ManyToMany;
|
|||
import jakarta.persistence.OneToMany;
|
||||
import jakarta.persistence.Table;
|
||||
|
||||
import org.hibernate.annotations.Where;
|
||||
import org.hibernate.annotations.WhereJoinTable;
|
||||
import org.hibernate.annotations.SQLJoinTableRestriction;
|
||||
import org.hibernate.annotations.SQLRestriction;
|
||||
|
||||
import org.hibernate.testing.TestForIssue;
|
||||
import org.hibernate.testing.junit4.BaseNonConfigCoreFunctionalTestCase;
|
||||
|
@ -172,7 +172,7 @@ public class EagerToManyWhereTest extends BaseNonConfigCoreFunctionalTestCase {
|
|||
|
||||
@OneToMany(fetch = FetchType.EAGER)
|
||||
@JoinColumn
|
||||
@Where( clause = "description is not null" )
|
||||
@SQLRestriction( "description is not null" )
|
||||
private Set<Category> categoriesWithDescOneToMany = new HashSet<>();
|
||||
|
||||
@ManyToMany(fetch = FetchType.EAGER)
|
||||
|
@ -181,19 +181,19 @@ public class EagerToManyWhereTest extends BaseNonConfigCoreFunctionalTestCase {
|
|||
|
||||
@ManyToMany(fetch = FetchType.EAGER)
|
||||
@JoinTable(name = "categoriesWithDescManyToMany", inverseJoinColumns = { @JoinColumn( name = "categoryId" )})
|
||||
@Where( clause = "description is not null" )
|
||||
@SQLRestriction( "description is not null" )
|
||||
private Set<Category> categoriesWithDescManyToMany = new HashSet<>();
|
||||
|
||||
@ManyToMany(fetch = FetchType.EAGER)
|
||||
@JoinTable(name = "categoriesWithDescIdLt4MToM", inverseJoinColumns = { @JoinColumn( name = "categoryId" )})
|
||||
@Where( clause = "description is not null" )
|
||||
@WhereJoinTable( clause = "categoryId < 4")
|
||||
@SQLRestriction( "description is not null" )
|
||||
@SQLJoinTableRestriction( "categoryId < 4")
|
||||
private Set<Category> categoriesWithDescIdLt4ManyToMany = new HashSet<>();
|
||||
}
|
||||
|
||||
@Entity(name = "Category")
|
||||
@Table(name = "CATEGORY")
|
||||
@Where(clause = "inactive = 0")
|
||||
@SQLRestriction("inactive = 0")
|
||||
public static class Category {
|
||||
@Id
|
||||
private int id;
|
||||
|
|
|
@ -20,8 +20,8 @@ import jakarta.persistence.ManyToMany;
|
|||
import jakarta.persistence.OneToMany;
|
||||
import jakarta.persistence.Table;
|
||||
|
||||
import org.hibernate.annotations.Where;
|
||||
import org.hibernate.annotations.WhereJoinTable;
|
||||
import org.hibernate.annotations.SQLJoinTableRestriction;
|
||||
import org.hibernate.annotations.SQLRestriction;
|
||||
import org.hibernate.cfg.AvailableSettings;
|
||||
|
||||
import org.hibernate.testing.TestForIssue;
|
||||
|
@ -178,7 +178,7 @@ public class EagerToManyWhereUseClassWhereTest extends BaseNonConfigCoreFunction
|
|||
|
||||
@OneToMany(fetch = FetchType.EAGER)
|
||||
@JoinColumn
|
||||
@Where( clause = "description is not null" )
|
||||
@SQLRestriction( "description is not null" )
|
||||
private Set<Category> categoriesWithDescOneToMany = new HashSet<>();
|
||||
|
||||
@ManyToMany(fetch = FetchType.EAGER)
|
||||
|
@ -187,19 +187,19 @@ public class EagerToManyWhereUseClassWhereTest extends BaseNonConfigCoreFunction
|
|||
|
||||
@ManyToMany(fetch = FetchType.EAGER)
|
||||
@JoinTable(name = "categoriesWithDescManyToMany", inverseJoinColumns = { @JoinColumn( name = "categoryId" )})
|
||||
@Where( clause = "description is not null" )
|
||||
@SQLRestriction( "description is not null" )
|
||||
private Set<Category> categoriesWithDescManyToMany = new HashSet<>();
|
||||
|
||||
@ManyToMany(fetch = FetchType.EAGER)
|
||||
@JoinTable(name = "categoriesWithDescIdLt4MToM", inverseJoinColumns = { @JoinColumn( name = "categoryId" )})
|
||||
@Where( clause = "description is not null" )
|
||||
@WhereJoinTable( clause = "categoryId < 4")
|
||||
@SQLRestriction( "description is not null" )
|
||||
@SQLJoinTableRestriction("categoryId < 4")
|
||||
private Set<Category> categoriesWithDescIdLt4ManyToMany = new HashSet<>();
|
||||
}
|
||||
|
||||
@Entity(name = "Category")
|
||||
@Table(name = "CATEGORY")
|
||||
@Where(clause = "inactive = 0")
|
||||
@SQLRestriction("inactive = 0")
|
||||
public static class Category {
|
||||
@Id
|
||||
private int id;
|
||||
|
|
|
@ -15,16 +15,14 @@ import jakarta.persistence.JoinTable;
|
|||
import jakarta.persistence.ManyToMany;
|
||||
import jakarta.persistence.OneToMany;
|
||||
import jakarta.persistence.Table;
|
||||
import org.hibernate.annotations.Where;
|
||||
import org.hibernate.annotations.WhereJoinTable;
|
||||
import org.hibernate.cfg.AvailableSettings;
|
||||
import org.hibernate.annotations.SQLJoinTableRestriction;
|
||||
import org.hibernate.annotations.SQLRestriction;
|
||||
import org.hibernate.testing.TestForIssue;
|
||||
import org.hibernate.testing.junit4.BaseNonConfigCoreFunctionalTestCase;
|
||||
import org.junit.Test;
|
||||
|
||||
import java.util.Arrays;
|
||||
import java.util.HashSet;
|
||||
import java.util.Map;
|
||||
import java.util.Set;
|
||||
|
||||
import static org.hibernate.testing.transaction.TransactionUtil.doInHibernate;
|
||||
|
@ -172,7 +170,7 @@ public class EagerToManyWhereUseClassWhereViaAnnotationTest extends BaseNonConfi
|
|||
|
||||
@OneToMany(fetch = FetchType.EAGER)
|
||||
@JoinColumn
|
||||
@Where( clause = "description is not null" )
|
||||
@SQLRestriction( "description is not null" )
|
||||
private Set<Category> categoriesWithDescOneToMany = new HashSet<>();
|
||||
|
||||
@ManyToMany(fetch = FetchType.EAGER)
|
||||
|
@ -181,19 +179,19 @@ public class EagerToManyWhereUseClassWhereViaAnnotationTest extends BaseNonConfi
|
|||
|
||||
@ManyToMany(fetch = FetchType.EAGER)
|
||||
@JoinTable(name = "categoriesWithDescManyToMany", inverseJoinColumns = { @JoinColumn( name = "categoryId" )})
|
||||
@Where( clause = "description is not null" )
|
||||
@SQLRestriction( "description is not null" )
|
||||
private Set<Category> categoriesWithDescManyToMany = new HashSet<>();
|
||||
|
||||
@ManyToMany(fetch = FetchType.EAGER)
|
||||
@JoinTable(name = "categoriesWithDescIdLt4MToM", inverseJoinColumns = { @JoinColumn( name = "categoryId" )})
|
||||
@Where( clause = "description is not null" )
|
||||
@WhereJoinTable( clause = "categoryId < 4")
|
||||
@SQLRestriction( "description is not null" )
|
||||
@SQLJoinTableRestriction("categoryId < 4")
|
||||
private Set<Category> categoriesWithDescIdLt4ManyToMany = new HashSet<>();
|
||||
}
|
||||
|
||||
@Entity(name = "Category")
|
||||
@Table(name = "CATEGORY")
|
||||
@Where(clause = "inactive = 0")
|
||||
@SQLRestriction("inactive = 0")
|
||||
public static class Category {
|
||||
@Id
|
||||
private int id;
|
||||
|
|
|
@ -21,7 +21,7 @@ import jakarta.persistence.Table;
|
|||
import org.hibernate.Hibernate;
|
||||
import org.hibernate.Session;
|
||||
import org.hibernate.annotations.Immutable;
|
||||
import org.hibernate.annotations.Where;
|
||||
import org.hibernate.annotations.SQLRestriction;
|
||||
import org.hibernate.dialect.H2Dialect;
|
||||
import org.hibernate.testing.RequiresDialect;
|
||||
import org.hibernate.testing.TestForIssue;
|
||||
|
@ -195,7 +195,7 @@ public class LazyElementCollectionBasicNonUniqueIdWhereTest extends BaseCoreFunc
|
|||
|
||||
@Entity( name = "Material" )
|
||||
@Table( name = "MAIN_TABLE" )
|
||||
@Where( clause = "CODE = 'MATERIAL'" )
|
||||
@SQLRestriction("CODE = 'MATERIAL'" )
|
||||
public static class Material {
|
||||
private int id;
|
||||
|
||||
|
@ -227,7 +227,7 @@ public class LazyElementCollectionBasicNonUniqueIdWhereTest extends BaseCoreFunc
|
|||
joinColumns = { @JoinColumn( name = "MAIN_ID" ) }
|
||||
)
|
||||
@Column( name="VAL")
|
||||
@Where( clause = "MAIN_CODE='MATERIAL' AND VALUE_CODE='SIZE'")
|
||||
@SQLRestriction("MAIN_CODE='MATERIAL' AND VALUE_CODE='SIZE'")
|
||||
@Immutable
|
||||
public Set<String> getSizesFromCombined() {
|
||||
return sizesFromCombined;
|
||||
|
@ -253,7 +253,7 @@ public class LazyElementCollectionBasicNonUniqueIdWhereTest extends BaseCoreFunc
|
|||
|
||||
@Entity( name = "Building" )
|
||||
@Table( name = "MAIN_TABLE" )
|
||||
@Where( clause = "CODE = 'BUILDING'" )
|
||||
@SQLRestriction("CODE = 'BUILDING'" )
|
||||
public static class Building {
|
||||
private int id;
|
||||
private String name;
|
||||
|
@ -284,7 +284,7 @@ public class LazyElementCollectionBasicNonUniqueIdWhereTest extends BaseCoreFunc
|
|||
joinColumns = { @JoinColumn( name = "MAIN_ID" ) }
|
||||
)
|
||||
@Column( name="VAL")
|
||||
@Where( clause = "MAIN_CODE='BUILDING' AND VALUE_CODE='SIZE'")
|
||||
@SQLRestriction("MAIN_CODE='BUILDING' AND VALUE_CODE='SIZE'")
|
||||
@Immutable
|
||||
public Set<String> getSizesFromCombined() {
|
||||
return sizesFromCombined;
|
||||
|
@ -299,7 +299,7 @@ public class LazyElementCollectionBasicNonUniqueIdWhereTest extends BaseCoreFunc
|
|||
joinColumns = { @JoinColumn( name = "MAIN_ID" ) }
|
||||
)
|
||||
@Column( name="VAL")
|
||||
@Where( clause = "MAIN_CODE='BUILDING' AND VALUE_CODE='RATING'" )
|
||||
@SQLRestriction( "MAIN_CODE='BUILDING' AND VALUE_CODE='RATING'" )
|
||||
@Immutable
|
||||
public Set<String> getRatingsFromCombined() {
|
||||
return ratingsFromCombined;
|
||||
|
|
|
@ -26,7 +26,7 @@ import jakarta.persistence.Table;
|
|||
import org.hibernate.Hibernate;
|
||||
import org.hibernate.Session;
|
||||
import org.hibernate.annotations.Immutable;
|
||||
import org.hibernate.annotations.Where;
|
||||
import org.hibernate.annotations.SQLRestriction;
|
||||
import org.hibernate.dialect.H2Dialect;
|
||||
import org.hibernate.testing.RequiresDialect;
|
||||
import org.hibernate.testing.TestForIssue;
|
||||
|
@ -208,7 +208,7 @@ public class LazyElementCollectionWithLazyManyToOneNonUniqueIdWhereTest extends
|
|||
|
||||
@Entity( name = "Material" )
|
||||
@Table( name = "MAIN_TABLE" )
|
||||
@Where( clause = "CODE = 'MATERIAL'" )
|
||||
@SQLRestriction( "CODE = 'MATERIAL'" )
|
||||
public static class Material {
|
||||
private int id;
|
||||
|
||||
|
@ -242,7 +242,7 @@ public class LazyElementCollectionWithLazyManyToOneNonUniqueIdWhereTest extends
|
|||
@AssociationOverrides(
|
||||
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
|
||||
public Set<ContainedSize> getContainedSizesFromCombined() {
|
||||
return containedSizesFromCombined;
|
||||
|
@ -270,7 +270,7 @@ public class LazyElementCollectionWithLazyManyToOneNonUniqueIdWhereTest extends
|
|||
|
||||
@Entity( name = "Building" )
|
||||
@Table( name = "MAIN_TABLE" )
|
||||
@Where( clause = "CODE = 'BUILDING'" )
|
||||
@SQLRestriction( "CODE = 'BUILDING'" )
|
||||
public static class Building {
|
||||
private int id;
|
||||
private String name;
|
||||
|
@ -300,7 +300,7 @@ public class LazyElementCollectionWithLazyManyToOneNonUniqueIdWhereTest extends
|
|||
name = "COLLECTION_TABLE",
|
||||
joinColumns = { @JoinColumn( name = "MAIN_ID" ) }
|
||||
)
|
||||
@Where( clause = "MAIN_CODE='BUILDING' AND ASSOCIATION_CODE='SIZE'")
|
||||
@SQLRestriction("MAIN_CODE='BUILDING' AND ASSOCIATION_CODE='SIZE'")
|
||||
@Immutable
|
||||
public Set<ContainedSize> getContainedSizesFromCombined() {
|
||||
return containedSizesFromCombined;
|
||||
|
@ -314,7 +314,7 @@ public class LazyElementCollectionWithLazyManyToOneNonUniqueIdWhereTest extends
|
|||
name = "COLLECTION_TABLE",
|
||||
joinColumns = { @JoinColumn( name = "MAIN_ID" ) }
|
||||
)
|
||||
@Where( clause = "MAIN_CODE='BUILDING' AND ASSOCIATION_CODE='RATING'" )
|
||||
@SQLRestriction( "MAIN_CODE='BUILDING' AND ASSOCIATION_CODE='RATING'" )
|
||||
@Immutable
|
||||
public Set<ContainedRating> getContainedRatingsFromCombined() {
|
||||
return containedRatingsFromCombined;
|
||||
|
@ -327,7 +327,7 @@ public class LazyElementCollectionWithLazyManyToOneNonUniqueIdWhereTest extends
|
|||
|
||||
@Entity( name = "Size" )
|
||||
@Table( name = "MAIN_TABLE" )
|
||||
@Where( clause = "CODE = 'SIZE'" )
|
||||
@SQLRestriction( "CODE = 'SIZE'" )
|
||||
public static class Size {
|
||||
private int id;
|
||||
private String name;
|
||||
|
@ -366,7 +366,7 @@ public class LazyElementCollectionWithLazyManyToOneNonUniqueIdWhereTest extends
|
|||
|
||||
@Entity( name = "Rating" )
|
||||
@Table( name = "MAIN_TABLE" )
|
||||
@Where( clause = "CODE = 'RATING'" )
|
||||
@SQLRestriction( "CODE = 'RATING'" )
|
||||
public static class Rating {
|
||||
private int id;
|
||||
private String name;
|
||||
|
|
|
@ -22,8 +22,8 @@ import jakarta.persistence.Table;
|
|||
|
||||
import org.hibernate.Hibernate;
|
||||
import org.hibernate.annotations.Immutable;
|
||||
import org.hibernate.annotations.Where;
|
||||
import org.hibernate.annotations.WhereJoinTable;
|
||||
import org.hibernate.annotations.SQLJoinTableRestriction;
|
||||
import org.hibernate.annotations.SQLRestriction;
|
||||
import org.hibernate.cfg.Configuration;
|
||||
import org.hibernate.metamodel.CollectionClassification;
|
||||
|
||||
|
@ -265,7 +265,7 @@ public class LazyManyToManyNonUniqueIdWhereTest extends BaseCoreFunctionalTestCa
|
|||
|
||||
@Entity( name = "Material" )
|
||||
@Table( name = "MAIN_TABLE" )
|
||||
@Where( clause = "CODE = 'MATERIAL'" )
|
||||
@SQLRestriction( "CODE = 'MATERIAL'" )
|
||||
public static class Material {
|
||||
private int id;
|
||||
|
||||
|
@ -297,7 +297,7 @@ public class LazyManyToManyNonUniqueIdWhereTest extends BaseCoreFunctionalTestCa
|
|||
joinColumns = { @JoinColumn( name = "MAIN_ID" ) },
|
||||
inverseJoinColumns = { @JoinColumn( name = "ASSOCIATION_ID" ) }
|
||||
)
|
||||
@WhereJoinTable( clause = "MAIN_CODE='MATERIAL' AND ASSOCIATION_CODE='SIZE'")
|
||||
@SQLJoinTableRestriction("MAIN_CODE='MATERIAL' AND ASSOCIATION_CODE='SIZE'")
|
||||
@Immutable
|
||||
public Set<Size> getSizesFromCombined() {
|
||||
return sizesFromCombined;
|
||||
|
@ -312,8 +312,8 @@ public class LazyManyToManyNonUniqueIdWhereTest extends BaseCoreFunctionalTestCa
|
|||
joinColumns = { @JoinColumn( name = "MAIN_ID" ) },
|
||||
inverseJoinColumns = { @JoinColumn( name = "ASSOCIATION_ID" ) }
|
||||
)
|
||||
@WhereJoinTable( clause = "MAIN_CODE='MATERIAL' AND ASSOCIATION_CODE='RATING'" )
|
||||
@Where( clause = "NAME = 'high' or NAME = 'medium'" )
|
||||
@SQLJoinTableRestriction( "MAIN_CODE='MATERIAL' AND ASSOCIATION_CODE='RATING'" )
|
||||
@SQLRestriction( "NAME = 'high' or NAME = 'medium'" )
|
||||
@Immutable
|
||||
public List<Rating> getMediumOrHighRatingsFromCombined() {
|
||||
return mediumOrHighRatingsFromCombined;
|
||||
|
@ -339,7 +339,7 @@ public class LazyManyToManyNonUniqueIdWhereTest extends BaseCoreFunctionalTestCa
|
|||
|
||||
@Entity( name = "Building" )
|
||||
@Table( name = "MAIN_TABLE" )
|
||||
@Where( clause = "CODE = 'BUILDING'" )
|
||||
@SQLRestriction( "CODE = 'BUILDING'" )
|
||||
public static class Building {
|
||||
private int id;
|
||||
private String name;
|
||||
|
@ -370,7 +370,7 @@ public class LazyManyToManyNonUniqueIdWhereTest extends BaseCoreFunctionalTestCa
|
|||
joinColumns = { @JoinColumn( name = "MAIN_ID" ) },
|
||||
inverseJoinColumns = { @JoinColumn( name = "ASSOCIATION_ID" ) }
|
||||
)
|
||||
@WhereJoinTable( clause = "MAIN_CODE='BUILDING' AND ASSOCIATION_CODE='SIZE'")
|
||||
@SQLJoinTableRestriction("MAIN_CODE='BUILDING' AND ASSOCIATION_CODE='SIZE'")
|
||||
@Immutable
|
||||
public Set<Size> getSizesFromCombined() {
|
||||
return sizesFromCombined;
|
||||
|
@ -385,7 +385,7 @@ public class LazyManyToManyNonUniqueIdWhereTest extends BaseCoreFunctionalTestCa
|
|||
joinColumns = { @JoinColumn( name = "MAIN_ID" ) },
|
||||
inverseJoinColumns = { @JoinColumn( name = "ASSOCIATION_ID" ) }
|
||||
)
|
||||
@WhereJoinTable( clause = "MAIN_CODE='BUILDING' AND ASSOCIATION_CODE='RATING'" )
|
||||
@SQLJoinTableRestriction("MAIN_CODE='BUILDING' AND ASSOCIATION_CODE='RATING'" )
|
||||
@Immutable
|
||||
public Set<Rating> getRatingsFromCombined() {
|
||||
return ratingsFromCombined;
|
||||
|
@ -400,7 +400,7 @@ public class LazyManyToManyNonUniqueIdWhereTest extends BaseCoreFunctionalTestCa
|
|||
joinColumns = { @JoinColumn( name = "BUILDING_ID") },
|
||||
inverseJoinColumns = { @JoinColumn( name = "RATING_ID" ) }
|
||||
)
|
||||
@Where( clause = "NAME = 'high' or NAME = 'medium'" )
|
||||
@SQLRestriction( "NAME = 'high' or NAME = 'medium'" )
|
||||
@Immutable
|
||||
public List<Rating> getMediumOrHighRatings() {
|
||||
return mediumOrHighRatings;
|
||||
|
@ -412,7 +412,7 @@ public class LazyManyToManyNonUniqueIdWhereTest extends BaseCoreFunctionalTestCa
|
|||
|
||||
@Entity( name = "Size" )
|
||||
@Table( name = "MAIN_TABLE" )
|
||||
@Where( clause = "CODE = 'SIZE'" )
|
||||
@SQLRestriction( "CODE = 'SIZE'" )
|
||||
public static class Size {
|
||||
private int id;
|
||||
private String name;
|
||||
|
@ -437,7 +437,7 @@ public class LazyManyToManyNonUniqueIdWhereTest extends BaseCoreFunctionalTestCa
|
|||
|
||||
@Entity( name = "Rating" )
|
||||
@Table( name = "MAIN_TABLE" )
|
||||
@Where( clause = "CODE = 'RATING'" )
|
||||
@SQLRestriction( "CODE = 'RATING'" )
|
||||
public static class Rating {
|
||||
private int id;
|
||||
private String name;
|
||||
|
|
|
@ -20,7 +20,7 @@ import jakarta.persistence.Table;
|
|||
|
||||
import org.hibernate.Hibernate;
|
||||
import org.hibernate.annotations.Immutable;
|
||||
import org.hibernate.annotations.Where;
|
||||
import org.hibernate.annotations.SQLRestriction;
|
||||
import org.hibernate.cfg.Configuration;
|
||||
import org.hibernate.metamodel.CollectionClassification;
|
||||
|
||||
|
@ -174,7 +174,7 @@ public class LazyOneToManyNonUniqueIdWhereTest extends BaseCoreFunctionalTestCas
|
|||
|
||||
@Entity( name = "Material" )
|
||||
@Table( name = "MAIN_TABLE" )
|
||||
@Where( clause = "CODE = 'MATERIAL'" )
|
||||
@SQLRestriction( "CODE = 'MATERIAL'" )
|
||||
public static class Material {
|
||||
private int id;
|
||||
|
||||
|
@ -211,7 +211,7 @@ public class LazyOneToManyNonUniqueIdWhereTest extends BaseCoreFunctionalTestCas
|
|||
|
||||
@OneToMany
|
||||
@JoinColumn( name = "MATERIAL_OWNER_ID")
|
||||
@Where( clause = "NAME = 'high' or NAME = 'medium'" )
|
||||
@SQLRestriction( "NAME = 'high' or NAME = 'medium'" )
|
||||
@Immutable
|
||||
public List<Rating> getMediumOrHighRatingsFromCombined() {
|
||||
return mediumOrHighRatingsFromCombined;
|
||||
|
@ -223,7 +223,7 @@ public class LazyOneToManyNonUniqueIdWhereTest extends BaseCoreFunctionalTestCas
|
|||
|
||||
@Entity( name = "Building" )
|
||||
@Table( name = "MAIN_TABLE" )
|
||||
@Where( clause = "CODE = 'BUILDING'" )
|
||||
@SQLRestriction( "CODE = 'BUILDING'" )
|
||||
public static class Building {
|
||||
private int id;
|
||||
private String name;
|
||||
|
@ -271,7 +271,7 @@ public class LazyOneToManyNonUniqueIdWhereTest extends BaseCoreFunctionalTestCas
|
|||
|
||||
@Entity( name = "Size" )
|
||||
@Table( name = "MAIN_TABLE" )
|
||||
@Where( clause = "CODE = 'SIZE'" )
|
||||
@SQLRestriction( "CODE = 'SIZE'" )
|
||||
public static class Size {
|
||||
private int id;
|
||||
private String name;
|
||||
|
@ -296,7 +296,7 @@ public class LazyOneToManyNonUniqueIdWhereTest extends BaseCoreFunctionalTestCas
|
|||
|
||||
@Entity( name = "Rating" )
|
||||
@Table( name = "MAIN_TABLE" )
|
||||
@Where( clause = "CODE = 'RATING'" )
|
||||
@SQLRestriction( "CODE = 'RATING'" )
|
||||
public static class Rating {
|
||||
private int id;
|
||||
private String name;
|
||||
|
|
|
@ -20,8 +20,8 @@ import jakarta.persistence.ManyToMany;
|
|||
import jakarta.persistence.OneToMany;
|
||||
import jakarta.persistence.Table;
|
||||
|
||||
import org.hibernate.annotations.Where;
|
||||
import org.hibernate.annotations.WhereJoinTable;
|
||||
import org.hibernate.annotations.SQLJoinTableRestriction;
|
||||
import org.hibernate.annotations.SQLRestriction;
|
||||
import org.hibernate.cfg.AvailableSettings;
|
||||
|
||||
import org.hibernate.testing.TestForIssue;
|
||||
|
@ -178,7 +178,7 @@ public class LazyToManyWhereDontUseClassWhereTest extends BaseNonConfigCoreFunct
|
|||
|
||||
@OneToMany(fetch = FetchType.LAZY)
|
||||
@JoinColumn
|
||||
@Where( clause = "description is not null" )
|
||||
@SQLRestriction( "description is not null" )
|
||||
private Set<Category> categoriesWithDescOneToMany = new HashSet<>();
|
||||
|
||||
@ManyToMany(fetch = FetchType.LAZY)
|
||||
|
@ -187,19 +187,19 @@ public class LazyToManyWhereDontUseClassWhereTest extends BaseNonConfigCoreFunct
|
|||
|
||||
@ManyToMany(fetch = FetchType.LAZY)
|
||||
@JoinTable(name = "categoriesWithDescManyToMany", inverseJoinColumns = { @JoinColumn( name = "categoryId" )})
|
||||
@Where( clause = "description is not null" )
|
||||
@SQLRestriction( "description is not null" )
|
||||
private Set<Category> categoriesWithDescManyToMany = new HashSet<>();
|
||||
|
||||
@ManyToMany(fetch = FetchType.LAZY)
|
||||
@JoinTable(name = "categoriesWithDescIdLt4MToM", inverseJoinColumns = { @JoinColumn( name = "categoryId" )})
|
||||
@Where( clause = "description is not null" )
|
||||
@WhereJoinTable( clause = "categoryId < 4")
|
||||
@SQLRestriction( "description is not null" )
|
||||
@SQLJoinTableRestriction( "categoryId < 4")
|
||||
private Set<Category> categoriesWithDescIdLt4ManyToMany = new HashSet<>();
|
||||
}
|
||||
|
||||
@Entity(name = "Category")
|
||||
@Table(name = "CATEGORY")
|
||||
@Where(clause = "inactive = 0")
|
||||
@SQLRestriction("inactive = 0")
|
||||
public static class Category {
|
||||
@Id
|
||||
private int id;
|
||||
|
|
|
@ -19,8 +19,8 @@ import jakarta.persistence.ManyToMany;
|
|||
import jakarta.persistence.OneToMany;
|
||||
import jakarta.persistence.Table;
|
||||
|
||||
import org.hibernate.annotations.Where;
|
||||
import org.hibernate.annotations.WhereJoinTable;
|
||||
import org.hibernate.annotations.SQLJoinTableRestriction;
|
||||
import org.hibernate.annotations.SQLRestriction;
|
||||
|
||||
import org.hibernate.testing.TestForIssue;
|
||||
import org.hibernate.testing.junit4.BaseNonConfigCoreFunctionalTestCase;
|
||||
|
@ -172,7 +172,7 @@ public class LazyToManyWhereTest extends BaseNonConfigCoreFunctionalTestCase {
|
|||
|
||||
@OneToMany(fetch = FetchType.LAZY)
|
||||
@JoinColumn
|
||||
@Where( clause = "description is not null" )
|
||||
@SQLRestriction( "description is not null" )
|
||||
private Set<Category> categoriesWithDescOneToMany = new HashSet<>();
|
||||
|
||||
@ManyToMany(fetch = FetchType.LAZY)
|
||||
|
@ -181,19 +181,19 @@ public class LazyToManyWhereTest extends BaseNonConfigCoreFunctionalTestCase {
|
|||
|
||||
@ManyToMany(fetch = FetchType.LAZY)
|
||||
@JoinTable(name = "categoriesWithDescManyToMany", inverseJoinColumns = { @JoinColumn( name = "categoryId" )})
|
||||
@Where( clause = "description is not null" )
|
||||
@SQLRestriction( "description is not null" )
|
||||
private Set<Category> categoriesWithDescManyToMany = new HashSet<>();
|
||||
|
||||
@ManyToMany(fetch = FetchType.LAZY)
|
||||
@JoinTable(name = "categoriesWithDescIdLt4MToM", inverseJoinColumns = { @JoinColumn( name = "categoryId" )})
|
||||
@Where( clause = "description is not null" )
|
||||
@WhereJoinTable( clause = "categoryId < 4")
|
||||
@SQLRestriction("description is not null" )
|
||||
@SQLJoinTableRestriction("categoryId < 4")
|
||||
private Set<Category> categoriesWithDescIdLt4ManyToMany = new HashSet<>();
|
||||
}
|
||||
|
||||
@Entity(name = "Category")
|
||||
@Table(name = "CATEGORY")
|
||||
@Where(clause = "inactive = 0")
|
||||
@SQLRestriction("inactive = 0")
|
||||
public static class Category {
|
||||
@Id
|
||||
private int id;
|
||||
|
|
|
@ -20,8 +20,8 @@ import jakarta.persistence.ManyToMany;
|
|||
import jakarta.persistence.OneToMany;
|
||||
import jakarta.persistence.Table;
|
||||
|
||||
import org.hibernate.annotations.Where;
|
||||
import org.hibernate.annotations.WhereJoinTable;
|
||||
import org.hibernate.annotations.SQLJoinTableRestriction;
|
||||
import org.hibernate.annotations.SQLRestriction;
|
||||
import org.hibernate.cfg.AvailableSettings;
|
||||
|
||||
import org.hibernate.testing.TestForIssue;
|
||||
|
@ -178,7 +178,7 @@ public class LazyToManyWhereUseClassWhereTest extends BaseNonConfigCoreFunctiona
|
|||
|
||||
@OneToMany(fetch = FetchType.LAZY)
|
||||
@JoinColumn
|
||||
@Where( clause = "description is not null" )
|
||||
@SQLRestriction( "description is not null" )
|
||||
private Set<Category> categoriesWithDescOneToMany = new HashSet<>();
|
||||
|
||||
@ManyToMany(fetch = FetchType.LAZY)
|
||||
|
@ -187,19 +187,19 @@ public class LazyToManyWhereUseClassWhereTest extends BaseNonConfigCoreFunctiona
|
|||
|
||||
@ManyToMany(fetch = FetchType.LAZY)
|
||||
@JoinTable(name = "categoriesWithDescManyToMany", inverseJoinColumns = { @JoinColumn( name = "categoryId" )})
|
||||
@Where( clause = "description is not null" )
|
||||
@SQLRestriction( "description is not null" )
|
||||
private Set<Category> categoriesWithDescManyToMany = new HashSet<>();
|
||||
|
||||
@ManyToMany(fetch = FetchType.LAZY)
|
||||
@JoinTable(name = "categoriesWithDescIdLt4MToM", inverseJoinColumns = { @JoinColumn( name = "categoryId" )})
|
||||
@Where( clause = "description is not null" )
|
||||
@WhereJoinTable( clause = "categoryId < 4")
|
||||
@SQLRestriction("description is not null" )
|
||||
@SQLJoinTableRestriction("categoryId < 4")
|
||||
private Set<Category> categoriesWithDescIdLt4ManyToMany = new HashSet<>();
|
||||
}
|
||||
|
||||
@Entity(name = "Category")
|
||||
@Table(name = "CATEGORY")
|
||||
@Where(clause = "inactive = 0")
|
||||
@SQLRestriction("inactive = 0")
|
||||
public static class Category {
|
||||
@Id
|
||||
private int id;
|
||||
|
|
|
@ -1,6 +1,6 @@
|
|||
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.testing.TestForIssue;
|
||||
|
@ -33,7 +33,7 @@ public class NullWhereClauseTest {
|
|||
|
||||
@Entity
|
||||
@Table(name = "person")
|
||||
@Where(clause = "`used` IS NULL")
|
||||
@SQLRestriction("`used` IS NULL")
|
||||
public static class Person {
|
||||
@Id
|
||||
private Integer id;
|
||||
|
|
|
@ -14,7 +14,7 @@ import jakarta.persistence.JoinColumn;
|
|||
import jakarta.persistence.JoinTable;
|
||||
import jakarta.persistence.ManyToMany;
|
||||
|
||||
import org.hibernate.annotations.WhereJoinTable;
|
||||
import org.hibernate.annotations.SQLJoinTableRestriction;
|
||||
import org.hibernate.envers.Audited;
|
||||
import org.hibernate.orm.test.envers.entities.IntNoAutoIdTestEntity;
|
||||
|
||||
|
@ -36,7 +36,7 @@ public class WhereJoinTableEntity {
|
|||
joinColumns = @JoinColumn(name = "wjte_id"),
|
||||
inverseJoinColumns = @JoinColumn(name = "ite_id")
|
||||
)
|
||||
@WhereJoinTable(clause = "ite_id < 20")
|
||||
@SQLJoinTableRestriction("ite_id < 20")
|
||||
private List<IntNoAutoIdTestEntity> references1;
|
||||
|
||||
@ManyToMany
|
||||
|
@ -45,7 +45,7 @@ public class WhereJoinTableEntity {
|
|||
joinColumns = @JoinColumn(name = "wjte_id"),
|
||||
inverseJoinColumns = @JoinColumn(name = "ite_id")
|
||||
)
|
||||
@WhereJoinTable(clause = "ite_id >= 20")
|
||||
@SQLJoinTableRestriction("ite_id >= 20")
|
||||
private List<IntNoAutoIdTestEntity> references2;
|
||||
|
||||
public Integer getId() {
|
||||
|
|
|
@ -16,6 +16,7 @@ import jakarta.persistence.JoinColumn;
|
|||
import jakarta.persistence.JoinTable;
|
||||
import jakarta.persistence.ManyToMany;
|
||||
|
||||
import org.hibernate.annotations.SQLJoinTableRestriction;
|
||||
import org.hibernate.annotations.WhereJoinTable;
|
||||
import org.hibernate.envers.Audited;
|
||||
|
||||
|
@ -49,7 +50,7 @@ public class Child1Entity {
|
|||
joinColumns = @JoinColumn(name = "child1_id"),
|
||||
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>();
|
||||
|
||||
public Integer getId() {
|
||||
|
|
|
@ -16,7 +16,7 @@ import jakarta.persistence.JoinColumn;
|
|||
import jakarta.persistence.JoinTable;
|
||||
import jakarta.persistence.ManyToMany;
|
||||
|
||||
import org.hibernate.annotations.WhereJoinTable;
|
||||
import org.hibernate.annotations.SQLJoinTableRestriction;
|
||||
import org.hibernate.envers.Audited;
|
||||
|
||||
/**
|
||||
|
@ -49,7 +49,7 @@ public class Child2Entity {
|
|||
joinColumns = @JoinColumn(name = "child2_id"),
|
||||
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>();
|
||||
|
||||
public Integer getId() {
|
||||
|
|
|
@ -16,7 +16,7 @@ import jakarta.persistence.JoinColumn;
|
|||
import jakarta.persistence.JoinTable;
|
||||
import jakarta.persistence.ManyToMany;
|
||||
|
||||
import org.hibernate.annotations.WhereJoinTable;
|
||||
import org.hibernate.annotations.SQLJoinTableRestriction;
|
||||
import org.hibernate.envers.Audited;
|
||||
|
||||
/**
|
||||
|
@ -49,7 +49,7 @@ public class ParentEntity {
|
|||
joinColumns = @JoinColumn(name = "parent_id"),
|
||||
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>();
|
||||
|
||||
@ManyToMany(fetch = FetchType.LAZY)
|
||||
|
@ -58,7 +58,7 @@ public class ParentEntity {
|
|||
joinColumns = @JoinColumn(name = "parent_id"),
|
||||
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>();
|
||||
|
||||
public Integer getId() {
|
||||
|
|
|
@ -18,6 +18,7 @@ import jakarta.persistence.JoinColumn;
|
|||
import jakarta.persistence.ManyToMany;
|
||||
import jakarta.persistence.Table;
|
||||
|
||||
import org.hibernate.annotations.SQLRestriction;
|
||||
import org.hibernate.annotations.Where;
|
||||
import org.hibernate.envers.AuditJoinTable;
|
||||
import org.hibernate.envers.Audited;
|
||||
|
@ -116,7 +117,7 @@ public class BasicWhereTest extends BaseEnversJPAFunctionalTestCase {
|
|||
|
||||
@ManyToMany
|
||||
@JoinColumn(name = "allC")
|
||||
@Where(clause = "type = 'C'")
|
||||
@SQLRestriction("type = 'C'")
|
||||
@Audited(targetAuditMode = RelationTargetAuditMode.NOT_AUDITED)
|
||||
@AuditJoinTable(name = "A_C_AUD")
|
||||
private Set<EntityC> allMyC;
|
||||
|
@ -190,7 +191,7 @@ public class BasicWhereTest extends BaseEnversJPAFunctionalTestCase {
|
|||
private String name;
|
||||
|
||||
@ManyToMany
|
||||
@Where(clause = "type = 'Z'")
|
||||
@SQLRestriction("type = 'Z'")
|
||||
@Audited(targetAuditMode = RelationTargetAuditMode.NOT_AUDITED)
|
||||
private Set<EntityZ> allMyZ;
|
||||
|
||||
|
|
|
@ -18,6 +18,7 @@ import jakarta.persistence.JoinColumn;
|
|||
import jakarta.persistence.OneToMany;
|
||||
import jakarta.persistence.Table;
|
||||
|
||||
import org.hibernate.annotations.SQLRestriction;
|
||||
import org.hibernate.annotations.Where;
|
||||
import org.hibernate.envers.AuditJoinTable;
|
||||
import org.hibernate.envers.Audited;
|
||||
|
@ -118,7 +119,7 @@ public class BasicWhereTest extends BaseEnversJPAFunctionalTestCase {
|
|||
|
||||
@OneToMany
|
||||
@JoinColumn(name = "allC")
|
||||
@Where(clause = "type = 'C'")
|
||||
@SQLRestriction("type = 'C'")
|
||||
@Audited(targetAuditMode = RelationTargetAuditMode.NOT_AUDITED)
|
||||
@AuditJoinTable(name = "A_C_AUD")
|
||||
private Set<EntityC> allMyC;
|
||||
|
@ -192,7 +193,7 @@ public class BasicWhereTest extends BaseEnversJPAFunctionalTestCase {
|
|||
private String name;
|
||||
|
||||
@OneToMany
|
||||
@Where(clause = "type = 'Z'")
|
||||
@SQLRestriction("type = 'Z'")
|
||||
@Audited(targetAuditMode = RelationTargetAuditMode.NOT_AUDITED)
|
||||
private Set<EntityZ> allMyZ;
|
||||
|
||||
|
|
|
@ -25,7 +25,7 @@ import jakarta.persistence.MapKeyEnumerated;
|
|||
import jakarta.persistence.MapKeyJoinColumn;
|
||||
import jakarta.persistence.OneToMany;
|
||||
|
||||
import org.hibernate.annotations.OrderBy;
|
||||
import org.hibernate.annotations.SQLOrder;
|
||||
import org.hibernate.annotations.SortComparator;
|
||||
import org.hibernate.annotations.SortNatural;
|
||||
|
||||
|
@ -367,7 +367,7 @@ public class EntityOfMaps {
|
|||
|
||||
@ElementCollection
|
||||
@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")
|
||||
public Map<String, SimpleComponent> getComponentByBasicOrdered() {
|
||||
return componentByBasicOrdered;
|
||||
|
|
Loading…
Reference in New Issue