Make list semantics setting explicit for failing tests
This commit is contained in:
parent
7aaeebe3af
commit
a91d23825f
|
@ -15,6 +15,7 @@ import org.hibernate.metamodel.CollectionClassification;
|
|||
|
||||
import org.hibernate.testing.orm.junit.DomainModel;
|
||||
import org.hibernate.testing.orm.junit.DomainModelScope;
|
||||
import org.hibernate.testing.orm.junit.ImplicitListAsListProvider;
|
||||
import org.hibernate.testing.orm.junit.ServiceRegistry;
|
||||
import org.hibernate.testing.orm.junit.SettingProvider;
|
||||
import org.junit.jupiter.api.Test;
|
||||
|
@ -35,7 +36,7 @@ import static org.hibernate.cfg.AvailableSettings.DEFAULT_LIST_SEMANTICS;
|
|||
@ServiceRegistry(
|
||||
settingProviders = @SettingProvider(
|
||||
settingName = DEFAULT_LIST_SEMANTICS,
|
||||
provider = ImplicitListAsListSemanticsTests.ImplicitListAsListProvider.class )
|
||||
provider = ImplicitListAsListProvider.class )
|
||||
)
|
||||
@DomainModel( annotatedClasses = ImplicitListAsListSemanticsTests.AnEntity.class )
|
||||
public class ImplicitListAsListSemanticsTests {
|
||||
|
@ -100,11 +101,4 @@ public class ImplicitListAsListSemanticsTests {
|
|||
this.name = name;
|
||||
}
|
||||
}
|
||||
|
||||
public static class ImplicitListAsListProvider implements SettingProvider.Provider<CollectionClassification> {
|
||||
@Override
|
||||
public CollectionClassification getSetting() {
|
||||
return CollectionClassification.LIST;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
|
@ -10,11 +10,17 @@ import java.util.Collection;
|
|||
import java.util.List;
|
||||
|
||||
import org.hibernate.cfg.AvailableSettings;
|
||||
import org.hibernate.cfg.Environment;
|
||||
import org.hibernate.mapping.Bag;
|
||||
import org.hibernate.mapping.Property;
|
||||
|
||||
import org.hibernate.testing.orm.junit.DomainModel;
|
||||
import org.hibernate.testing.orm.junit.DomainModelScope;
|
||||
import org.hibernate.testing.orm.junit.ImplicitListAsBagProvider;
|
||||
import org.hibernate.testing.orm.junit.ImplicitListAsListProvider;
|
||||
import org.hibernate.testing.orm.junit.ServiceRegistry;
|
||||
import org.hibernate.testing.orm.junit.Setting;
|
||||
import org.hibernate.testing.orm.junit.SettingProvider;
|
||||
import org.junit.jupiter.api.Test;
|
||||
|
||||
import jakarta.persistence.Basic;
|
||||
|
@ -25,6 +31,7 @@ import jakarta.persistence.OrderColumn;
|
|||
import jakarta.persistence.Table;
|
||||
|
||||
import static org.assertj.core.api.Assertions.assertThat;
|
||||
import static org.hibernate.cfg.AvailableSettings.DEFAULT_LIST_SEMANTICS;
|
||||
|
||||
/**
|
||||
* Uses the default {@value AvailableSettings#DEFAULT_LIST_SEMANTICS} value of LIST
|
||||
|
@ -32,6 +39,12 @@ import static org.assertj.core.api.Assertions.assertThat;
|
|||
*
|
||||
* @author Steve Ebersole
|
||||
*/
|
||||
@ServiceRegistry(
|
||||
settingProviders = @SettingProvider(
|
||||
settingName = DEFAULT_LIST_SEMANTICS,
|
||||
provider = ImplicitListAsListProvider.class
|
||||
)
|
||||
)
|
||||
@DomainModel( annotatedClasses = ImplicitListDefaultSemanticsTests.AnEntity.class )
|
||||
public class ImplicitListDefaultSemanticsTests {
|
||||
@Test
|
||||
|
|
|
@ -14,17 +14,27 @@ import org.hibernate.type.CustomCollectionType;
|
|||
|
||||
import org.hibernate.testing.orm.junit.DomainModel;
|
||||
import org.hibernate.testing.orm.junit.DomainModelScope;
|
||||
import org.hibernate.testing.orm.junit.ImplicitListAsListProvider;
|
||||
import org.hibernate.testing.orm.junit.ServiceRegistry;
|
||||
import org.hibernate.testing.orm.junit.SessionFactory;
|
||||
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.Test;
|
||||
|
||||
import static org.assertj.core.api.Assertions.assertThat;
|
||||
import static org.hibernate.cfg.AvailableSettings.DEFAULT_LIST_SEMANTICS;
|
||||
import static org.junit.jupiter.api.Assertions.fail;
|
||||
|
||||
/**
|
||||
* @author Steve Ebersole
|
||||
*/
|
||||
@ServiceRegistry(
|
||||
settingProviders = @SettingProvider(
|
||||
settingName = DEFAULT_LIST_SEMANTICS,
|
||||
provider = ImplicitListAsListProvider.class
|
||||
)
|
||||
)
|
||||
@DomainModel( annotatedClasses = { TheEntityWithUniqueList.class, TheEntityWithUniqueListRegistration.class } )
|
||||
@SessionFactory
|
||||
public class CustomSemanticsTest {
|
||||
|
|
|
@ -7,6 +7,7 @@
|
|||
package org.hibernate.orm.test.mapping.onetomany;
|
||||
|
||||
import java.util.ArrayList;
|
||||
import java.util.HashSet;
|
||||
import java.util.List;
|
||||
import jakarta.persistence.Entity;
|
||||
import jakarta.persistence.Id;
|
||||
|
@ -616,8 +617,8 @@ public class OneToManyBidirectionalTest {
|
|||
assertThat( statistics.getPrepareStatementCount(), is( 1L ) );
|
||||
assertTrue( Hibernate.isInitialized( order.getLineItems() ) );
|
||||
|
||||
|
||||
assertThat( order.getLineItems().size(), is( 2 ) );
|
||||
// With BAG semantics, the list will contain duplicates, so filter that
|
||||
assertThat( new HashSet<>( order.getLineItems()).size(), is( 2 ) );
|
||||
} );
|
||||
}
|
||||
|
||||
|
|
|
@ -0,0 +1,19 @@
|
|||
/*
|
||||
* 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;
|
||||
|
||||
/**
|
||||
* @author Christian Beikov
|
||||
*/
|
||||
public class ImplicitListAsListProvider implements SettingProvider.Provider<CollectionClassification> {
|
||||
@Override
|
||||
public CollectionClassification getSetting() {
|
||||
return CollectionClassification.LIST;
|
||||
}
|
||||
}
|
Loading…
Reference in New Issue