hibernate.mapping.default_list_semantics (`AvailableSettings#DEFAULT_LIST_SEMANTICS`)
make LIST the default classification for List attributes with no `@OrderColumn`, etc.
This commit is contained in:
parent
1beabbdf40
commit
773f3429c6
|
@ -8,6 +8,7 @@ package org.hibernate.userguide.associations;
|
||||||
|
|
||||||
import java.util.ArrayList;
|
import java.util.ArrayList;
|
||||||
import java.util.List;
|
import java.util.List;
|
||||||
|
import java.util.Map;
|
||||||
import java.util.Objects;
|
import java.util.Objects;
|
||||||
import jakarta.persistence.CascadeType;
|
import jakarta.persistence.CascadeType;
|
||||||
import jakarta.persistence.Column;
|
import jakarta.persistence.Column;
|
||||||
|
@ -17,10 +18,12 @@ import jakarta.persistence.Id;
|
||||||
import jakarta.persistence.ManyToMany;
|
import jakarta.persistence.ManyToMany;
|
||||||
|
|
||||||
import org.hibernate.annotations.NaturalId;
|
import org.hibernate.annotations.NaturalId;
|
||||||
|
import org.hibernate.metamodel.CollectionClassification;
|
||||||
import org.hibernate.orm.test.jpa.BaseEntityManagerFunctionalTestCase;
|
import org.hibernate.orm.test.jpa.BaseEntityManagerFunctionalTestCase;
|
||||||
|
|
||||||
import org.junit.Test;
|
import org.junit.Test;
|
||||||
|
|
||||||
|
import static org.hibernate.cfg.AvailableSettings.DEFAULT_LIST_SEMANTICS;
|
||||||
import static org.hibernate.testing.transaction.TransactionUtil.doInJPA;
|
import static org.hibernate.testing.transaction.TransactionUtil.doInJPA;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
@ -36,6 +39,12 @@ public class ManyToManyBidirectionalTest extends BaseEntityManagerFunctionalTest
|
||||||
};
|
};
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
protected void addConfigOptions(Map options) {
|
||||||
|
super.addConfigOptions( options );
|
||||||
|
options.put( DEFAULT_LIST_SEMANTICS, CollectionClassification.BAG.name() );
|
||||||
|
}
|
||||||
|
|
||||||
@Test
|
@Test
|
||||||
public void testLifecycle() {
|
public void testLifecycle() {
|
||||||
doInJPA(this::entityManagerFactory, entityManager -> {
|
doInJPA(this::entityManagerFactory, entityManager -> {
|
||||||
|
|
|
@ -8,6 +8,8 @@ package org.hibernate.userguide.collections;
|
||||||
|
|
||||||
import java.util.ArrayList;
|
import java.util.ArrayList;
|
||||||
import java.util.List;
|
import java.util.List;
|
||||||
|
import java.util.Map;
|
||||||
|
|
||||||
import jakarta.persistence.CascadeType;
|
import jakarta.persistence.CascadeType;
|
||||||
import jakarta.persistence.Entity;
|
import jakarta.persistence.Entity;
|
||||||
import jakarta.persistence.FetchType;
|
import jakarta.persistence.FetchType;
|
||||||
|
@ -17,11 +19,13 @@ import jakarta.persistence.ManyToOne;
|
||||||
import jakarta.persistence.OneToMany;
|
import jakarta.persistence.OneToMany;
|
||||||
|
|
||||||
import org.hibernate.dialect.H2Dialect;
|
import org.hibernate.dialect.H2Dialect;
|
||||||
|
import org.hibernate.metamodel.CollectionClassification;
|
||||||
import org.hibernate.orm.test.jpa.BaseEntityManagerFunctionalTestCase;
|
import org.hibernate.orm.test.jpa.BaseEntityManagerFunctionalTestCase;
|
||||||
|
|
||||||
import org.hibernate.testing.RequiresDialect;
|
import org.hibernate.testing.RequiresDialect;
|
||||||
import org.junit.Test;
|
import org.junit.Test;
|
||||||
|
|
||||||
|
import static org.hibernate.cfg.AvailableSettings.DEFAULT_LIST_SEMANTICS;
|
||||||
import static org.hibernate.testing.transaction.TransactionUtil.doInJPA;
|
import static org.hibernate.testing.transaction.TransactionUtil.doInJPA;
|
||||||
import static org.junit.Assert.assertEquals;
|
import static org.junit.Assert.assertEquals;
|
||||||
|
|
||||||
|
@ -39,6 +43,12 @@ public class OrderedBySQLTest extends BaseEntityManagerFunctionalTestCase {
|
||||||
};
|
};
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
protected void addConfigOptions(Map options) {
|
||||||
|
super.addConfigOptions( options );
|
||||||
|
options.put( DEFAULT_LIST_SEMANTICS, CollectionClassification.BAG.name() );
|
||||||
|
}
|
||||||
|
|
||||||
@Test
|
@Test
|
||||||
public void testLifecycle() {
|
public void testLifecycle() {
|
||||||
doInJPA(this::entityManagerFactory, entityManager -> {
|
doInJPA(this::entityManagerFactory, entityManager -> {
|
||||||
|
|
|
@ -8,6 +8,8 @@ package org.hibernate.userguide.fetching;
|
||||||
|
|
||||||
import java.util.ArrayList;
|
import java.util.ArrayList;
|
||||||
import java.util.List;
|
import java.util.List;
|
||||||
|
import java.util.Map;
|
||||||
|
|
||||||
import jakarta.persistence.Entity;
|
import jakarta.persistence.Entity;
|
||||||
import jakarta.persistence.FetchType;
|
import jakarta.persistence.FetchType;
|
||||||
import jakarta.persistence.GeneratedValue;
|
import jakarta.persistence.GeneratedValue;
|
||||||
|
@ -18,10 +20,12 @@ import jakarta.persistence.OneToMany;
|
||||||
import org.hibernate.annotations.Fetch;
|
import org.hibernate.annotations.Fetch;
|
||||||
import org.hibernate.annotations.FetchMode;
|
import org.hibernate.annotations.FetchMode;
|
||||||
import org.hibernate.annotations.NaturalId;
|
import org.hibernate.annotations.NaturalId;
|
||||||
|
import org.hibernate.metamodel.CollectionClassification;
|
||||||
import org.hibernate.orm.test.jpa.BaseEntityManagerFunctionalTestCase;
|
import org.hibernate.orm.test.jpa.BaseEntityManagerFunctionalTestCase;
|
||||||
|
|
||||||
import org.junit.Test;
|
import org.junit.Test;
|
||||||
|
|
||||||
|
import static org.hibernate.cfg.AvailableSettings.DEFAULT_LIST_SEMANTICS;
|
||||||
import static org.hibernate.testing.transaction.TransactionUtil.doInJPA;
|
import static org.hibernate.testing.transaction.TransactionUtil.doInJPA;
|
||||||
import static org.junit.Assert.assertEquals;
|
import static org.junit.Assert.assertEquals;
|
||||||
|
|
||||||
|
@ -38,6 +42,12 @@ public class FetchModeJoinTest extends BaseEntityManagerFunctionalTestCase {
|
||||||
};
|
};
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
protected void addConfigOptions(Map options) {
|
||||||
|
super.addConfigOptions( options );
|
||||||
|
options.put( DEFAULT_LIST_SEMANTICS, CollectionClassification.BAG.name() );
|
||||||
|
}
|
||||||
|
|
||||||
@Test
|
@Test
|
||||||
public void test() {
|
public void test() {
|
||||||
doInJPA(this::entityManagerFactory, entityManager -> {
|
doInJPA(this::entityManagerFactory, entityManager -> {
|
||||||
|
|
|
@ -8,6 +8,8 @@ package org.hibernate.userguide.fetching;
|
||||||
|
|
||||||
import java.util.ArrayList;
|
import java.util.ArrayList;
|
||||||
import java.util.List;
|
import java.util.List;
|
||||||
|
import java.util.Map;
|
||||||
|
|
||||||
import jakarta.persistence.Entity;
|
import jakarta.persistence.Entity;
|
||||||
import jakarta.persistence.FetchType;
|
import jakarta.persistence.FetchType;
|
||||||
import jakarta.persistence.GeneratedValue;
|
import jakarta.persistence.GeneratedValue;
|
||||||
|
@ -18,10 +20,12 @@ import jakarta.persistence.OneToMany;
|
||||||
import org.hibernate.annotations.Fetch;
|
import org.hibernate.annotations.Fetch;
|
||||||
import org.hibernate.annotations.FetchMode;
|
import org.hibernate.annotations.FetchMode;
|
||||||
import org.hibernate.annotations.NaturalId;
|
import org.hibernate.annotations.NaturalId;
|
||||||
|
import org.hibernate.metamodel.CollectionClassification;
|
||||||
import org.hibernate.orm.test.jpa.BaseEntityManagerFunctionalTestCase;
|
import org.hibernate.orm.test.jpa.BaseEntityManagerFunctionalTestCase;
|
||||||
|
|
||||||
import org.junit.Test;
|
import org.junit.Test;
|
||||||
|
|
||||||
|
import static org.hibernate.cfg.AvailableSettings.DEFAULT_LIST_SEMANTICS;
|
||||||
import static org.hibernate.testing.transaction.TransactionUtil.doInJPA;
|
import static org.hibernate.testing.transaction.TransactionUtil.doInJPA;
|
||||||
import static org.junit.Assert.assertEquals;
|
import static org.junit.Assert.assertEquals;
|
||||||
|
|
||||||
|
@ -38,6 +42,12 @@ public class FetchModeSelectTest extends BaseEntityManagerFunctionalTestCase {
|
||||||
};
|
};
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
protected void addConfigOptions(Map options) {
|
||||||
|
super.addConfigOptions( options );
|
||||||
|
options.put( DEFAULT_LIST_SEMANTICS, CollectionClassification.BAG.name() );
|
||||||
|
}
|
||||||
|
|
||||||
@Test
|
@Test
|
||||||
public void test() {
|
public void test() {
|
||||||
doInJPA(this::entityManagerFactory, entityManager -> {
|
doInJPA(this::entityManagerFactory, entityManager -> {
|
||||||
|
|
|
@ -8,6 +8,8 @@ package org.hibernate.userguide.fetching;
|
||||||
|
|
||||||
import java.util.ArrayList;
|
import java.util.ArrayList;
|
||||||
import java.util.List;
|
import java.util.List;
|
||||||
|
import java.util.Map;
|
||||||
|
|
||||||
import jakarta.persistence.Entity;
|
import jakarta.persistence.Entity;
|
||||||
import jakarta.persistence.FetchType;
|
import jakarta.persistence.FetchType;
|
||||||
import jakarta.persistence.GeneratedValue;
|
import jakarta.persistence.GeneratedValue;
|
||||||
|
@ -18,10 +20,12 @@ import jakarta.persistence.OneToMany;
|
||||||
import org.hibernate.annotations.Fetch;
|
import org.hibernate.annotations.Fetch;
|
||||||
import org.hibernate.annotations.FetchMode;
|
import org.hibernate.annotations.FetchMode;
|
||||||
import org.hibernate.annotations.NaturalId;
|
import org.hibernate.annotations.NaturalId;
|
||||||
|
import org.hibernate.metamodel.CollectionClassification;
|
||||||
import org.hibernate.orm.test.jpa.BaseEntityManagerFunctionalTestCase;
|
import org.hibernate.orm.test.jpa.BaseEntityManagerFunctionalTestCase;
|
||||||
|
|
||||||
import org.junit.Test;
|
import org.junit.Test;
|
||||||
|
|
||||||
|
import static org.hibernate.cfg.AvailableSettings.DEFAULT_LIST_SEMANTICS;
|
||||||
import static org.hibernate.testing.transaction.TransactionUtil.doInJPA;
|
import static org.hibernate.testing.transaction.TransactionUtil.doInJPA;
|
||||||
import static org.junit.Assert.assertEquals;
|
import static org.junit.Assert.assertEquals;
|
||||||
|
|
||||||
|
@ -38,6 +42,12 @@ public class FetchModeSubselectTest extends BaseEntityManagerFunctionalTestCase
|
||||||
};
|
};
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
protected void addConfigOptions(Map options) {
|
||||||
|
super.addConfigOptions( options );
|
||||||
|
options.put( DEFAULT_LIST_SEMANTICS, CollectionClassification.BAG.name() );
|
||||||
|
}
|
||||||
|
|
||||||
@Test
|
@Test
|
||||||
public void test() {
|
public void test() {
|
||||||
doInJPA(this::entityManagerFactory, entityManager -> {
|
doInJPA(this::entityManagerFactory, entityManager -> {
|
||||||
|
|
|
@ -9,6 +9,8 @@ package org.hibernate.userguide.fetching;
|
||||||
import java.util.ArrayList;
|
import java.util.ArrayList;
|
||||||
import java.util.Collections;
|
import java.util.Collections;
|
||||||
import java.util.List;
|
import java.util.List;
|
||||||
|
import java.util.Map;
|
||||||
|
|
||||||
import jakarta.persistence.Column;
|
import jakarta.persistence.Column;
|
||||||
import jakarta.persistence.Entity;
|
import jakarta.persistence.Entity;
|
||||||
import jakarta.persistence.FetchType;
|
import jakarta.persistence.FetchType;
|
||||||
|
@ -24,11 +26,13 @@ import jakarta.persistence.QueryHint;
|
||||||
import org.hibernate.annotations.ColumnTransformer;
|
import org.hibernate.annotations.ColumnTransformer;
|
||||||
import org.hibernate.annotations.NaturalId;
|
import org.hibernate.annotations.NaturalId;
|
||||||
import org.hibernate.dialect.H2Dialect;
|
import org.hibernate.dialect.H2Dialect;
|
||||||
|
import org.hibernate.metamodel.CollectionClassification;
|
||||||
import org.hibernate.orm.test.jpa.BaseEntityManagerFunctionalTestCase;
|
import org.hibernate.orm.test.jpa.BaseEntityManagerFunctionalTestCase;
|
||||||
|
|
||||||
import org.hibernate.testing.RequiresDialect;
|
import org.hibernate.testing.RequiresDialect;
|
||||||
import org.junit.Test;
|
import org.junit.Test;
|
||||||
|
|
||||||
|
import static org.hibernate.cfg.AvailableSettings.DEFAULT_LIST_SEMANTICS;
|
||||||
import static org.hibernate.testing.transaction.TransactionUtil.doInJPA;
|
import static org.hibernate.testing.transaction.TransactionUtil.doInJPA;
|
||||||
import static org.junit.Assert.assertEquals;
|
import static org.junit.Assert.assertEquals;
|
||||||
import static org.junit.Assert.assertNotNull;
|
import static org.junit.Assert.assertNotNull;
|
||||||
|
@ -49,6 +53,12 @@ public class GraphFetchingTest extends BaseEntityManagerFunctionalTestCase {
|
||||||
};
|
};
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
protected void addConfigOptions(Map options) {
|
||||||
|
super.addConfigOptions( options );
|
||||||
|
options.put( DEFAULT_LIST_SEMANTICS, CollectionClassification.BAG.name() );
|
||||||
|
}
|
||||||
|
|
||||||
@Test
|
@Test
|
||||||
public void test() {
|
public void test() {
|
||||||
doInJPA(this::entityManagerFactory, entityManager -> {
|
doInJPA(this::entityManagerFactory, entityManager -> {
|
||||||
|
|
|
@ -8,6 +8,8 @@ package org.hibernate.userguide.pc;
|
||||||
|
|
||||||
import java.util.ArrayList;
|
import java.util.ArrayList;
|
||||||
import java.util.List;
|
import java.util.List;
|
||||||
|
import java.util.Map;
|
||||||
|
|
||||||
import jakarta.persistence.CascadeType;
|
import jakarta.persistence.CascadeType;
|
||||||
import jakarta.persistence.Column;
|
import jakarta.persistence.Column;
|
||||||
import jakarta.persistence.Entity;
|
import jakarta.persistence.Entity;
|
||||||
|
@ -24,10 +26,12 @@ import org.hibernate.Session;
|
||||||
import org.hibernate.annotations.Filter;
|
import org.hibernate.annotations.Filter;
|
||||||
import org.hibernate.annotations.FilterDef;
|
import org.hibernate.annotations.FilterDef;
|
||||||
import org.hibernate.annotations.ParamDef;
|
import org.hibernate.annotations.ParamDef;
|
||||||
|
import org.hibernate.metamodel.CollectionClassification;
|
||||||
import org.hibernate.orm.test.jpa.BaseEntityManagerFunctionalTestCase;
|
import org.hibernate.orm.test.jpa.BaseEntityManagerFunctionalTestCase;
|
||||||
|
|
||||||
import org.junit.Test;
|
import org.junit.Test;
|
||||||
|
|
||||||
|
import static org.hibernate.cfg.AvailableSettings.DEFAULT_LIST_SEMANTICS;
|
||||||
import static org.hibernate.testing.transaction.TransactionUtil.doInJPA;
|
import static org.hibernate.testing.transaction.TransactionUtil.doInJPA;
|
||||||
import static org.junit.Assert.assertEquals;
|
import static org.junit.Assert.assertEquals;
|
||||||
import static org.junit.Assert.assertFalse;
|
import static org.junit.Assert.assertFalse;
|
||||||
|
@ -47,6 +51,12 @@ public class FilterTest extends BaseEntityManagerFunctionalTestCase {
|
||||||
};
|
};
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
protected void addConfigOptions(Map options) {
|
||||||
|
super.addConfigOptions( options );
|
||||||
|
options.put( DEFAULT_LIST_SEMANTICS, CollectionClassification.BAG.name() );
|
||||||
|
}
|
||||||
|
|
||||||
@Test
|
@Test
|
||||||
public void testLifecycle() {
|
public void testLifecycle() {
|
||||||
doInJPA(this::entityManagerFactory, entityManager -> {
|
doInJPA(this::entityManagerFactory, entityManager -> {
|
||||||
|
|
|
@ -9,6 +9,7 @@ package org.hibernate.userguide.pc;
|
||||||
import java.sql.Statement;
|
import java.sql.Statement;
|
||||||
import java.util.ArrayList;
|
import java.util.ArrayList;
|
||||||
import java.util.List;
|
import java.util.List;
|
||||||
|
import java.util.Map;
|
||||||
import java.util.Optional;
|
import java.util.Optional;
|
||||||
import jakarta.persistence.CascadeType;
|
import jakarta.persistence.CascadeType;
|
||||||
import jakarta.persistence.Entity;
|
import jakarta.persistence.Entity;
|
||||||
|
@ -26,10 +27,12 @@ import org.hibernate.Session;
|
||||||
import org.hibernate.SessionFactory;
|
import org.hibernate.SessionFactory;
|
||||||
import org.hibernate.annotations.NaturalId;
|
import org.hibernate.annotations.NaturalId;
|
||||||
import org.hibernate.engine.spi.SessionImplementor;
|
import org.hibernate.engine.spi.SessionImplementor;
|
||||||
|
import org.hibernate.metamodel.CollectionClassification;
|
||||||
import org.hibernate.orm.test.jpa.BaseEntityManagerFunctionalTestCase;
|
import org.hibernate.orm.test.jpa.BaseEntityManagerFunctionalTestCase;
|
||||||
|
|
||||||
import org.junit.Test;
|
import org.junit.Test;
|
||||||
|
|
||||||
|
import static org.hibernate.cfg.AvailableSettings.DEFAULT_LIST_SEMANTICS;
|
||||||
import static org.hibernate.testing.transaction.TransactionUtil.doInJPA;
|
import static org.hibernate.testing.transaction.TransactionUtil.doInJPA;
|
||||||
import static org.junit.Assert.assertEquals;
|
import static org.junit.Assert.assertEquals;
|
||||||
import static org.junit.Assert.assertNotNull;
|
import static org.junit.Assert.assertNotNull;
|
||||||
|
@ -48,6 +51,12 @@ public class PersistenceContextTest extends BaseEntityManagerFunctionalTestCase
|
||||||
};
|
};
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
protected void addConfigOptions(Map options) {
|
||||||
|
super.addConfigOptions( options );
|
||||||
|
options.put( DEFAULT_LIST_SEMANTICS, CollectionClassification.BAG.name() );
|
||||||
|
}
|
||||||
|
|
||||||
@Test
|
@Test
|
||||||
public void test() {
|
public void test() {
|
||||||
doInJPA(this::entityManagerFactory, entityManager -> {
|
doInJPA(this::entityManagerFactory, entityManager -> {
|
||||||
|
|
|
@ -9,6 +9,8 @@ package org.hibernate.userguide.pc;
|
||||||
import java.sql.Statement;
|
import java.sql.Statement;
|
||||||
import java.util.ArrayList;
|
import java.util.ArrayList;
|
||||||
import java.util.List;
|
import java.util.List;
|
||||||
|
import java.util.Map;
|
||||||
|
|
||||||
import jakarta.persistence.Entity;
|
import jakarta.persistence.Entity;
|
||||||
import jakarta.persistence.Id;
|
import jakarta.persistence.Id;
|
||||||
import jakarta.persistence.JoinColumn;
|
import jakarta.persistence.JoinColumn;
|
||||||
|
@ -18,11 +20,13 @@ import jakarta.persistence.ManyToMany;
|
||||||
import org.hibernate.Session;
|
import org.hibernate.Session;
|
||||||
import org.hibernate.annotations.WhereJoinTable;
|
import org.hibernate.annotations.WhereJoinTable;
|
||||||
import org.hibernate.dialect.H2Dialect;
|
import org.hibernate.dialect.H2Dialect;
|
||||||
|
import org.hibernate.metamodel.CollectionClassification;
|
||||||
import org.hibernate.orm.test.jpa.BaseEntityManagerFunctionalTestCase;
|
import org.hibernate.orm.test.jpa.BaseEntityManagerFunctionalTestCase;
|
||||||
|
|
||||||
import org.hibernate.testing.RequiresDialect;
|
import org.hibernate.testing.RequiresDialect;
|
||||||
import org.junit.Test;
|
import org.junit.Test;
|
||||||
|
|
||||||
|
import static org.hibernate.cfg.AvailableSettings.DEFAULT_LIST_SEMANTICS;
|
||||||
import static org.hibernate.testing.transaction.TransactionUtil.doInJPA;
|
import static org.hibernate.testing.transaction.TransactionUtil.doInJPA;
|
||||||
import static org.junit.Assert.assertEquals;
|
import static org.junit.Assert.assertEquals;
|
||||||
|
|
||||||
|
@ -40,6 +44,12 @@ public class WhereJoinTableTest extends BaseEntityManagerFunctionalTestCase {
|
||||||
};
|
};
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
protected void addConfigOptions(Map options) {
|
||||||
|
super.addConfigOptions( options );
|
||||||
|
options.put( DEFAULT_LIST_SEMANTICS, CollectionClassification.BAG.name() );
|
||||||
|
}
|
||||||
|
|
||||||
@Test
|
@Test
|
||||||
public void testLifecycle() {
|
public void testLifecycle() {
|
||||||
//tag::pc-where-persistence-example[]
|
//tag::pc-where-persistence-example[]
|
||||||
|
|
|
@ -8,6 +8,8 @@ package org.hibernate.userguide.pc;
|
||||||
|
|
||||||
import java.util.ArrayList;
|
import java.util.ArrayList;
|
||||||
import java.util.List;
|
import java.util.List;
|
||||||
|
import java.util.Map;
|
||||||
|
|
||||||
import jakarta.persistence.Column;
|
import jakarta.persistence.Column;
|
||||||
import jakarta.persistence.Entity;
|
import jakarta.persistence.Entity;
|
||||||
import jakarta.persistence.EnumType;
|
import jakarta.persistence.EnumType;
|
||||||
|
@ -17,10 +19,12 @@ import jakarta.persistence.ManyToOne;
|
||||||
import jakarta.persistence.OneToMany;
|
import jakarta.persistence.OneToMany;
|
||||||
|
|
||||||
import org.hibernate.annotations.Where;
|
import org.hibernate.annotations.Where;
|
||||||
|
import org.hibernate.metamodel.CollectionClassification;
|
||||||
import org.hibernate.orm.test.jpa.BaseEntityManagerFunctionalTestCase;
|
import org.hibernate.orm.test.jpa.BaseEntityManagerFunctionalTestCase;
|
||||||
|
|
||||||
import org.junit.Test;
|
import org.junit.Test;
|
||||||
|
|
||||||
|
import static org.hibernate.cfg.AvailableSettings.DEFAULT_LIST_SEMANTICS;
|
||||||
import static org.hibernate.testing.transaction.TransactionUtil.doInJPA;
|
import static org.hibernate.testing.transaction.TransactionUtil.doInJPA;
|
||||||
import static org.junit.Assert.assertEquals;
|
import static org.junit.Assert.assertEquals;
|
||||||
|
|
||||||
|
@ -37,6 +41,12 @@ public class WhereTest extends BaseEntityManagerFunctionalTestCase {
|
||||||
};
|
};
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
protected void addConfigOptions(Map options) {
|
||||||
|
super.addConfigOptions( options );
|
||||||
|
options.put( DEFAULT_LIST_SEMANTICS, CollectionClassification.BAG.name() );
|
||||||
|
}
|
||||||
|
|
||||||
@Test
|
@Test
|
||||||
public void testLifecycle() {
|
public void testLifecycle() {
|
||||||
//tag::pc-where-persistence-example[]
|
//tag::pc-where-persistence-example[]
|
||||||
|
|
|
@ -10,6 +10,8 @@ import java.sql.Statement;
|
||||||
import java.sql.Types;
|
import java.sql.Types;
|
||||||
import java.util.ArrayList;
|
import java.util.ArrayList;
|
||||||
import java.util.List;
|
import java.util.List;
|
||||||
|
import java.util.Map;
|
||||||
|
|
||||||
import jakarta.persistence.ElementCollection;
|
import jakarta.persistence.ElementCollection;
|
||||||
import jakarta.persistence.Entity;
|
import jakarta.persistence.Entity;
|
||||||
import jakarta.persistence.GeneratedValue;
|
import jakarta.persistence.GeneratedValue;
|
||||||
|
@ -26,6 +28,7 @@ import org.hibernate.annotations.SQLInsert;
|
||||||
import org.hibernate.annotations.SQLUpdate;
|
import org.hibernate.annotations.SQLUpdate;
|
||||||
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.orm.test.jpa.BaseEntityManagerFunctionalTestCase;
|
import org.hibernate.orm.test.jpa.BaseEntityManagerFunctionalTestCase;
|
||||||
|
|
||||||
import org.hibernate.testing.RequiresDialect;
|
import org.hibernate.testing.RequiresDialect;
|
||||||
|
@ -33,6 +36,7 @@ import org.hibernate.testing.TestForIssue;
|
||||||
import org.junit.Before;
|
import org.junit.Before;
|
||||||
import org.junit.Test;
|
import org.junit.Test;
|
||||||
|
|
||||||
|
import static org.hibernate.cfg.AvailableSettings.DEFAULT_LIST_SEMANTICS;
|
||||||
import static org.hibernate.testing.transaction.TransactionUtil.doInJPA;
|
import static org.hibernate.testing.transaction.TransactionUtil.doInJPA;
|
||||||
import static org.junit.Assert.assertEquals;
|
import static org.junit.Assert.assertEquals;
|
||||||
|
|
||||||
|
@ -52,6 +56,12 @@ public class CollectionLoaderTest extends BaseEntityManagerFunctionalTestCase {
|
||||||
};
|
};
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
protected void addConfigOptions(Map options) {
|
||||||
|
super.addConfigOptions( options );
|
||||||
|
options.put( DEFAULT_LIST_SEMANTICS, CollectionClassification.BAG.name() );
|
||||||
|
}
|
||||||
|
|
||||||
@Before
|
@Before
|
||||||
public void init() {
|
public void init() {
|
||||||
doInJPA(this::entityManagerFactory, entityManager -> {
|
doInJPA(this::entityManagerFactory, entityManager -> {
|
||||||
|
|
|
@ -9,6 +9,8 @@ package org.hibernate.userguide.sql;
|
||||||
import java.sql.Statement;
|
import java.sql.Statement;
|
||||||
import java.util.ArrayList;
|
import java.util.ArrayList;
|
||||||
import java.util.List;
|
import java.util.List;
|
||||||
|
import java.util.Map;
|
||||||
|
|
||||||
import jakarta.persistence.ElementCollection;
|
import jakarta.persistence.ElementCollection;
|
||||||
import jakarta.persistence.Entity;
|
import jakarta.persistence.Entity;
|
||||||
import jakarta.persistence.GeneratedValue;
|
import jakarta.persistence.GeneratedValue;
|
||||||
|
@ -26,12 +28,14 @@ import org.hibernate.annotations.SQLUpdate;
|
||||||
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;
|
||||||
|
import org.hibernate.metamodel.CollectionClassification;
|
||||||
import org.hibernate.orm.test.jpa.BaseEntityManagerFunctionalTestCase;
|
import org.hibernate.orm.test.jpa.BaseEntityManagerFunctionalTestCase;
|
||||||
|
|
||||||
import org.hibernate.testing.RequiresDialect;
|
import org.hibernate.testing.RequiresDialect;
|
||||||
import org.junit.Before;
|
import org.junit.Before;
|
||||||
import org.junit.Test;
|
import org.junit.Test;
|
||||||
|
|
||||||
|
import static org.hibernate.cfg.AvailableSettings.DEFAULT_LIST_SEMANTICS;
|
||||||
import static org.hibernate.testing.transaction.TransactionUtil.doInJPA;
|
import static org.hibernate.testing.transaction.TransactionUtil.doInJPA;
|
||||||
import static org.junit.Assert.assertEquals;
|
import static org.junit.Assert.assertEquals;
|
||||||
import static org.junit.Assert.assertNull;
|
import static org.junit.Assert.assertNull;
|
||||||
|
@ -50,6 +54,12 @@ public class CustomSQLTest extends BaseEntityManagerFunctionalTestCase {
|
||||||
};
|
};
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
protected void addConfigOptions(Map options) {
|
||||||
|
super.addConfigOptions( options );
|
||||||
|
options.put( DEFAULT_LIST_SEMANTICS, CollectionClassification.BAG.name() );
|
||||||
|
}
|
||||||
|
|
||||||
@Before
|
@Before
|
||||||
public void init() {
|
public void init() {
|
||||||
doInJPA(this::entityManagerFactory, entityManager -> {
|
doInJPA(this::entityManagerFactory, entityManager -> {
|
||||||
|
|
|
@ -476,8 +476,7 @@ public class MetadataBuilderImpl implements MetadataBuilderImplementor, TypeCont
|
||||||
}
|
}
|
||||||
return classification;
|
return classification;
|
||||||
},
|
},
|
||||||
// for now, to follow legacy behavior
|
CollectionClassification.LIST
|
||||||
CollectionClassification.BAG
|
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -15,8 +15,11 @@ import org.hibernate.jpa.internal.PersistenceUnitUtilImpl;
|
||||||
|
|
||||||
import org.hibernate.testing.TestForIssue;
|
import org.hibernate.testing.TestForIssue;
|
||||||
import org.hibernate.testing.orm.junit.DomainModel;
|
import org.hibernate.testing.orm.junit.DomainModel;
|
||||||
|
import org.hibernate.testing.orm.junit.ImplicitListAsBagProvider;
|
||||||
|
import org.hibernate.testing.orm.junit.ServiceRegistry;
|
||||||
import org.hibernate.testing.orm.junit.SessionFactory;
|
import org.hibernate.testing.orm.junit.SessionFactory;
|
||||||
import org.hibernate.testing.orm.junit.SessionFactoryScope;
|
import org.hibernate.testing.orm.junit.SessionFactoryScope;
|
||||||
|
import org.hibernate.testing.orm.junit.SettingProvider;
|
||||||
import org.junit.jupiter.api.AfterEach;
|
import org.junit.jupiter.api.AfterEach;
|
||||||
import org.junit.jupiter.api.Test;
|
import org.junit.jupiter.api.Test;
|
||||||
|
|
||||||
|
@ -29,11 +32,21 @@ import jakarta.persistence.JoinColumn;
|
||||||
import jakarta.persistence.ManyToOne;
|
import jakarta.persistence.ManyToOne;
|
||||||
import jakarta.persistence.OneToMany;
|
import jakarta.persistence.OneToMany;
|
||||||
|
|
||||||
|
import static org.hibernate.cfg.AvailableSettings.DEFAULT_LIST_SEMANTICS;
|
||||||
import static org.junit.jupiter.api.Assertions.assertEquals;
|
import static org.junit.jupiter.api.Assertions.assertEquals;
|
||||||
import static org.junit.jupiter.api.Assertions.assertFalse;
|
import static org.junit.jupiter.api.Assertions.assertFalse;
|
||||||
import static org.junit.jupiter.api.Assertions.assertNull;
|
import static org.junit.jupiter.api.Assertions.assertNull;
|
||||||
import static org.junit.jupiter.api.Assertions.assertTrue;
|
import static org.junit.jupiter.api.Assertions.assertTrue;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @author Andrea Boriero
|
||||||
|
*/
|
||||||
|
@ServiceRegistry(
|
||||||
|
settingProviders = @SettingProvider(
|
||||||
|
settingName = DEFAULT_LIST_SEMANTICS,
|
||||||
|
provider = ImplicitListAsBagProvider.class
|
||||||
|
)
|
||||||
|
)
|
||||||
@DomainModel(
|
@DomainModel(
|
||||||
annotatedClasses = {
|
annotatedClasses = {
|
||||||
CompositeIdDerivedIdWithIdClassTest.ShoppingCart.class,
|
CompositeIdDerivedIdWithIdClassTest.ShoppingCart.class,
|
||||||
|
|
|
@ -10,6 +10,8 @@ import java.util.Iterator;
|
||||||
|
|
||||||
import org.hibernate.boot.MetadataBuilder;
|
import org.hibernate.boot.MetadataBuilder;
|
||||||
import org.hibernate.boot.model.naming.ImplicitNamingStrategyJpaCompliantImpl;
|
import org.hibernate.boot.model.naming.ImplicitNamingStrategyJpaCompliantImpl;
|
||||||
|
import org.hibernate.boot.registry.StandardServiceRegistryBuilder;
|
||||||
|
import org.hibernate.cfg.AvailableSettings;
|
||||||
import org.hibernate.internal.util.StringHelper;
|
import org.hibernate.internal.util.StringHelper;
|
||||||
import org.hibernate.mapping.Bag;
|
import org.hibernate.mapping.Bag;
|
||||||
import org.hibernate.mapping.Column;
|
import org.hibernate.mapping.Column;
|
||||||
|
@ -20,6 +22,7 @@ import org.hibernate.mapping.Property;
|
||||||
import org.hibernate.mapping.Set;
|
import org.hibernate.mapping.Set;
|
||||||
import org.hibernate.mapping.Table;
|
import org.hibernate.mapping.Table;
|
||||||
import org.hibernate.mapping.UniqueKey;
|
import org.hibernate.mapping.UniqueKey;
|
||||||
|
import org.hibernate.metamodel.CollectionClassification;
|
||||||
|
|
||||||
import org.hibernate.testing.junit4.BaseNonConfigCoreFunctionalTestCase;
|
import org.hibernate.testing.junit4.BaseNonConfigCoreFunctionalTestCase;
|
||||||
import org.junit.Test;
|
import org.junit.Test;
|
||||||
|
@ -39,6 +42,12 @@ public abstract class AbstractJPAIndexTest extends BaseNonConfigCoreFunctionalTe
|
||||||
metadataBuilder.applyImplicitNamingStrategy( ImplicitNamingStrategyJpaCompliantImpl.INSTANCE );
|
metadataBuilder.applyImplicitNamingStrategy( ImplicitNamingStrategyJpaCompliantImpl.INSTANCE );
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
protected void configureStandardServiceRegistryBuilder(StandardServiceRegistryBuilder ssrb) {
|
||||||
|
super.configureStandardServiceRegistryBuilder( ssrb );
|
||||||
|
ssrb.applySetting( AvailableSettings.DEFAULT_LIST_SEMANTICS, CollectionClassification.BAG );
|
||||||
|
}
|
||||||
|
|
||||||
@Test
|
@Test
|
||||||
public void testTableIndex() {
|
public void testTableIndex() {
|
||||||
PersistentClass entity = metadata().getEntityBinding( Car.class.getName() );
|
PersistentClass entity = metadata().getEntityBinding( Car.class.getName() );
|
||||||
|
|
|
@ -23,7 +23,9 @@ import jakarta.persistence.criteria.Root;
|
||||||
import org.hibernate.Hibernate;
|
import org.hibernate.Hibernate;
|
||||||
import org.hibernate.Session;
|
import org.hibernate.Session;
|
||||||
import org.hibernate.Transaction;
|
import org.hibernate.Transaction;
|
||||||
|
import org.hibernate.cfg.AvailableSettings;
|
||||||
import org.hibernate.cfg.Configuration;
|
import org.hibernate.cfg.Configuration;
|
||||||
|
import org.hibernate.metamodel.CollectionClassification;
|
||||||
|
|
||||||
import org.hibernate.testing.TestForIssue;
|
import org.hibernate.testing.TestForIssue;
|
||||||
import org.hibernate.testing.junit4.BaseCoreFunctionalTestCase;
|
import org.hibernate.testing.junit4.BaseCoreFunctionalTestCase;
|
||||||
|
@ -45,6 +47,7 @@ public class ManyToManyTest extends BaseCoreFunctionalTestCase {
|
||||||
@Override
|
@Override
|
||||||
protected void configure(Configuration configuration) {
|
protected void configure(Configuration configuration) {
|
||||||
super.configure( configuration );
|
super.configure( configuration );
|
||||||
|
configuration.setProperty( AvailableSettings.DEFAULT_LIST_SEMANTICS, CollectionClassification.BAG.name() );
|
||||||
// configuration.setImplicitNamingStrategy( ImplicitNamingStrategyJpaCompliantImpl.INSTANCE );
|
// configuration.setImplicitNamingStrategy( ImplicitNamingStrategyJpaCompliantImpl.INSTANCE );
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -12,6 +12,7 @@ import java.util.Collections;
|
||||||
import java.util.HashSet;
|
import java.util.HashSet;
|
||||||
import java.util.Iterator;
|
import java.util.Iterator;
|
||||||
import java.util.List;
|
import java.util.List;
|
||||||
|
import java.util.Map;
|
||||||
import java.util.Set;
|
import java.util.Set;
|
||||||
import java.util.SortedSet;
|
import java.util.SortedSet;
|
||||||
import java.util.TreeSet;
|
import java.util.TreeSet;
|
||||||
|
@ -36,6 +37,7 @@ import org.hibernate.exception.ConstraintViolationException;
|
||||||
import org.hibernate.mapping.Column;
|
import org.hibernate.mapping.Column;
|
||||||
import org.hibernate.mapping.PersistentClass;
|
import org.hibernate.mapping.PersistentClass;
|
||||||
import org.hibernate.mapping.Table;
|
import org.hibernate.mapping.Table;
|
||||||
|
import org.hibernate.metamodel.CollectionClassification;
|
||||||
|
|
||||||
import org.hibernate.testing.DialectChecks;
|
import org.hibernate.testing.DialectChecks;
|
||||||
import org.hibernate.testing.RequiresDialectFeature;
|
import org.hibernate.testing.RequiresDialectFeature;
|
||||||
|
@ -49,6 +51,7 @@ import org.hibernate.test.annotations.TicketComparator;
|
||||||
import org.junit.Assert;
|
import org.junit.Assert;
|
||||||
import org.junit.Test;
|
import org.junit.Test;
|
||||||
|
|
||||||
|
import static org.hibernate.cfg.AvailableSettings.DEFAULT_LIST_SEMANTICS;
|
||||||
import static org.hibernate.testing.junit4.ExtraAssertions.assertTyping;
|
import static org.hibernate.testing.junit4.ExtraAssertions.assertTyping;
|
||||||
import static org.hibernate.testing.transaction.TransactionUtil.doInHibernate;
|
import static org.hibernate.testing.transaction.TransactionUtil.doInHibernate;
|
||||||
import static org.junit.Assert.assertEquals;
|
import static org.junit.Assert.assertEquals;
|
||||||
|
@ -570,6 +573,13 @@ public class OneToManyTest extends BaseNonConfigCoreFunctionalTestCase {
|
||||||
return new String[] { "org/hibernate/orm/test/annotations/onetomany/orm.xml" };
|
return new String[] { "org/hibernate/orm/test/annotations/onetomany/orm.xml" };
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
protected void addSettings(Map settings) {
|
||||||
|
super.addSettings( settings );
|
||||||
|
// needed for `#testListWithBagSemanticAndOrderBy`
|
||||||
|
settings.put( DEFAULT_LIST_SEMANTICS, CollectionClassification.BAG.name() );
|
||||||
|
}
|
||||||
|
|
||||||
@Entity(name = "OnDeleteUnidirectionalOneToManyParent")
|
@Entity(name = "OnDeleteUnidirectionalOneToManyParent")
|
||||||
@jakarta.persistence.Table(name = "OneToManyParent")
|
@jakarta.persistence.Table(name = "OneToManyParent")
|
||||||
public static class OnDeleteUnidirectionalOneToManyParent {
|
public static class OnDeleteUnidirectionalOneToManyParent {
|
||||||
|
|
|
@ -6,6 +6,7 @@
|
||||||
*/
|
*/
|
||||||
package org.hibernate.orm.test.annotations.onetomany;
|
package org.hibernate.orm.test.annotations.onetomany;
|
||||||
|
|
||||||
|
import static org.hibernate.cfg.AvailableSettings.DEFAULT_LIST_SEMANTICS;
|
||||||
import static org.junit.Assert.assertEquals;
|
import static org.junit.Assert.assertEquals;
|
||||||
import static org.junit.Assert.assertFalse;
|
import static org.junit.Assert.assertFalse;
|
||||||
import static org.junit.Assert.assertTrue;
|
import static org.junit.Assert.assertTrue;
|
||||||
|
@ -30,6 +31,7 @@ import org.hibernate.dialect.OracleDialect;
|
||||||
import org.hibernate.dialect.SQLServerDialect;
|
import org.hibernate.dialect.SQLServerDialect;
|
||||||
import org.hibernate.engine.spi.SessionImplementor;
|
import org.hibernate.engine.spi.SessionImplementor;
|
||||||
import org.hibernate.graph.RootGraph;
|
import org.hibernate.graph.RootGraph;
|
||||||
|
import org.hibernate.metamodel.CollectionClassification;
|
||||||
import org.hibernate.persister.collection.CollectionPersister;
|
import org.hibernate.persister.collection.CollectionPersister;
|
||||||
import org.hibernate.persister.collection.QueryableCollection;
|
import org.hibernate.persister.collection.QueryableCollection;
|
||||||
import org.hibernate.query.Query;
|
import org.hibernate.query.Query;
|
||||||
|
@ -500,6 +502,7 @@ public class OrderByTest extends BaseCoreFunctionalTestCase {
|
||||||
@Override
|
@Override
|
||||||
protected void configure(Configuration configuration) {
|
protected void configure(Configuration configuration) {
|
||||||
configuration.setProperty( AvailableSettings.DEFAULT_NULL_ORDERING, "last" );
|
configuration.setProperty( AvailableSettings.DEFAULT_NULL_ORDERING, "last" );
|
||||||
|
configuration.setProperty( DEFAULT_LIST_SEMANTICS, CollectionClassification.BAG.name() );
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
|
|
|
@ -13,10 +13,12 @@ import org.hibernate.cfg.AvailableSettings;
|
||||||
|
|
||||||
import org.hibernate.testing.TestForIssue;
|
import org.hibernate.testing.TestForIssue;
|
||||||
import org.hibernate.testing.orm.junit.DomainModel;
|
import org.hibernate.testing.orm.junit.DomainModel;
|
||||||
|
import org.hibernate.testing.orm.junit.ImplicitListAsBagProvider;
|
||||||
import org.hibernate.testing.orm.junit.ServiceRegistry;
|
import org.hibernate.testing.orm.junit.ServiceRegistry;
|
||||||
import org.hibernate.testing.orm.junit.SessionFactory;
|
import org.hibernate.testing.orm.junit.SessionFactory;
|
||||||
import org.hibernate.testing.orm.junit.SessionFactoryScope;
|
import org.hibernate.testing.orm.junit.SessionFactoryScope;
|
||||||
import org.hibernate.testing.orm.junit.Setting;
|
import org.hibernate.testing.orm.junit.Setting;
|
||||||
|
import org.hibernate.testing.orm.junit.SettingProvider;
|
||||||
import org.junit.jupiter.api.Test;
|
import org.junit.jupiter.api.Test;
|
||||||
|
|
||||||
import jakarta.persistence.CascadeType;
|
import jakarta.persistence.CascadeType;
|
||||||
|
@ -29,6 +31,7 @@ import jakarta.persistence.OneToMany;
|
||||||
import jakarta.persistence.OrderBy;
|
import jakarta.persistence.OrderBy;
|
||||||
import jakarta.persistence.Table;
|
import jakarta.persistence.Table;
|
||||||
|
|
||||||
|
import static org.hibernate.cfg.AvailableSettings.DEFAULT_LIST_SEMANTICS;
|
||||||
import static org.junit.jupiter.api.Assertions.assertEquals;
|
import static org.junit.jupiter.api.Assertions.assertEquals;
|
||||||
import static org.junit.jupiter.api.Assertions.assertNotNull;
|
import static org.junit.jupiter.api.Assertions.assertNotNull;
|
||||||
|
|
||||||
|
@ -45,7 +48,11 @@ import static org.junit.jupiter.api.Assertions.assertNotNull;
|
||||||
@Setting(name = AvailableSettings.SHOW_SQL, value = "true"),
|
@Setting(name = AvailableSettings.SHOW_SQL, value = "true"),
|
||||||
@Setting(name = AvailableSettings.FORMAT_SQL, value = "true"),
|
@Setting(name = AvailableSettings.FORMAT_SQL, value = "true"),
|
||||||
@Setting(name = AvailableSettings.DEFAULT_BATCH_FETCH_SIZE, value = "64")
|
@Setting(name = AvailableSettings.DEFAULT_BATCH_FETCH_SIZE, value = "64")
|
||||||
}
|
},
|
||||||
|
settingProviders = @SettingProvider(
|
||||||
|
settingName = DEFAULT_LIST_SEMANTICS,
|
||||||
|
provider = ImplicitListAsBagProvider.class
|
||||||
|
)
|
||||||
)
|
)
|
||||||
public class BatchFetchReferencedColumnNameTest {
|
public class BatchFetchReferencedColumnNameTest {
|
||||||
|
|
||||||
|
|
|
@ -10,6 +10,7 @@ import org.hibernate.annotations.LazyToOne;
|
||||||
import org.hibernate.annotations.LazyToOneOption;
|
import org.hibernate.annotations.LazyToOneOption;
|
||||||
import org.hibernate.cfg.AvailableSettings;
|
import org.hibernate.cfg.AvailableSettings;
|
||||||
import org.hibernate.cfg.Configuration;
|
import org.hibernate.cfg.Configuration;
|
||||||
|
import org.hibernate.metamodel.CollectionClassification;
|
||||||
|
|
||||||
import org.hibernate.testing.bytecode.enhancement.BytecodeEnhancerRunner;
|
import org.hibernate.testing.bytecode.enhancement.BytecodeEnhancerRunner;
|
||||||
import org.hibernate.testing.junit4.BaseCoreFunctionalTestCase;
|
import org.hibernate.testing.junit4.BaseCoreFunctionalTestCase;
|
||||||
|
@ -30,6 +31,7 @@ import jakarta.persistence.Table;
|
||||||
import java.util.ArrayList;
|
import java.util.ArrayList;
|
||||||
import java.util.List;
|
import java.util.List;
|
||||||
|
|
||||||
|
import static org.hibernate.cfg.AvailableSettings.DEFAULT_LIST_SEMANTICS;
|
||||||
import static org.hibernate.testing.bytecode.enhancement.EnhancerTestUtils.checkDirtyTracking;
|
import static org.hibernate.testing.bytecode.enhancement.EnhancerTestUtils.checkDirtyTracking;
|
||||||
import static org.hibernate.testing.transaction.TransactionUtil.doInHibernate;
|
import static org.hibernate.testing.transaction.TransactionUtil.doInHibernate;
|
||||||
|
|
||||||
|
@ -51,6 +53,7 @@ public class LazyLoadingIntegrationTest extends BaseCoreFunctionalTestCase {
|
||||||
protected void configure(Configuration configuration) {
|
protected void configure(Configuration configuration) {
|
||||||
configuration.setProperty( AvailableSettings.USE_SECOND_LEVEL_CACHE, "false" );
|
configuration.setProperty( AvailableSettings.USE_SECOND_LEVEL_CACHE, "false" );
|
||||||
configuration.setProperty( AvailableSettings.ENABLE_LAZY_LOAD_NO_TRANS, "true" );
|
configuration.setProperty( AvailableSettings.ENABLE_LAZY_LOAD_NO_TRANS, "true" );
|
||||||
|
configuration.setProperty( DEFAULT_LIST_SEMANTICS, CollectionClassification.BAG.name() );
|
||||||
}
|
}
|
||||||
|
|
||||||
@Before
|
@Before
|
||||||
|
|
|
@ -7,10 +7,13 @@
|
||||||
package org.hibernate.orm.test.bytecode.enhancement.lazy.proxy;
|
package org.hibernate.orm.test.bytecode.enhancement.lazy.proxy;
|
||||||
|
|
||||||
import static org.assertj.core.api.Assertions.assertThatThrownBy;
|
import static org.assertj.core.api.Assertions.assertThatThrownBy;
|
||||||
|
import static org.hibernate.cfg.AvailableSettings.DEFAULT_LIST_SEMANTICS;
|
||||||
import static org.hibernate.testing.transaction.TransactionUtil.doInHibernate;
|
import static org.hibernate.testing.transaction.TransactionUtil.doInHibernate;
|
||||||
|
|
||||||
import java.util.ArrayList;
|
import java.util.ArrayList;
|
||||||
import java.util.List;
|
import java.util.List;
|
||||||
|
import java.util.Map;
|
||||||
|
|
||||||
import jakarta.persistence.Entity;
|
import jakarta.persistence.Entity;
|
||||||
import jakarta.persistence.FetchType;
|
import jakarta.persistence.FetchType;
|
||||||
import jakarta.persistence.Id;
|
import jakarta.persistence.Id;
|
||||||
|
@ -18,6 +21,7 @@ import jakarta.persistence.ManyToMany;
|
||||||
import jakarta.persistence.Table;
|
import jakarta.persistence.Table;
|
||||||
|
|
||||||
import org.hibernate.LazyInitializationException;
|
import org.hibernate.LazyInitializationException;
|
||||||
|
import org.hibernate.metamodel.CollectionClassification;
|
||||||
|
|
||||||
import org.hibernate.testing.TestForIssue;
|
import org.hibernate.testing.TestForIssue;
|
||||||
import org.hibernate.testing.bytecode.enhancement.BytecodeEnhancerRunner;
|
import org.hibernate.testing.bytecode.enhancement.BytecodeEnhancerRunner;
|
||||||
|
@ -38,6 +42,12 @@ public class BytecodeEnhancedLazyLoadingOnDeletedEntityTest
|
||||||
return new Class<?>[] { AssociationOwner.class, AssociationNonOwner.class };
|
return new Class<?>[] { AssociationOwner.class, AssociationNonOwner.class };
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
protected void addSettings(Map settings) {
|
||||||
|
super.addSettings( settings );
|
||||||
|
settings.put( DEFAULT_LIST_SEMANTICS, CollectionClassification.BAG.name() );
|
||||||
|
}
|
||||||
|
|
||||||
@After
|
@After
|
||||||
public void tearDown() {
|
public void tearDown() {
|
||||||
doInHibernate( this::sessionFactory, s -> {
|
doInHibernate( this::sessionFactory, s -> {
|
||||||
|
|
|
@ -13,6 +13,7 @@ import org.hibernate.cache.spi.access.CollectionDataAccess;
|
||||||
import org.hibernate.cfg.Configuration;
|
import org.hibernate.cfg.Configuration;
|
||||||
import org.hibernate.cfg.Environment;
|
import org.hibernate.cfg.Environment;
|
||||||
import org.hibernate.engine.spi.SessionImplementor;
|
import org.hibernate.engine.spi.SessionImplementor;
|
||||||
|
import org.hibernate.metamodel.CollectionClassification;
|
||||||
import org.hibernate.persister.collection.CollectionPersister;
|
import org.hibernate.persister.collection.CollectionPersister;
|
||||||
|
|
||||||
import org.hibernate.testing.TestForIssue;
|
import org.hibernate.testing.TestForIssue;
|
||||||
|
@ -21,6 +22,7 @@ import org.junit.After;
|
||||||
import org.junit.Before;
|
import org.junit.Before;
|
||||||
import org.junit.Test;
|
import org.junit.Test;
|
||||||
|
|
||||||
|
import static org.hibernate.cfg.AvailableSettings.DEFAULT_LIST_SEMANTICS;
|
||||||
import static org.junit.Assert.assertEquals;
|
import static org.junit.Assert.assertEquals;
|
||||||
import static org.junit.Assert.assertNotNull;
|
import static org.junit.Assert.assertNotNull;
|
||||||
import static org.junit.Assert.assertNull;
|
import static org.junit.Assert.assertNull;
|
||||||
|
@ -53,6 +55,7 @@ public class CollectionCacheEvictionTest extends BaseCoreFunctionalTestCase {
|
||||||
cfg.setProperty( Environment.USE_SECOND_LEVEL_CACHE, "true" );
|
cfg.setProperty( Environment.USE_SECOND_LEVEL_CACHE, "true" );
|
||||||
cfg.setProperty( Environment.USE_QUERY_CACHE, "true" );
|
cfg.setProperty( Environment.USE_QUERY_CACHE, "true" );
|
||||||
cfg.setProperty( Environment.CACHE_PROVIDER_CONFIG, "true" );
|
cfg.setProperty( Environment.CACHE_PROVIDER_CONFIG, "true" );
|
||||||
|
cfg.setProperty( DEFAULT_LIST_SEMANTICS, CollectionClassification.BAG.name() );
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
|
|
|
@ -9,10 +9,12 @@ import org.hibernate.Session;
|
||||||
import org.hibernate.cache.internal.CollectionCacheInvalidator;
|
import org.hibernate.cache.internal.CollectionCacheInvalidator;
|
||||||
import org.hibernate.cfg.Configuration;
|
import org.hibernate.cfg.Configuration;
|
||||||
import org.hibernate.cfg.Environment;
|
import org.hibernate.cfg.Environment;
|
||||||
|
import org.hibernate.metamodel.CollectionClassification;
|
||||||
|
|
||||||
import org.hibernate.testing.TestForIssue;
|
import org.hibernate.testing.TestForIssue;
|
||||||
import org.hibernate.testing.junit4.BaseCoreFunctionalTestCase;
|
import org.hibernate.testing.junit4.BaseCoreFunctionalTestCase;
|
||||||
|
|
||||||
|
import static org.hibernate.cfg.AvailableSettings.DEFAULT_LIST_SEMANTICS;
|
||||||
import static org.junit.Assert.assertEquals;
|
import static org.junit.Assert.assertEquals;
|
||||||
import static org.junit.Assert.assertFalse;
|
import static org.junit.Assert.assertFalse;
|
||||||
import static org.junit.Assert.assertNull;
|
import static org.junit.Assert.assertNull;
|
||||||
|
@ -45,6 +47,7 @@ public class LockModeTest extends BaseCoreFunctionalTestCase {
|
||||||
cfg.setProperty( Environment.USE_SECOND_LEVEL_CACHE, "true" );
|
cfg.setProperty( Environment.USE_SECOND_LEVEL_CACHE, "true" );
|
||||||
cfg.setProperty( Environment.USE_QUERY_CACHE, "true" );
|
cfg.setProperty( Environment.USE_QUERY_CACHE, "true" );
|
||||||
cfg.setProperty( Environment.CACHE_PROVIDER_CONFIG, "true" );
|
cfg.setProperty( Environment.CACHE_PROVIDER_CONFIG, "true" );
|
||||||
|
cfg.setProperty( DEFAULT_LIST_SEMANTICS, CollectionClassification.BAG.name() );
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
|
|
|
@ -15,12 +15,14 @@ import org.hibernate.annotations.CacheConcurrencyStrategy;
|
||||||
import org.hibernate.cache.internal.CollectionCacheInvalidator;
|
import org.hibernate.cache.internal.CollectionCacheInvalidator;
|
||||||
import org.hibernate.cfg.Configuration;
|
import org.hibernate.cfg.Configuration;
|
||||||
import org.hibernate.cfg.Environment;
|
import org.hibernate.cfg.Environment;
|
||||||
|
import org.hibernate.metamodel.CollectionClassification;
|
||||||
|
|
||||||
import org.hibernate.testing.junit4.BaseCoreFunctionalTestCase;
|
import org.hibernate.testing.junit4.BaseCoreFunctionalTestCase;
|
||||||
import org.junit.After;
|
import org.junit.After;
|
||||||
import org.junit.Before;
|
import org.junit.Before;
|
||||||
import org.junit.Test;
|
import org.junit.Test;
|
||||||
|
|
||||||
|
import static org.hibernate.cfg.AvailableSettings.DEFAULT_LIST_SEMANTICS;
|
||||||
import static org.junit.Assert.assertEquals;
|
import static org.junit.Assert.assertEquals;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
@ -49,6 +51,7 @@ public class ManyToManyCollectionCacheEvictionTest extends BaseCoreFunctionalTes
|
||||||
cfg.setProperty( Environment.USE_SECOND_LEVEL_CACHE, "true" );
|
cfg.setProperty( Environment.USE_SECOND_LEVEL_CACHE, "true" );
|
||||||
cfg.setProperty( Environment.USE_QUERY_CACHE, "true" );
|
cfg.setProperty( Environment.USE_QUERY_CACHE, "true" );
|
||||||
cfg.setProperty( Environment.CACHE_PROVIDER_CONFIG, "true" );
|
cfg.setProperty( Environment.CACHE_PROVIDER_CONFIG, "true" );
|
||||||
|
cfg.setProperty( DEFAULT_LIST_SEMANTICS, CollectionClassification.BAG.name() );
|
||||||
}
|
}
|
||||||
|
|
||||||
@Test
|
@Test
|
||||||
|
|
|
@ -8,6 +8,9 @@ package org.hibernate.orm.test.collection.bag;
|
||||||
|
|
||||||
import java.util.ArrayList;
|
import java.util.ArrayList;
|
||||||
import java.util.List;
|
import java.util.List;
|
||||||
|
|
||||||
|
import org.hibernate.testing.orm.junit.ImplicitListAsBagProvider;
|
||||||
|
|
||||||
import jakarta.persistence.CollectionTable;
|
import jakarta.persistence.CollectionTable;
|
||||||
import jakarta.persistence.Column;
|
import jakarta.persistence.Column;
|
||||||
import jakarta.persistence.ElementCollection;
|
import jakarta.persistence.ElementCollection;
|
||||||
|
@ -20,16 +23,24 @@ import jakarta.persistence.Table;
|
||||||
|
|
||||||
import org.hibernate.testing.TestForIssue;
|
import org.hibernate.testing.TestForIssue;
|
||||||
import org.hibernate.testing.orm.junit.DomainModel;
|
import org.hibernate.testing.orm.junit.DomainModel;
|
||||||
|
import org.hibernate.testing.orm.junit.ServiceRegistry;
|
||||||
import org.hibernate.testing.orm.junit.SessionFactory;
|
import org.hibernate.testing.orm.junit.SessionFactory;
|
||||||
import org.hibernate.testing.orm.junit.SessionFactoryScope;
|
import org.hibernate.testing.orm.junit.SessionFactoryScope;
|
||||||
|
import org.hibernate.testing.orm.junit.SettingProvider;
|
||||||
import org.junit.jupiter.api.Test;
|
import org.junit.jupiter.api.Test;
|
||||||
|
|
||||||
|
import static org.hibernate.cfg.AvailableSettings.DEFAULT_LIST_SEMANTICS;
|
||||||
import static org.junit.jupiter.api.Assertions.assertEquals;
|
import static org.junit.jupiter.api.Assertions.assertEquals;
|
||||||
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @author Gail Badner
|
* @author Gail Badner
|
||||||
*/
|
*/
|
||||||
|
@ServiceRegistry(
|
||||||
|
settingProviders = @SettingProvider(
|
||||||
|
settingName = DEFAULT_LIST_SEMANTICS,
|
||||||
|
provider = ImplicitListAsBagProvider.class )
|
||||||
|
)
|
||||||
@DomainModel(annotatedClasses = {
|
@DomainModel(annotatedClasses = {
|
||||||
BagElementNullBasicTest.AnEntity.class,
|
BagElementNullBasicTest.AnEntity.class,
|
||||||
BagElementNullBasicTest.NullableElementsEntity.class
|
BagElementNullBasicTest.NullableElementsEntity.class
|
||||||
|
|
|
@ -18,17 +18,26 @@ import jakarta.persistence.OneToMany;
|
||||||
import jakarta.persistence.Table;
|
import jakarta.persistence.Table;
|
||||||
|
|
||||||
import org.hibernate.loader.MultipleBagFetchException;
|
import org.hibernate.loader.MultipleBagFetchException;
|
||||||
|
import org.hibernate.testing.orm.junit.ImplicitListAsBagProvider;
|
||||||
|
|
||||||
import org.hibernate.testing.orm.junit.DomainModel;
|
import org.hibernate.testing.orm.junit.DomainModel;
|
||||||
|
import org.hibernate.testing.orm.junit.ServiceRegistry;
|
||||||
import org.hibernate.testing.orm.junit.SessionFactory;
|
import org.hibernate.testing.orm.junit.SessionFactory;
|
||||||
import org.hibernate.testing.orm.junit.SessionFactoryScope;
|
import org.hibernate.testing.orm.junit.SessionFactoryScope;
|
||||||
|
import org.hibernate.testing.orm.junit.SettingProvider;
|
||||||
import org.junit.jupiter.api.AfterEach;
|
import org.junit.jupiter.api.AfterEach;
|
||||||
import org.junit.jupiter.api.BeforeEach;
|
import org.junit.jupiter.api.BeforeEach;
|
||||||
import org.junit.jupiter.api.Test;
|
import org.junit.jupiter.api.Test;
|
||||||
|
|
||||||
|
import static org.hibernate.cfg.AvailableSettings.DEFAULT_LIST_SEMANTICS;
|
||||||
import static org.junit.jupiter.api.Assertions.assertTrue;
|
import static org.junit.jupiter.api.Assertions.assertTrue;
|
||||||
import static org.junit.jupiter.api.Assertions.fail;
|
import static org.junit.jupiter.api.Assertions.fail;
|
||||||
|
|
||||||
|
@ServiceRegistry(
|
||||||
|
settingProviders = @SettingProvider(
|
||||||
|
settingName = DEFAULT_LIST_SEMANTICS,
|
||||||
|
provider = ImplicitListAsBagProvider.class )
|
||||||
|
)
|
||||||
@DomainModel(
|
@DomainModel(
|
||||||
annotatedClasses = {
|
annotatedClasses = {
|
||||||
MultipleBagFetchHqlTest.Post.class,
|
MultipleBagFetchHqlTest.Post.class,
|
||||||
|
|
|
@ -24,6 +24,7 @@ import jakarta.persistence.OneToMany;
|
||||||
|
|
||||||
import org.hibernate.Hibernate;
|
import org.hibernate.Hibernate;
|
||||||
import org.hibernate.collection.spi.AbstractPersistentCollection;
|
import org.hibernate.collection.spi.AbstractPersistentCollection;
|
||||||
|
import org.hibernate.testing.orm.junit.ImplicitListAsBagProvider;
|
||||||
import org.hibernate.type.CollectionType;
|
import org.hibernate.type.CollectionType;
|
||||||
|
|
||||||
import org.hibernate.testing.TestForIssue;
|
import org.hibernate.testing.TestForIssue;
|
||||||
|
@ -31,12 +32,15 @@ import org.hibernate.testing.orm.junit.DomainModel;
|
||||||
import org.hibernate.testing.orm.junit.LoggingInspections;
|
import org.hibernate.testing.orm.junit.LoggingInspections;
|
||||||
import org.hibernate.testing.orm.junit.LoggingInspectionsScope;
|
import org.hibernate.testing.orm.junit.LoggingInspectionsScope;
|
||||||
import org.hibernate.testing.orm.junit.MessageKeyWatcher;
|
import org.hibernate.testing.orm.junit.MessageKeyWatcher;
|
||||||
|
import org.hibernate.testing.orm.junit.ServiceRegistry;
|
||||||
import org.hibernate.testing.orm.junit.SessionFactory;
|
import org.hibernate.testing.orm.junit.SessionFactory;
|
||||||
import org.hibernate.testing.orm.junit.SessionFactoryScope;
|
import org.hibernate.testing.orm.junit.SessionFactoryScope;
|
||||||
|
import org.hibernate.testing.orm.junit.SettingProvider;
|
||||||
import org.junit.jupiter.api.AfterEach;
|
import org.junit.jupiter.api.AfterEach;
|
||||||
import org.junit.jupiter.api.BeforeEach;
|
import org.junit.jupiter.api.BeforeEach;
|
||||||
import org.junit.jupiter.api.Test;
|
import org.junit.jupiter.api.Test;
|
||||||
|
|
||||||
|
import static org.hibernate.cfg.AvailableSettings.DEFAULT_LIST_SEMANTICS;
|
||||||
import static org.junit.jupiter.api.Assertions.assertEquals;
|
import static org.junit.jupiter.api.Assertions.assertEquals;
|
||||||
import static org.junit.jupiter.api.Assertions.assertFalse;
|
import static org.junit.jupiter.api.Assertions.assertFalse;
|
||||||
import static org.junit.jupiter.api.Assertions.assertTrue;
|
import static org.junit.jupiter.api.Assertions.assertTrue;
|
||||||
|
@ -47,6 +51,11 @@ import static org.junit.jupiter.api.Assertions.fail;
|
||||||
*
|
*
|
||||||
* @author Gail Badner
|
* @author Gail Badner
|
||||||
*/
|
*/
|
||||||
|
@ServiceRegistry(
|
||||||
|
settingProviders = @SettingProvider(
|
||||||
|
settingName = DEFAULT_LIST_SEMANTICS,
|
||||||
|
provider = ImplicitListAsBagProvider.class )
|
||||||
|
)
|
||||||
@DomainModel(
|
@DomainModel(
|
||||||
annotatedClasses = {
|
annotatedClasses = {
|
||||||
DetachedBagDelayedOperationTest.Parent.class,
|
DetachedBagDelayedOperationTest.Parent.class,
|
||||||
|
|
|
@ -12,8 +12,11 @@ import java.util.List;
|
||||||
|
|
||||||
import org.hibernate.testing.TestForIssue;
|
import org.hibernate.testing.TestForIssue;
|
||||||
import org.hibernate.testing.orm.junit.DomainModel;
|
import org.hibernate.testing.orm.junit.DomainModel;
|
||||||
|
import org.hibernate.testing.orm.junit.ImplicitListAsBagProvider;
|
||||||
|
import org.hibernate.testing.orm.junit.ServiceRegistry;
|
||||||
import org.hibernate.testing.orm.junit.SessionFactory;
|
import org.hibernate.testing.orm.junit.SessionFactory;
|
||||||
import org.hibernate.testing.orm.junit.SessionFactoryScope;
|
import org.hibernate.testing.orm.junit.SessionFactoryScope;
|
||||||
|
import org.hibernate.testing.orm.junit.SettingProvider;
|
||||||
import org.junit.jupiter.api.Test;
|
import org.junit.jupiter.api.Test;
|
||||||
|
|
||||||
import jakarta.persistence.Column;
|
import jakarta.persistence.Column;
|
||||||
|
@ -30,6 +33,7 @@ import jakarta.persistence.OneToMany;
|
||||||
import jakarta.persistence.Table;
|
import jakarta.persistence.Table;
|
||||||
|
|
||||||
import static org.assertj.core.api.Assertions.assertThat;
|
import static org.assertj.core.api.Assertions.assertThat;
|
||||||
|
import static org.hibernate.cfg.AvailableSettings.DEFAULT_LIST_SEMANTICS;
|
||||||
import static org.hibernate.orm.test.util.SchemaUtil.getColumnNames;
|
import static org.hibernate.orm.test.util.SchemaUtil.getColumnNames;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
@ -58,6 +62,12 @@ import static org.hibernate.orm.test.util.SchemaUtil.getColumnNames;
|
||||||
* at org.hibernate.testing.junit4.TestClassMetadata.performCallbackInvocation(TestClassMetadata.java:205)
|
* at org.hibernate.testing.junit4.TestClassMetadata.performCallbackInvocation(TestClassMetadata.java:205)
|
||||||
*/
|
*/
|
||||||
@TestForIssue(jiraKey = "HHH-13295")
|
@TestForIssue(jiraKey = "HHH-13295")
|
||||||
|
@ServiceRegistry(
|
||||||
|
settingProviders = @SettingProvider(
|
||||||
|
settingName = DEFAULT_LIST_SEMANTICS,
|
||||||
|
provider = ImplicitListAsBagProvider.class
|
||||||
|
)
|
||||||
|
)
|
||||||
@DomainModel(
|
@DomainModel(
|
||||||
annotatedClasses = {
|
annotatedClasses = {
|
||||||
EmbeddedIdWithMapsIdTargetingDerivedEntityTest.Attendance.class,
|
EmbeddedIdWithMapsIdTargetingDerivedEntityTest.Attendance.class,
|
||||||
|
|
|
@ -17,12 +17,15 @@ import jakarta.persistence.ManyToOne;
|
||||||
import jakarta.persistence.OrderBy;
|
import jakarta.persistence.OrderBy;
|
||||||
|
|
||||||
import org.hibernate.Session;
|
import org.hibernate.Session;
|
||||||
|
import org.hibernate.cfg.Configuration;
|
||||||
|
import org.hibernate.metamodel.CollectionClassification;
|
||||||
import org.hibernate.query.Query;
|
import org.hibernate.query.Query;
|
||||||
|
|
||||||
import org.hibernate.testing.junit4.BaseCoreFunctionalTestCase;
|
import org.hibernate.testing.junit4.BaseCoreFunctionalTestCase;
|
||||||
import org.junit.Test;
|
import org.junit.Test;
|
||||||
|
|
||||||
import static org.assertj.core.api.Assertions.assertThat;
|
import static org.assertj.core.api.Assertions.assertThat;
|
||||||
|
import static org.hibernate.cfg.AvailableSettings.DEFAULT_LIST_SEMANTICS;
|
||||||
|
|
||||||
public class OrderByEmbeddableToOneTest extends BaseCoreFunctionalTestCase {
|
public class OrderByEmbeddableToOneTest extends BaseCoreFunctionalTestCase {
|
||||||
|
|
||||||
|
@ -31,6 +34,12 @@ public class OrderByEmbeddableToOneTest extends BaseCoreFunctionalTestCase {
|
||||||
return new Class[] { Containing.class, Embed.class, Contained.class };
|
return new Class[] { Containing.class, Embed.class, Contained.class };
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
protected void configure(Configuration configuration) {
|
||||||
|
super.configure( configuration );
|
||||||
|
configuration.setProperty( DEFAULT_LIST_SEMANTICS, CollectionClassification.BAG.name() );
|
||||||
|
}
|
||||||
|
|
||||||
@Test
|
@Test
|
||||||
public void test() {
|
public void test() {
|
||||||
inTransaction( session -> {
|
inTransaction( session -> {
|
||||||
|
|
|
@ -17,12 +17,15 @@ import jakarta.persistence.Id;
|
||||||
import jakarta.persistence.OrderBy;
|
import jakarta.persistence.OrderBy;
|
||||||
|
|
||||||
import org.hibernate.Session;
|
import org.hibernate.Session;
|
||||||
|
import org.hibernate.cfg.Configuration;
|
||||||
|
import org.hibernate.metamodel.CollectionClassification;
|
||||||
import org.hibernate.query.Query;
|
import org.hibernate.query.Query;
|
||||||
|
|
||||||
import org.hibernate.testing.junit4.BaseCoreFunctionalTestCase;
|
import org.hibernate.testing.junit4.BaseCoreFunctionalTestCase;
|
||||||
import org.junit.Test;
|
import org.junit.Test;
|
||||||
|
|
||||||
import static org.assertj.core.api.Assertions.assertThat;
|
import static org.assertj.core.api.Assertions.assertThat;
|
||||||
|
import static org.hibernate.cfg.AvailableSettings.DEFAULT_LIST_SEMANTICS;
|
||||||
|
|
||||||
public class OrderByEmbeddableX2Test extends BaseCoreFunctionalTestCase {
|
public class OrderByEmbeddableX2Test extends BaseCoreFunctionalTestCase {
|
||||||
|
|
||||||
|
@ -31,6 +34,12 @@ public class OrderByEmbeddableX2Test extends BaseCoreFunctionalTestCase {
|
||||||
return new Class[] { Containing.class, Embed.class, Contained.class };
|
return new Class[] { Containing.class, Embed.class, Contained.class };
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
protected void configure(Configuration configuration) {
|
||||||
|
super.configure( configuration );
|
||||||
|
configuration.setProperty( DEFAULT_LIST_SEMANTICS, CollectionClassification.BAG.name() );
|
||||||
|
}
|
||||||
|
|
||||||
@Test
|
@Test
|
||||||
public void test() {
|
public void test() {
|
||||||
inTransaction( session -> {
|
inTransaction( session -> {
|
||||||
|
|
|
@ -11,11 +11,13 @@ import java.util.List;
|
||||||
import org.hibernate.Session;
|
import org.hibernate.Session;
|
||||||
import org.hibernate.boot.model.naming.ImplicitNamingStrategyLegacyJpaImpl;
|
import org.hibernate.boot.model.naming.ImplicitNamingStrategyLegacyJpaImpl;
|
||||||
import org.hibernate.cfg.Configuration;
|
import org.hibernate.cfg.Configuration;
|
||||||
|
import org.hibernate.metamodel.CollectionClassification;
|
||||||
|
|
||||||
import org.hibernate.testing.TestForIssue;
|
import org.hibernate.testing.TestForIssue;
|
||||||
import org.hibernate.testing.junit4.BaseCoreFunctionalTestCase;
|
import org.hibernate.testing.junit4.BaseCoreFunctionalTestCase;
|
||||||
import org.junit.Test;
|
import org.junit.Test;
|
||||||
|
|
||||||
|
import static org.hibernate.cfg.AvailableSettings.DEFAULT_LIST_SEMANTICS;
|
||||||
import static org.junit.Assert.assertEquals;
|
import static org.junit.Assert.assertEquals;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
@ -27,6 +29,7 @@ public class BadMergeHandlingTest extends BaseCoreFunctionalTestCase {
|
||||||
protected void configure(Configuration configuration) {
|
protected void configure(Configuration configuration) {
|
||||||
super.configure( configuration );
|
super.configure( configuration );
|
||||||
configuration.setImplicitNamingStrategy( ImplicitNamingStrategyLegacyJpaImpl.INSTANCE );
|
configuration.setImplicitNamingStrategy( ImplicitNamingStrategyLegacyJpaImpl.INSTANCE );
|
||||||
|
configuration.setProperty( DEFAULT_LIST_SEMANTICS, CollectionClassification.BAG.name() );
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
|
|
|
@ -20,12 +20,14 @@ import org.hibernate.event.spi.PostCollectionUpdateEvent;
|
||||||
import org.hibernate.event.spi.PreCollectionRecreateEvent;
|
import org.hibernate.event.spi.PreCollectionRecreateEvent;
|
||||||
import org.hibernate.event.spi.PreCollectionRemoveEvent;
|
import org.hibernate.event.spi.PreCollectionRemoveEvent;
|
||||||
import org.hibernate.event.spi.PreCollectionUpdateEvent;
|
import org.hibernate.event.spi.PreCollectionUpdateEvent;
|
||||||
|
import org.hibernate.metamodel.CollectionClassification;
|
||||||
|
|
||||||
import org.hibernate.testing.TestForIssue;
|
import org.hibernate.testing.TestForIssue;
|
||||||
import org.hibernate.testing.junit4.BaseCoreFunctionalTestCase;
|
import org.hibernate.testing.junit4.BaseCoreFunctionalTestCase;
|
||||||
import org.junit.Before;
|
import org.junit.Before;
|
||||||
import org.junit.Test;
|
import org.junit.Test;
|
||||||
|
|
||||||
|
import static org.hibernate.cfg.AvailableSettings.DEFAULT_LIST_SEMANTICS;
|
||||||
import static org.hibernate.testing.junit4.ExtraAssertions.assertTyping;
|
import static org.hibernate.testing.junit4.ExtraAssertions.assertTyping;
|
||||||
import static org.junit.Assert.assertEquals;
|
import static org.junit.Assert.assertEquals;
|
||||||
|
|
||||||
|
@ -39,6 +41,7 @@ public class MergeCollectionEventTest extends BaseCoreFunctionalTestCase {
|
||||||
protected void configure(Configuration configuration) {
|
protected void configure(Configuration configuration) {
|
||||||
super.configure( configuration );
|
super.configure( configuration );
|
||||||
configuration.setImplicitNamingStrategy( ImplicitNamingStrategyLegacyJpaImpl.INSTANCE );
|
configuration.setImplicitNamingStrategy( ImplicitNamingStrategyLegacyJpaImpl.INSTANCE );
|
||||||
|
configuration.setProperty( DEFAULT_LIST_SEMANTICS, CollectionClassification.BAG.name() );
|
||||||
}
|
}
|
||||||
|
|
||||||
private AggregatedCollectionEventListener.IntegratorImpl collectionListenerIntegrator =
|
private AggregatedCollectionEventListener.IntegratorImpl collectionListenerIntegrator =
|
||||||
|
|
|
@ -21,12 +21,14 @@ import org.hibernate.annotations.FetchMode;
|
||||||
import org.hibernate.annotations.FetchProfile;
|
import org.hibernate.annotations.FetchProfile;
|
||||||
import org.hibernate.cfg.Configuration;
|
import org.hibernate.cfg.Configuration;
|
||||||
import org.hibernate.cfg.Environment;
|
import org.hibernate.cfg.Environment;
|
||||||
|
import org.hibernate.metamodel.CollectionClassification;
|
||||||
|
|
||||||
import org.hibernate.testing.TestForIssue;
|
import org.hibernate.testing.TestForIssue;
|
||||||
import org.hibernate.testing.junit4.BaseCoreFunctionalTestCase;
|
import org.hibernate.testing.junit4.BaseCoreFunctionalTestCase;
|
||||||
import org.junit.Assert;
|
import org.junit.Assert;
|
||||||
import org.junit.Test;
|
import org.junit.Test;
|
||||||
|
|
||||||
|
import static org.hibernate.cfg.AvailableSettings.DEFAULT_LIST_SEMANTICS;
|
||||||
import static org.hibernate.testing.transaction.TransactionUtil.doInHibernate;
|
import static org.hibernate.testing.transaction.TransactionUtil.doInHibernate;
|
||||||
import static org.junit.Assert.assertEquals;
|
import static org.junit.Assert.assertEquals;
|
||||||
import static org.junit.Assert.fail;
|
import static org.junit.Assert.fail;
|
||||||
|
@ -49,6 +51,7 @@ public class CollectionLoadedInTwoPhaseLoadTest extends BaseCoreFunctionalTestCa
|
||||||
|
|
||||||
public void configure(Configuration cfg) {
|
public void configure(Configuration cfg) {
|
||||||
cfg.setProperty( Environment.GENERATE_STATISTICS, "true" );
|
cfg.setProperty( Environment.GENERATE_STATISTICS, "true" );
|
||||||
|
cfg.setProperty( DEFAULT_LIST_SEMANTICS, CollectionClassification.BAG.name() );
|
||||||
}
|
}
|
||||||
|
|
||||||
@Test
|
@Test
|
||||||
|
|
|
@ -17,11 +17,14 @@ import java.util.TreeSet;
|
||||||
import org.hibernate.QueryException;
|
import org.hibernate.QueryException;
|
||||||
import org.hibernate.Session;
|
import org.hibernate.Session;
|
||||||
import org.hibernate.Transaction;
|
import org.hibernate.Transaction;
|
||||||
|
import org.hibernate.boot.registry.StandardServiceRegistryBuilder;
|
||||||
|
import org.hibernate.cfg.AvailableSettings;
|
||||||
import org.hibernate.dialect.H2Dialect;
|
import org.hibernate.dialect.H2Dialect;
|
||||||
import org.hibernate.dialect.MySQLDialect;
|
import org.hibernate.dialect.MySQLDialect;
|
||||||
import org.hibernate.exception.ConstraintViolationException;
|
import org.hibernate.exception.ConstraintViolationException;
|
||||||
import org.hibernate.id.BulkInsertionCapableIdentifierGenerator;
|
import org.hibernate.id.BulkInsertionCapableIdentifierGenerator;
|
||||||
import org.hibernate.id.IdentifierGenerator;
|
import org.hibernate.id.IdentifierGenerator;
|
||||||
|
import org.hibernate.metamodel.CollectionClassification;
|
||||||
import org.hibernate.persister.entity.EntityPersister;
|
import org.hibernate.persister.entity.EntityPersister;
|
||||||
import org.hibernate.query.Query;
|
import org.hibernate.query.Query;
|
||||||
|
|
||||||
|
@ -70,6 +73,13 @@ public class BulkManipulationTest extends BaseCoreFunctionalTestCase {
|
||||||
return new Class<?>[] { Farm.class, Crop.class };
|
return new Class<?>[] { Farm.class, Crop.class };
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
@Override
|
||||||
|
protected void prepareBasicRegistryBuilder(StandardServiceRegistryBuilder builer) {
|
||||||
|
super.prepareBasicRegistryBuilder( builer );
|
||||||
|
builer.applySetting( AvailableSettings.DEFAULT_LIST_SEMANTICS, CollectionClassification.BAG );
|
||||||
|
}
|
||||||
|
|
||||||
@Test
|
@Test
|
||||||
public void testUpdateWithSubquery() {
|
public void testUpdateWithSubquery() {
|
||||||
Session s = openSession();
|
Session s = openSession();
|
||||||
|
|
|
@ -23,19 +23,29 @@ import jakarta.persistence.OneToOne;
|
||||||
|
|
||||||
import org.hibernate.testing.TestForIssue;
|
import org.hibernate.testing.TestForIssue;
|
||||||
import org.hibernate.testing.orm.junit.DomainModel;
|
import org.hibernate.testing.orm.junit.DomainModel;
|
||||||
|
import org.hibernate.testing.orm.junit.ImplicitListAsBagProvider;
|
||||||
|
import org.hibernate.testing.orm.junit.ServiceRegistry;
|
||||||
import org.hibernate.testing.orm.junit.SessionFactory;
|
import org.hibernate.testing.orm.junit.SessionFactory;
|
||||||
import org.hibernate.testing.orm.junit.SessionFactoryScope;
|
import org.hibernate.testing.orm.junit.SessionFactoryScope;
|
||||||
|
import org.hibernate.testing.orm.junit.SettingProvider;
|
||||||
import org.junit.jupiter.api.BeforeEach;
|
import org.junit.jupiter.api.BeforeEach;
|
||||||
import org.junit.jupiter.api.Test;
|
import org.junit.jupiter.api.Test;
|
||||||
|
|
||||||
import static org.hamcrest.MatcherAssert.assertThat;
|
import static org.hamcrest.MatcherAssert.assertThat;
|
||||||
import static org.hamcrest.core.Is.is;
|
import static org.hamcrest.core.Is.is;
|
||||||
|
import static org.hibernate.cfg.AvailableSettings.DEFAULT_LIST_SEMANTICS;
|
||||||
import static org.junit.jupiter.api.Assertions.fail;
|
import static org.junit.jupiter.api.Assertions.fail;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @author Davide D'Alto
|
* @author Davide D'Alto
|
||||||
*/
|
*/
|
||||||
@TestForIssue(jiraKey = "HHH-12332")
|
@TestForIssue(jiraKey = "HHH-12332")
|
||||||
|
@ServiceRegistry(
|
||||||
|
settingProviders = @SettingProvider(
|
||||||
|
settingName = DEFAULT_LIST_SEMANTICS,
|
||||||
|
provider = ImplicitListAsBagProvider.class
|
||||||
|
)
|
||||||
|
)
|
||||||
@DomainModel(
|
@DomainModel(
|
||||||
annotatedClasses = {
|
annotatedClasses = {
|
||||||
TablePerClassInheritancePersistTest.Family.class,
|
TablePerClassInheritancePersistTest.Family.class,
|
||||||
|
|
|
@ -8,6 +8,7 @@ import org.hibernate.boot.registry.StandardServiceRegistryBuilder;
|
||||||
import org.hibernate.cfg.AvailableSettings;
|
import org.hibernate.cfg.AvailableSettings;
|
||||||
import org.hibernate.cfg.Environment;
|
import org.hibernate.cfg.Environment;
|
||||||
import org.hibernate.engine.jdbc.connections.spi.ConnectionProvider;
|
import org.hibernate.engine.jdbc.connections.spi.ConnectionProvider;
|
||||||
|
import org.hibernate.metamodel.CollectionClassification;
|
||||||
import org.hibernate.type.descriptor.java.StringJavaTypeDescriptor;
|
import org.hibernate.type.descriptor.java.StringJavaTypeDescriptor;
|
||||||
import org.hibernate.type.descriptor.jdbc.JdbcType;
|
import org.hibernate.type.descriptor.jdbc.JdbcType;
|
||||||
|
|
||||||
|
@ -55,6 +56,7 @@ abstract class BaseInsertOrderingTest extends BaseSessionFactoryFunctionalTest {
|
||||||
.get( AvailableSettings.CONNECTION_PROVIDER );
|
.get( AvailableSettings.CONNECTION_PROVIDER );
|
||||||
this.connectionProvider.setConnectionProvider( connectionProvider );
|
this.connectionProvider.setConnectionProvider( connectionProvider );
|
||||||
builer.applySetting( AvailableSettings.CONNECTION_PROVIDER, this.connectionProvider );
|
builer.applySetting( AvailableSettings.CONNECTION_PROVIDER, this.connectionProvider );
|
||||||
|
builer.applySetting( AvailableSettings.DEFAULT_LIST_SEMANTICS, CollectionClassification.BAG );
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
|
@ -29,21 +29,30 @@ import jakarta.persistence.Table;
|
||||||
|
|
||||||
import org.hibernate.testing.FailureExpected;
|
import org.hibernate.testing.FailureExpected;
|
||||||
import org.hibernate.testing.TestForIssue;
|
import org.hibernate.testing.TestForIssue;
|
||||||
|
import org.hibernate.testing.orm.junit.ImplicitListAsBagProvider;
|
||||||
import org.hibernate.testing.orm.junit.Jpa;
|
import org.hibernate.testing.orm.junit.Jpa;
|
||||||
import org.hibernate.testing.orm.junit.EntityManagerFactoryScope;
|
import org.hibernate.testing.orm.junit.EntityManagerFactoryScope;
|
||||||
|
import org.hibernate.testing.orm.junit.SettingProvider;
|
||||||
|
|
||||||
import org.junit.jupiter.api.Test;
|
import org.junit.jupiter.api.Test;
|
||||||
|
|
||||||
|
import static org.hibernate.cfg.AvailableSettings.DEFAULT_LIST_SEMANTICS;
|
||||||
import static org.junit.jupiter.api.Assertions.assertEquals;
|
import static org.junit.jupiter.api.Assertions.assertEquals;
|
||||||
import static org.junit.jupiter.api.Assertions.assertFalse;
|
import static org.junit.jupiter.api.Assertions.assertFalse;
|
||||||
import static org.junit.jupiter.api.Assertions.assertNotNull;
|
import static org.junit.jupiter.api.Assertions.assertNotNull;
|
||||||
|
|
||||||
@Jpa(annotatedClasses = {
|
@Jpa(
|
||||||
|
annotatedClasses = {
|
||||||
MultiLevelCascadeCollectionEmbeddableTest.MainEntity.class,
|
MultiLevelCascadeCollectionEmbeddableTest.MainEntity.class,
|
||||||
MultiLevelCascadeCollectionEmbeddableTest.SubEntity.class,
|
MultiLevelCascadeCollectionEmbeddableTest.SubEntity.class,
|
||||||
MultiLevelCascadeCollectionEmbeddableTest.AnotherSubSubEntity.class,
|
MultiLevelCascadeCollectionEmbeddableTest.AnotherSubSubEntity.class,
|
||||||
MultiLevelCascadeCollectionEmbeddableTest.SubSubEntity.class
|
MultiLevelCascadeCollectionEmbeddableTest.SubSubEntity.class
|
||||||
})
|
},
|
||||||
|
settingProviders = @SettingProvider(
|
||||||
|
settingName = DEFAULT_LIST_SEMANTICS,
|
||||||
|
provider = ImplicitListAsBagProvider.class
|
||||||
|
)
|
||||||
|
)
|
||||||
public class MultiLevelCascadeCollectionEmbeddableTest {
|
public class MultiLevelCascadeCollectionEmbeddableTest {
|
||||||
|
|
||||||
private boolean initialized = false;
|
private boolean initialized = false;
|
||||||
|
|
|
@ -28,23 +28,33 @@ import jakarta.persistence.Table;
|
||||||
|
|
||||||
import org.hibernate.testing.FailureExpected;
|
import org.hibernate.testing.FailureExpected;
|
||||||
import org.hibernate.testing.TestForIssue;
|
import org.hibernate.testing.TestForIssue;
|
||||||
|
import org.hibernate.testing.orm.junit.ImplicitListAsBagProvider;
|
||||||
import org.hibernate.testing.orm.junit.Jpa;
|
import org.hibernate.testing.orm.junit.Jpa;
|
||||||
import org.hibernate.testing.orm.junit.EntityManagerFactoryScope;
|
import org.hibernate.testing.orm.junit.EntityManagerFactoryScope;
|
||||||
|
import org.hibernate.testing.orm.junit.Setting;
|
||||||
|
import org.hibernate.testing.orm.junit.SettingProvider;
|
||||||
|
|
||||||
import org.jboss.logging.Logger;
|
import org.jboss.logging.Logger;
|
||||||
|
|
||||||
import org.junit.jupiter.api.Test;
|
import org.junit.jupiter.api.Test;
|
||||||
|
|
||||||
|
import static org.hibernate.cfg.AvailableSettings.DEFAULT_LIST_SEMANTICS;
|
||||||
import static org.junit.jupiter.api.Assertions.assertEquals;
|
import static org.junit.jupiter.api.Assertions.assertEquals;
|
||||||
import static org.junit.jupiter.api.Assertions.assertFalse;
|
import static org.junit.jupiter.api.Assertions.assertFalse;
|
||||||
import static org.junit.jupiter.api.Assertions.assertNotNull;
|
import static org.junit.jupiter.api.Assertions.assertNotNull;
|
||||||
|
|
||||||
@Jpa(annotatedClasses = {
|
@Jpa(
|
||||||
|
annotatedClasses = {
|
||||||
MultiLevelCascadeCollectionIdClassTest.MainEntity.class,
|
MultiLevelCascadeCollectionIdClassTest.MainEntity.class,
|
||||||
MultiLevelCascadeCollectionIdClassTest.SubEntity.class,
|
MultiLevelCascadeCollectionIdClassTest.SubEntity.class,
|
||||||
MultiLevelCascadeCollectionIdClassTest.AnotherSubSubEntity.class,
|
MultiLevelCascadeCollectionIdClassTest.AnotherSubSubEntity.class,
|
||||||
MultiLevelCascadeCollectionIdClassTest.SubSubEntity.class
|
MultiLevelCascadeCollectionIdClassTest.SubSubEntity.class
|
||||||
})
|
},
|
||||||
|
settingProviders = @SettingProvider(
|
||||||
|
settingName = DEFAULT_LIST_SEMANTICS,
|
||||||
|
provider = ImplicitListAsBagProvider.class
|
||||||
|
)
|
||||||
|
)
|
||||||
public class MultiLevelCascadeCollectionIdClassTest {
|
public class MultiLevelCascadeCollectionIdClassTest {
|
||||||
|
|
||||||
private static final Logger log = Logger.getLogger( MultiLevelCascadeCollectionIdClassTest.class );
|
private static final Logger log = Logger.getLogger( MultiLevelCascadeCollectionIdClassTest.class );
|
||||||
|
|
|
@ -9,6 +9,7 @@ package org.hibernate.orm.test.jpa.graphs.queryhint;
|
||||||
import java.util.HashSet;
|
import java.util.HashSet;
|
||||||
import java.util.Iterator;
|
import java.util.Iterator;
|
||||||
import java.util.List;
|
import java.util.List;
|
||||||
|
import java.util.Map;
|
||||||
import java.util.Set;
|
import java.util.Set;
|
||||||
import jakarta.persistence.EntityGraph;
|
import jakarta.persistence.EntityGraph;
|
||||||
import jakarta.persistence.EntityManager;
|
import jakarta.persistence.EntityManager;
|
||||||
|
@ -18,6 +19,7 @@ import jakarta.persistence.Subgraph;
|
||||||
import org.hibernate.Hibernate;
|
import org.hibernate.Hibernate;
|
||||||
import org.hibernate.Session;
|
import org.hibernate.Session;
|
||||||
import org.hibernate.jpa.QueryHints;
|
import org.hibernate.jpa.QueryHints;
|
||||||
|
import org.hibernate.metamodel.CollectionClassification;
|
||||||
import org.hibernate.orm.test.jpa.BaseEntityManagerFunctionalTestCase;
|
import org.hibernate.orm.test.jpa.BaseEntityManagerFunctionalTestCase;
|
||||||
import org.hibernate.orm.test.jpa.graphs.Company;
|
import org.hibernate.orm.test.jpa.graphs.Company;
|
||||||
import org.hibernate.orm.test.jpa.graphs.CompanyFetchProfile;
|
import org.hibernate.orm.test.jpa.graphs.CompanyFetchProfile;
|
||||||
|
@ -32,6 +34,7 @@ import org.hibernate.testing.TestForIssue;
|
||||||
import org.junit.Before;
|
import org.junit.Before;
|
||||||
import org.junit.Test;
|
import org.junit.Test;
|
||||||
|
|
||||||
|
import static org.hibernate.cfg.AvailableSettings.DEFAULT_LIST_SEMANTICS;
|
||||||
import static org.hibernate.testing.transaction.TransactionUtil.doInJPA;
|
import static org.hibernate.testing.transaction.TransactionUtil.doInJPA;
|
||||||
import static org.junit.Assert.assertEquals;
|
import static org.junit.Assert.assertEquals;
|
||||||
import static org.junit.Assert.assertFalse;
|
import static org.junit.Assert.assertFalse;
|
||||||
|
@ -534,4 +537,10 @@ public class QueryHintEntityGraphTest extends BaseEntityManagerFunctionalTestCas
|
||||||
protected Class<?>[] getAnnotatedClasses() {
|
protected Class<?>[] getAnnotatedClasses() {
|
||||||
return new Class<?>[] { Company.class, CompanyFetchProfile.class, Employee.class, Manager.class, Location.class, Course.class, Student.class };
|
return new Class<?>[] { Company.class, CompanyFetchProfile.class, Employee.class, Manager.class, Location.class, Course.class, Student.class };
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
protected void addConfigOptions(Map options) {
|
||||||
|
super.addConfigOptions( options );
|
||||||
|
options.put( DEFAULT_LIST_SEMANTICS, CollectionClassification.BAG );
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -20,11 +20,15 @@ import org.hibernate.annotations.NaturalId;
|
||||||
import org.hibernate.dialect.TiDBDialect;
|
import org.hibernate.dialect.TiDBDialect;
|
||||||
import org.hibernate.testing.orm.junit.EntityManagerFactoryScope;
|
import org.hibernate.testing.orm.junit.EntityManagerFactoryScope;
|
||||||
import org.hibernate.testing.orm.junit.FailureExpected;
|
import org.hibernate.testing.orm.junit.FailureExpected;
|
||||||
|
import org.hibernate.testing.orm.junit.ImplicitListAsBagProvider;
|
||||||
import org.hibernate.testing.orm.junit.Jpa;
|
import org.hibernate.testing.orm.junit.Jpa;
|
||||||
|
import org.hibernate.testing.orm.junit.SettingProvider;
|
||||||
import org.hibernate.testing.orm.junit.SkipForDialect;
|
import org.hibernate.testing.orm.junit.SkipForDialect;
|
||||||
import org.junit.jupiter.api.AfterEach;
|
import org.junit.jupiter.api.AfterEach;
|
||||||
import org.junit.jupiter.api.Test;
|
import org.junit.jupiter.api.Test;
|
||||||
|
|
||||||
|
import static org.hibernate.cfg.AvailableSettings.DEFAULT_LIST_SEMANTICS;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @author Vlad Mihalcea
|
* @author Vlad Mihalcea
|
||||||
*/
|
*/
|
||||||
|
@ -32,7 +36,11 @@ import org.junit.jupiter.api.Test;
|
||||||
annotatedClasses = {
|
annotatedClasses = {
|
||||||
ManyToManyBidirectionalTest.Person.class,
|
ManyToManyBidirectionalTest.Person.class,
|
||||||
ManyToManyBidirectionalTest.Address.class,
|
ManyToManyBidirectionalTest.Address.class,
|
||||||
}
|
},
|
||||||
|
settingProviders = @SettingProvider(
|
||||||
|
settingName = DEFAULT_LIST_SEMANTICS,
|
||||||
|
provider = ImplicitListAsBagProvider.class
|
||||||
|
)
|
||||||
)
|
)
|
||||||
public class ManyToManyBidirectionalTest {
|
public class ManyToManyBidirectionalTest {
|
||||||
|
|
||||||
|
|
|
@ -10,12 +10,16 @@ import java.util.Collection;
|
||||||
import java.util.List;
|
import java.util.List;
|
||||||
|
|
||||||
import org.hibernate.annotations.CollectionClassificationType;
|
import org.hibernate.annotations.CollectionClassificationType;
|
||||||
|
import org.hibernate.cfg.AvailableSettings;
|
||||||
import org.hibernate.mapping.Bag;
|
import org.hibernate.mapping.Bag;
|
||||||
import org.hibernate.mapping.Property;
|
import org.hibernate.mapping.Property;
|
||||||
import org.hibernate.metamodel.CollectionClassification;
|
import org.hibernate.metamodel.CollectionClassification;
|
||||||
|
|
||||||
import org.hibernate.testing.orm.junit.DomainModel;
|
import org.hibernate.testing.orm.junit.DomainModel;
|
||||||
import org.hibernate.testing.orm.junit.DomainModelScope;
|
import org.hibernate.testing.orm.junit.DomainModelScope;
|
||||||
|
import org.hibernate.testing.orm.junit.ImplicitListAsBagProvider;
|
||||||
|
import org.hibernate.testing.orm.junit.ServiceRegistry;
|
||||||
|
import org.hibernate.testing.orm.junit.SettingProvider;
|
||||||
import org.junit.jupiter.api.Test;
|
import org.junit.jupiter.api.Test;
|
||||||
|
|
||||||
import jakarta.persistence.Basic;
|
import jakarta.persistence.Basic;
|
||||||
|
@ -25,17 +29,31 @@ import jakarta.persistence.Id;
|
||||||
import jakarta.persistence.Table;
|
import jakarta.persistence.Table;
|
||||||
|
|
||||||
import static org.assertj.core.api.Assertions.assertThat;
|
import static org.assertj.core.api.Assertions.assertThat;
|
||||||
|
import static org.hibernate.cfg.AvailableSettings.DEFAULT_LIST_SEMANTICS;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
* Explicitly sets {@link AvailableSettings#DEFAULT_LIST_SEMANTICS} to BAG
|
||||||
|
* and verifies the outcome.
|
||||||
|
*
|
||||||
|
* Basically verifies that the legacy behavior can be achieved via the setting
|
||||||
|
* for users migrating who wish to retain that legacy behavior
|
||||||
|
*
|
||||||
* @author Steve Ebersole
|
* @author Steve Ebersole
|
||||||
*/
|
*/
|
||||||
|
@ServiceRegistry(
|
||||||
|
settingProviders = @SettingProvider(
|
||||||
|
settingName = DEFAULT_LIST_SEMANTICS,
|
||||||
|
provider = ImplicitListAsBagProvider.class
|
||||||
|
)
|
||||||
|
)
|
||||||
@DomainModel( annotatedClasses = ImplicitListAsBagSemanticsTests.AnEntity.class )
|
@DomainModel( annotatedClasses = ImplicitListAsBagSemanticsTests.AnEntity.class )
|
||||||
public class ImplicitListAsBagSemanticsTests {
|
public class ImplicitListAsBagSemanticsTests {
|
||||||
@Test
|
@Test
|
||||||
void verifyModel(DomainModelScope scope) {
|
void verifyModel(DomainModelScope scope) {
|
||||||
scope.withHierarchy( AnEntity.class, (descriptor) -> {
|
scope.withHierarchy( AnEntity.class, (descriptor) -> {
|
||||||
final Property implicitList = descriptor.getProperty( "implicitList" );
|
final Property implicitList = descriptor.getProperty( "implicitList" );
|
||||||
// because of missing `AvailableSettings.DEFAULT_LIST_SEMANTICS`, this should be BAG (legacy)
|
// this is the purpose of the new AvailableSettings#DEFAULT_LIST_SEMANTICS
|
||||||
|
// setting to allow legacy behavior.
|
||||||
assertThat( implicitList.getValue() ).isInstanceOf( Bag.class );
|
assertThat( implicitList.getValue() ).isInstanceOf( Bag.class );
|
||||||
|
|
||||||
final Property implicitBag = descriptor.getProperty( "implicitBag" );
|
final Property implicitBag = descriptor.getProperty( "implicitBag" );
|
||||||
|
@ -92,4 +110,5 @@ public class ImplicitListAsBagSemanticsTests {
|
||||||
this.name = name;
|
this.name = name;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
|
@ -0,0 +1,100 @@
|
||||||
|
/*
|
||||||
|
* Hibernate, Relational Persistence for Idiomatic Java
|
||||||
|
*
|
||||||
|
* License: GNU Lesser General Public License (LGPL), version 2.1 or later
|
||||||
|
* See the lgpl.txt file in the root directory or http://www.gnu.org/licenses/lgpl-2.1.html
|
||||||
|
*/
|
||||||
|
package org.hibernate.orm.test.mapping.collections;
|
||||||
|
|
||||||
|
import java.util.Collection;
|
||||||
|
import java.util.List;
|
||||||
|
|
||||||
|
import org.hibernate.annotations.CollectionClassificationType;
|
||||||
|
import org.hibernate.cfg.AvailableSettings;
|
||||||
|
import org.hibernate.mapping.Bag;
|
||||||
|
import org.hibernate.mapping.Property;
|
||||||
|
import org.hibernate.metamodel.CollectionClassification;
|
||||||
|
|
||||||
|
import org.hibernate.testing.orm.junit.DomainModel;
|
||||||
|
import org.hibernate.testing.orm.junit.DomainModelScope;
|
||||||
|
import org.junit.jupiter.api.Test;
|
||||||
|
|
||||||
|
import jakarta.persistence.Basic;
|
||||||
|
import jakarta.persistence.ElementCollection;
|
||||||
|
import jakarta.persistence.Entity;
|
||||||
|
import jakarta.persistence.Id;
|
||||||
|
import jakarta.persistence.Table;
|
||||||
|
|
||||||
|
import static org.assertj.core.api.Assertions.assertThat;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Uses the default {@link AvailableSettings#DEFAULT_LIST_SEMANTICS} value of LIST
|
||||||
|
* and verifies the outcome
|
||||||
|
*
|
||||||
|
* @author Steve Ebersole
|
||||||
|
*/
|
||||||
|
@DomainModel( annotatedClasses = ImplicitListDefaultSemanticsTests.AnEntity.class )
|
||||||
|
public class ImplicitListDefaultSemanticsTests {
|
||||||
|
@Test
|
||||||
|
void verifyModel(DomainModelScope scope) {
|
||||||
|
scope.withHierarchy( AnEntity.class, (descriptor) -> {
|
||||||
|
final Property implicitList = descriptor.getProperty( "implicitList" );
|
||||||
|
// this is the change related to AvailableSettings#DEFAULT_LIST_SEMANTICS
|
||||||
|
// previous versions interpreted these as BAG
|
||||||
|
assertThat( implicitList.getValue() ).isInstanceOf( org.hibernate.mapping.List.class );
|
||||||
|
|
||||||
|
final Property implicitBag = descriptor.getProperty( "implicitBag" );
|
||||||
|
assertThat( implicitBag.getValue() ).isInstanceOf( Bag.class );
|
||||||
|
|
||||||
|
final Property explicitBag = descriptor.getProperty( "explicitBag" );
|
||||||
|
assertThat( explicitBag.getValue() ).isInstanceOf( Bag.class );
|
||||||
|
|
||||||
|
final Property explicitList = descriptor.getProperty( "explicitList" );
|
||||||
|
assertThat( explicitList.getValue() ).isInstanceOf( org.hibernate.mapping.List.class );
|
||||||
|
} );
|
||||||
|
}
|
||||||
|
|
||||||
|
@Entity( name = "AnEntity" )
|
||||||
|
@Table( name = "t_entity" )
|
||||||
|
public static class AnEntity {
|
||||||
|
@Id
|
||||||
|
private Integer id;
|
||||||
|
@Basic
|
||||||
|
private String name;
|
||||||
|
|
||||||
|
@ElementCollection
|
||||||
|
private List<String> implicitList;
|
||||||
|
|
||||||
|
@ElementCollection
|
||||||
|
private Collection<String> implicitBag;
|
||||||
|
|
||||||
|
@ElementCollection
|
||||||
|
@CollectionClassificationType( CollectionClassification.BAG )
|
||||||
|
private List<String> explicitBag;
|
||||||
|
|
||||||
|
@ElementCollection
|
||||||
|
@CollectionClassificationType( CollectionClassification.LIST )
|
||||||
|
private List<String> explicitList;
|
||||||
|
|
||||||
|
private AnEntity() {
|
||||||
|
// for use by Hibernate
|
||||||
|
}
|
||||||
|
|
||||||
|
public AnEntity(Integer id, String name) {
|
||||||
|
this.id = id;
|
||||||
|
this.name = name;
|
||||||
|
}
|
||||||
|
|
||||||
|
public Integer getId() {
|
||||||
|
return id;
|
||||||
|
}
|
||||||
|
|
||||||
|
public String getName() {
|
||||||
|
return name;
|
||||||
|
}
|
||||||
|
|
||||||
|
public void setName(String name) {
|
||||||
|
this.name = name;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
|
@ -589,7 +589,6 @@ public class OneToManyBidirectionalTest {
|
||||||
}
|
}
|
||||||
|
|
||||||
@Test
|
@Test
|
||||||
@FailureExpected(jiraKey = "no jira", reason = "order.getLineItems().size() is 4 and not 2 as it should be")
|
|
||||||
public void testItemFetchJoin(SessionFactoryScope scope) {
|
public void testItemFetchJoin(SessionFactoryScope scope) {
|
||||||
SQLStatementInspector sqlStatementInterceptor = (SQLStatementInspector) scope.getStatementInspector();
|
SQLStatementInspector sqlStatementInterceptor = (SQLStatementInspector) scope.getStatementInspector();
|
||||||
scope.inTransaction( session -> {
|
scope.inTransaction( session -> {
|
||||||
|
|
|
@ -17,23 +17,32 @@ import jakarta.persistence.OneToMany;
|
||||||
import jakarta.persistence.Table;
|
import jakarta.persistence.Table;
|
||||||
|
|
||||||
import org.hibernate.collection.spi.PersistentBag;
|
import org.hibernate.collection.spi.PersistentBag;
|
||||||
|
import org.hibernate.testing.orm.junit.ImplicitListAsBagProvider;
|
||||||
import org.hibernate.stat.spi.StatisticsImplementor;
|
import org.hibernate.stat.spi.StatisticsImplementor;
|
||||||
|
|
||||||
import org.hibernate.testing.orm.junit.DomainModel;
|
import org.hibernate.testing.orm.junit.DomainModel;
|
||||||
|
import org.hibernate.testing.orm.junit.ServiceRegistry;
|
||||||
import org.hibernate.testing.orm.junit.SessionFactory;
|
import org.hibernate.testing.orm.junit.SessionFactory;
|
||||||
import org.hibernate.testing.orm.junit.SessionFactoryScope;
|
import org.hibernate.testing.orm.junit.SessionFactoryScope;
|
||||||
|
import org.hibernate.testing.orm.junit.SettingProvider;
|
||||||
import org.junit.jupiter.api.Test;
|
import org.junit.jupiter.api.Test;
|
||||||
|
|
||||||
import static org.hamcrest.CoreMatchers.is;
|
import static org.hamcrest.CoreMatchers.is;
|
||||||
import static org.hamcrest.CoreMatchers.sameInstance;
|
import static org.hamcrest.CoreMatchers.sameInstance;
|
||||||
import static org.hamcrest.MatcherAssert.assertThat;
|
import static org.hamcrest.MatcherAssert.assertThat;
|
||||||
import static org.hamcrest.core.IsInstanceOf.instanceOf;
|
import static org.hamcrest.core.IsInstanceOf.instanceOf;
|
||||||
|
import static org.hibernate.cfg.AvailableSettings.DEFAULT_LIST_SEMANTICS;
|
||||||
import static org.junit.jupiter.api.Assertions.assertFalse;
|
import static org.junit.jupiter.api.Assertions.assertFalse;
|
||||||
import static org.junit.jupiter.api.Assertions.assertTrue;
|
import static org.junit.jupiter.api.Assertions.assertTrue;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @author Andrea Boriero
|
* @author Andrea Boriero
|
||||||
*/
|
*/
|
||||||
|
@ServiceRegistry(
|
||||||
|
settingProviders = @SettingProvider(
|
||||||
|
settingName = DEFAULT_LIST_SEMANTICS,
|
||||||
|
provider = ImplicitListAsBagProvider.class )
|
||||||
|
)
|
||||||
@DomainModel(
|
@DomainModel(
|
||||||
annotatedClasses = {
|
annotatedClasses = {
|
||||||
OneToManyEmptyCollectionTest.Order.class,
|
OneToManyEmptyCollectionTest.Order.class,
|
||||||
|
|
|
@ -14,6 +14,8 @@ import org.hibernate.boot.MetadataSources;
|
||||||
import org.hibernate.boot.model.naming.ImplicitNamingStrategyComponentPathImpl;
|
import org.hibernate.boot.model.naming.ImplicitNamingStrategyComponentPathImpl;
|
||||||
import org.hibernate.boot.registry.StandardServiceRegistry;
|
import org.hibernate.boot.registry.StandardServiceRegistry;
|
||||||
import org.hibernate.boot.registry.StandardServiceRegistryBuilder;
|
import org.hibernate.boot.registry.StandardServiceRegistryBuilder;
|
||||||
|
import org.hibernate.cfg.AvailableSettings;
|
||||||
|
import org.hibernate.metamodel.CollectionClassification;
|
||||||
|
|
||||||
import org.hibernate.testing.TestForIssue;
|
import org.hibernate.testing.TestForIssue;
|
||||||
import org.hibernate.testing.orm.junit.BaseUnitTest;
|
import org.hibernate.testing.orm.junit.BaseUnitTest;
|
||||||
|
@ -42,7 +44,9 @@ public class ComponentNamingStrategyForJoinColumnTest {
|
||||||
|
|
||||||
@Test
|
@Test
|
||||||
public void testNamingComponentPath() {
|
public void testNamingComponentPath() {
|
||||||
final StandardServiceRegistry ssr = new StandardServiceRegistryBuilder().build();
|
final StandardServiceRegistry ssr = new StandardServiceRegistryBuilder()
|
||||||
|
.applySetting( AvailableSettings.DEFAULT_LIST_SEMANTICS, CollectionClassification.BAG )
|
||||||
|
.build();
|
||||||
|
|
||||||
try {
|
try {
|
||||||
final MetadataSources ms = new MetadataSources( ssr )
|
final MetadataSources ms = new MetadataSources( ssr )
|
||||||
|
|
|
@ -12,11 +12,13 @@ import org.hibernate.boot.model.naming.ImplicitNamingStrategyComponentPathImpl;
|
||||||
import org.hibernate.boot.model.naming.ImplicitNamingStrategyJpaCompliantImpl;
|
import org.hibernate.boot.model.naming.ImplicitNamingStrategyJpaCompliantImpl;
|
||||||
import org.hibernate.boot.registry.StandardServiceRegistry;
|
import org.hibernate.boot.registry.StandardServiceRegistry;
|
||||||
import org.hibernate.boot.registry.StandardServiceRegistryBuilder;
|
import org.hibernate.boot.registry.StandardServiceRegistryBuilder;
|
||||||
|
import org.hibernate.cfg.AvailableSettings;
|
||||||
import org.hibernate.mapping.Bag;
|
import org.hibernate.mapping.Bag;
|
||||||
import org.hibernate.mapping.Column;
|
import org.hibernate.mapping.Column;
|
||||||
import org.hibernate.mapping.PersistentClass;
|
import org.hibernate.mapping.PersistentClass;
|
||||||
import org.hibernate.mapping.Property;
|
import org.hibernate.mapping.Property;
|
||||||
import org.hibernate.mapping.SimpleValue;
|
import org.hibernate.mapping.SimpleValue;
|
||||||
|
import org.hibernate.metamodel.CollectionClassification;
|
||||||
|
|
||||||
import org.hibernate.testing.TestForIssue;
|
import org.hibernate.testing.TestForIssue;
|
||||||
import org.hibernate.testing.orm.junit.BaseUnitTest;
|
import org.hibernate.testing.orm.junit.BaseUnitTest;
|
||||||
|
@ -34,7 +36,9 @@ public class ComponentNamingStrategyTest {
|
||||||
|
|
||||||
@Test
|
@Test
|
||||||
public void testDefaultNamingStrategy() {
|
public void testDefaultNamingStrategy() {
|
||||||
final StandardServiceRegistry ssr = new StandardServiceRegistryBuilder().build();
|
final StandardServiceRegistry ssr = new StandardServiceRegistryBuilder()
|
||||||
|
.applySetting( AvailableSettings.DEFAULT_LIST_SEMANTICS, CollectionClassification.BAG )
|
||||||
|
.build();
|
||||||
|
|
||||||
try {
|
try {
|
||||||
final MetadataSources ms = new MetadataSources( ssr );
|
final MetadataSources ms = new MetadataSources( ssr );
|
||||||
|
@ -60,7 +64,9 @@ public class ComponentNamingStrategyTest {
|
||||||
@Test
|
@Test
|
||||||
@TestForIssue( jiraKey = "HHH-6005" )
|
@TestForIssue( jiraKey = "HHH-6005" )
|
||||||
public void testComponentSafeNamingStrategy() {
|
public void testComponentSafeNamingStrategy() {
|
||||||
final StandardServiceRegistry ssr = new StandardServiceRegistryBuilder().build();
|
final StandardServiceRegistry ssr = new StandardServiceRegistryBuilder()
|
||||||
|
.applySetting( AvailableSettings.DEFAULT_LIST_SEMANTICS, CollectionClassification.BAG )
|
||||||
|
.build();
|
||||||
|
|
||||||
try {
|
try {
|
||||||
final MetadataSources ms = new MetadataSources( ssr );
|
final MetadataSources ms = new MetadataSources( ssr );
|
||||||
|
|
|
@ -30,15 +30,18 @@ import org.hibernate.engine.spi.SessionFactoryImplementor;
|
||||||
import org.hibernate.persister.collection.CollectionPersister;
|
import org.hibernate.persister.collection.CollectionPersister;
|
||||||
|
|
||||||
import org.hibernate.testing.orm.junit.DomainModel;
|
import org.hibernate.testing.orm.junit.DomainModel;
|
||||||
|
import org.hibernate.testing.orm.junit.ImplicitListAsBagProvider;
|
||||||
import org.hibernate.testing.orm.junit.ServiceRegistry;
|
import org.hibernate.testing.orm.junit.ServiceRegistry;
|
||||||
import org.hibernate.testing.orm.junit.SessionFactory;
|
import org.hibernate.testing.orm.junit.SessionFactory;
|
||||||
import org.hibernate.testing.orm.junit.SessionFactoryScope;
|
import org.hibernate.testing.orm.junit.SessionFactoryScope;
|
||||||
import org.hibernate.testing.orm.junit.Setting;
|
import org.hibernate.testing.orm.junit.Setting;
|
||||||
|
import org.hibernate.testing.orm.junit.SettingProvider;
|
||||||
import org.junit.jupiter.api.AfterEach;
|
import org.junit.jupiter.api.AfterEach;
|
||||||
import org.junit.jupiter.api.Test;
|
import org.junit.jupiter.api.Test;
|
||||||
|
|
||||||
import static org.hamcrest.CoreMatchers.is;
|
import static org.hamcrest.CoreMatchers.is;
|
||||||
import static org.hamcrest.MatcherAssert.assertThat;
|
import static org.hamcrest.MatcherAssert.assertThat;
|
||||||
|
import static org.hibernate.cfg.AvailableSettings.DEFAULT_LIST_SEMANTICS;
|
||||||
import static org.junit.jupiter.api.Assertions.assertFalse;
|
import static org.junit.jupiter.api.Assertions.assertFalse;
|
||||||
import static org.junit.jupiter.api.Assertions.assertTrue;
|
import static org.junit.jupiter.api.Assertions.assertTrue;
|
||||||
|
|
||||||
|
@ -46,6 +49,18 @@ import static org.junit.jupiter.api.Assertions.assertTrue;
|
||||||
/**
|
/**
|
||||||
* @author Janario Oliveira
|
* @author Janario Oliveira
|
||||||
*/
|
*/
|
||||||
|
@ServiceRegistry(
|
||||||
|
settings = {
|
||||||
|
@Setting(name = AvailableSettings.ENABLE_LAZY_LOAD_NO_TRANS, value = "true"),
|
||||||
|
@Setting(name = Environment.USE_SECOND_LEVEL_CACHE, value = "true"),
|
||||||
|
@Setting(name = Environment.USE_QUERY_CACHE, value = "true"),
|
||||||
|
@Setting(name = Environment.CACHE_PROVIDER_CONFIG, value = "true"),
|
||||||
|
},
|
||||||
|
settingProviders = @SettingProvider(
|
||||||
|
settingName = DEFAULT_LIST_SEMANTICS,
|
||||||
|
provider = ImplicitListAsBagProvider.class
|
||||||
|
)
|
||||||
|
)
|
||||||
@DomainModel(
|
@DomainModel(
|
||||||
annotatedClasses = {
|
annotatedClasses = {
|
||||||
CacheLazyLoadNoTransTest.Application.class,
|
CacheLazyLoadNoTransTest.Application.class,
|
||||||
|
@ -54,14 +69,6 @@ import static org.junit.jupiter.api.Assertions.assertTrue;
|
||||||
}
|
}
|
||||||
)
|
)
|
||||||
@SessionFactory
|
@SessionFactory
|
||||||
@ServiceRegistry(
|
|
||||||
settings = {
|
|
||||||
@Setting(name = AvailableSettings.ENABLE_LAZY_LOAD_NO_TRANS, value = "true"),
|
|
||||||
@Setting(name = Environment.USE_SECOND_LEVEL_CACHE, value = "true"),
|
|
||||||
@Setting(name = Environment.USE_QUERY_CACHE, value = "true"),
|
|
||||||
@Setting(name = Environment.CACHE_PROVIDER_CONFIG, value = "true"),
|
|
||||||
}
|
|
||||||
)
|
|
||||||
public class CacheLazyLoadNoTransTest {
|
public class CacheLazyLoadNoTransTest {
|
||||||
|
|
||||||
@AfterEach
|
@AfterEach
|
||||||
|
|
|
@ -9,10 +9,13 @@ package org.hibernate.orm.test.unidir;
|
||||||
import org.hibernate.Hibernate;
|
import org.hibernate.Hibernate;
|
||||||
import org.hibernate.Session;
|
import org.hibernate.Session;
|
||||||
import org.hibernate.Transaction;
|
import org.hibernate.Transaction;
|
||||||
|
import org.hibernate.cfg.Configuration;
|
||||||
|
import org.hibernate.metamodel.CollectionClassification;
|
||||||
|
|
||||||
import org.hibernate.testing.junit4.BaseCoreFunctionalTestCase;
|
import org.hibernate.testing.junit4.BaseCoreFunctionalTestCase;
|
||||||
import org.junit.Test;
|
import org.junit.Test;
|
||||||
|
|
||||||
|
import static org.hibernate.cfg.AvailableSettings.DEFAULT_LIST_SEMANTICS;
|
||||||
import static org.junit.Assert.assertEquals;
|
import static org.junit.Assert.assertEquals;
|
||||||
import static org.junit.Assert.assertFalse;
|
import static org.junit.Assert.assertFalse;
|
||||||
|
|
||||||
|
@ -38,6 +41,12 @@ public class BackrefTest extends BaseCoreFunctionalTestCase {
|
||||||
return new Class<?>[] { Parent1.class, Child1.class, Child2.class };
|
return new Class<?>[] { Parent1.class, Child1.class, Child2.class };
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
protected void configure(Configuration configuration) {
|
||||||
|
super.configure( configuration );
|
||||||
|
configuration.setProperty( DEFAULT_LIST_SEMANTICS, CollectionClassification.BAG.name() );
|
||||||
|
}
|
||||||
|
|
||||||
@Test
|
@Test
|
||||||
public void testBackRef() {
|
public void testBackRef() {
|
||||||
Session s = openSession();
|
Session s = openSession();
|
||||||
|
|
|
@ -24,6 +24,8 @@ import org.hibernate.Hibernate;
|
||||||
import org.hibernate.annotations.Immutable;
|
import org.hibernate.annotations.Immutable;
|
||||||
import org.hibernate.annotations.Where;
|
import org.hibernate.annotations.Where;
|
||||||
import org.hibernate.annotations.WhereJoinTable;
|
import org.hibernate.annotations.WhereJoinTable;
|
||||||
|
import org.hibernate.cfg.Configuration;
|
||||||
|
import org.hibernate.metamodel.CollectionClassification;
|
||||||
|
|
||||||
import org.hibernate.testing.TestForIssue;
|
import org.hibernate.testing.TestForIssue;
|
||||||
import org.hibernate.testing.junit4.BaseCoreFunctionalTestCase;
|
import org.hibernate.testing.junit4.BaseCoreFunctionalTestCase;
|
||||||
|
@ -31,6 +33,7 @@ import org.junit.After;
|
||||||
import org.junit.Before;
|
import org.junit.Before;
|
||||||
import org.junit.Test;
|
import org.junit.Test;
|
||||||
|
|
||||||
|
import static org.hibernate.cfg.AvailableSettings.DEFAULT_LIST_SEMANTICS;
|
||||||
import static org.hibernate.testing.transaction.TransactionUtil.doInHibernate;
|
import static org.hibernate.testing.transaction.TransactionUtil.doInHibernate;
|
||||||
import static org.junit.Assert.assertEquals;
|
import static org.junit.Assert.assertEquals;
|
||||||
import static org.junit.Assert.assertFalse;
|
import static org.junit.Assert.assertFalse;
|
||||||
|
@ -48,6 +51,12 @@ public class LazyManyToManyNonUniqueIdWhereTest extends BaseCoreFunctionalTestCa
|
||||||
return new Class[] { Material.class, Building.class, Rating.class, Size.class };
|
return new Class[] { Material.class, Building.class, Rating.class, Size.class };
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
protected void configure(Configuration configuration) {
|
||||||
|
super.configure( configuration );
|
||||||
|
configuration.setProperty( DEFAULT_LIST_SEMANTICS, CollectionClassification.BAG.name() );
|
||||||
|
}
|
||||||
|
|
||||||
@Before
|
@Before
|
||||||
public void setup() {
|
public void setup() {
|
||||||
doInHibernate(
|
doInHibernate(
|
||||||
|
|
|
@ -21,6 +21,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.Where;
|
||||||
|
import org.hibernate.cfg.Configuration;
|
||||||
|
import org.hibernate.metamodel.CollectionClassification;
|
||||||
|
|
||||||
import org.hibernate.testing.TestForIssue;
|
import org.hibernate.testing.TestForIssue;
|
||||||
import org.hibernate.testing.junit4.BaseCoreFunctionalTestCase;
|
import org.hibernate.testing.junit4.BaseCoreFunctionalTestCase;
|
||||||
|
@ -28,6 +30,7 @@ import org.junit.After;
|
||||||
import org.junit.Before;
|
import org.junit.Before;
|
||||||
import org.junit.Test;
|
import org.junit.Test;
|
||||||
|
|
||||||
|
import static org.hibernate.cfg.AvailableSettings.DEFAULT_LIST_SEMANTICS;
|
||||||
import static org.hibernate.testing.transaction.TransactionUtil.doInHibernate;
|
import static org.hibernate.testing.transaction.TransactionUtil.doInHibernate;
|
||||||
import static org.junit.Assert.assertEquals;
|
import static org.junit.Assert.assertEquals;
|
||||||
import static org.junit.Assert.assertFalse;
|
import static org.junit.Assert.assertFalse;
|
||||||
|
@ -45,6 +48,12 @@ public class LazyOneToManyNonUniqueIdWhereTest extends BaseCoreFunctionalTestCas
|
||||||
return new Class[] { Material.class, Building.class, Rating.class, Size.class };
|
return new Class[] { Material.class, Building.class, Rating.class, Size.class };
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
protected void configure(Configuration configuration) {
|
||||||
|
super.configure( configuration );
|
||||||
|
configuration.setProperty( DEFAULT_LIST_SEMANTICS, CollectionClassification.BAG.name() );
|
||||||
|
}
|
||||||
|
|
||||||
@Before
|
@Before
|
||||||
public void setup() {
|
public void setup() {
|
||||||
doInHibernate(
|
doInHibernate(
|
||||||
|
|
|
@ -21,3 +21,6 @@ hibernate.cache.region_prefix hibernate.test
|
||||||
hibernate.cache.region.factory_class org.hibernate.testing.cache.CachingRegionFactory
|
hibernate.cache.region.factory_class org.hibernate.testing.cache.CachingRegionFactory
|
||||||
|
|
||||||
hibernate.service.allow_crawling=false
|
hibernate.service.allow_crawling=false
|
||||||
|
|
||||||
|
## backwards compatibility wrt bag v. list for "implicit" List mappings
|
||||||
|
hibernate.mapping.default_list_semantics=bag
|
||||||
|
|
|
@ -0,0 +1,30 @@
|
||||||
|
/*
|
||||||
|
* Hibernate, Relational Persistence for Idiomatic Java
|
||||||
|
*
|
||||||
|
* License: GNU Lesser General Public License (LGPL), version 2.1 or later
|
||||||
|
* See the lgpl.txt file in the root directory or http://www.gnu.org/licenses/lgpl-2.1.html
|
||||||
|
*/
|
||||||
|
package org.hibernate.testing.orm.junit;
|
||||||
|
|
||||||
|
import org.hibernate.metamodel.CollectionClassification;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Used as a SettingProvider to enable backwards compatibility regarding
|
||||||
|
* plural {@link java.util.List} mappings when no {@link jakarta.persistence.OrderColumn},
|
||||||
|
* {@link org.hibernate.annotations.ListIndexBase},
|
||||||
|
* {@link org.hibernate.annotations.CollectionId} or other annotations hinting at
|
||||||
|
* the classification to use.
|
||||||
|
*
|
||||||
|
* Historically, Hibernate classified these as BAG. 6.0 changes that to LIST (with an
|
||||||
|
* implied {@link jakarta.persistence.OrderColumn}).
|
||||||
|
*
|
||||||
|
* This setting provider is used to enable the legacy classification
|
||||||
|
*
|
||||||
|
* @author Steve Ebersole
|
||||||
|
*/
|
||||||
|
public class ImplicitListAsBagProvider implements SettingProvider.Provider<CollectionClassification> {
|
||||||
|
@Override
|
||||||
|
public CollectionClassification getSetting() {
|
||||||
|
return CollectionClassification.BAG;
|
||||||
|
}
|
||||||
|
}
|
Loading…
Reference in New Issue