mirror of
https://github.com/hibernate/hibernate-orm
synced 2025-02-17 00:24:57 +00:00
HHH-7929 bind batch size to the plural attribute
This commit is contained in:
parent
948b14f866
commit
bdf13987a2
@ -1412,6 +1412,7 @@ private AbstractPluralAttributeBinding bindPluralAttribute(
|
||||
attributeBinding.setCustomSqlDeleteAll( attributeSource.getCustomSqlDeleteAll() );
|
||||
attributeBinding.setWhere( attributeSource.getWhere() );
|
||||
attributeBinding.setMutable( attributeSource.isMutable() );
|
||||
attributeBinding.setBatchSize( attributeSource.getBatchSize() );
|
||||
switch ( attributeSource.getElementSource().getNature() ) {
|
||||
case BASIC:
|
||||
bindBasicPluralAttribute( attributeSource, attributeBinding, reflectedCollectionJavaTypes );
|
||||
|
@ -634,13 +634,7 @@ public void addEntity(EntityBinding entityBinding) {
|
||||
if ( isPOJO && StringHelper.isEmpty( className ) ) {
|
||||
throw new MappingException( "Entity[" + entityName + "] is mapped as pojo but don't have a class name" );
|
||||
}
|
||||
if ( StringHelper.isEmpty( className ) || entityName.equals( className ) ) {
|
||||
//ignore
|
||||
}
|
||||
else if ( entityBindingMap.containsKey( className ) ) {
|
||||
throw new DuplicateMappingException( DuplicateMappingException.Type.ENTITY, entityName );
|
||||
}
|
||||
else {
|
||||
if ( StringHelper.isNotEmpty( className ) && !entityBindingMap.containsKey( className ) ) {
|
||||
entityBindingMap.put( className, entityBinding );
|
||||
}
|
||||
}
|
||||
|
@ -116,6 +116,11 @@ public FilterSource[] getFilterSources() {
|
||||
return filterSources;
|
||||
}
|
||||
|
||||
@Override
|
||||
public int getBatchSize() {
|
||||
return associationAttribute.getBatchSize();
|
||||
}
|
||||
|
||||
@Override
|
||||
public ValueHolder<Class<?>> getElementClassReference() {
|
||||
// needed for arrays
|
||||
|
@ -90,6 +90,7 @@ public class AssociationAttribute extends MappedAttribute {
|
||||
private final AnnotationInstance joinTableAnnotation;
|
||||
private AttributeTypeResolver resolver;
|
||||
|
||||
|
||||
public static AssociationAttribute createAssociationAttribute(
|
||||
ClassInfo classInfo,
|
||||
String name,
|
||||
|
@ -86,6 +86,7 @@ public class PluralAssociationAttribute extends AssociationAttribute {
|
||||
private LazyCollectionOption lazyOption;
|
||||
private final boolean isCollectionIdPresent;
|
||||
private final boolean mutable;
|
||||
private final int batchSize;
|
||||
|
||||
|
||||
public static PluralAssociationAttribute createPluralAssociationAttribute(
|
||||
@ -265,6 +266,13 @@ HibernateDotNames.SQL_DELETE_ALL, annotations()
|
||||
this.isSequentiallyIndexed = orderColumnAnnotation != null || indexColumnAnnotation != null;
|
||||
this.pluralAttributeNature = resolvePluralAttributeNature();
|
||||
|
||||
AnnotationInstance batchAnnotation = JandexHelper.getSingleAnnotation( annotations, HibernateDotNames.BATCH_SIZE );
|
||||
if ( batchAnnotation != null ) {
|
||||
this.batchSize = batchAnnotation.value( "size" ).asInt();
|
||||
}
|
||||
else {
|
||||
this.batchSize = -1;
|
||||
}
|
||||
validateMapping();
|
||||
}
|
||||
|
||||
@ -348,6 +356,10 @@ public boolean isOptimisticLockable() {
|
||||
return hasOptimisticLockAnnotation() ? super.isOptimisticLockable() : StringHelper.isEmpty( getMappedBy() );
|
||||
}
|
||||
|
||||
public int getBatchSize() {
|
||||
return batchSize;
|
||||
}
|
||||
|
||||
private String determineCustomLoaderName() {
|
||||
String loader = null;
|
||||
final AnnotationInstance customLoaderAnnotation = JandexHelper.getSingleAnnotation(
|
||||
|
@ -196,6 +196,11 @@ public boolean isMutable() {
|
||||
return pluralAttributeElement.isMutable();
|
||||
}
|
||||
|
||||
@Override
|
||||
public int getBatchSize() {
|
||||
return pluralAttributeElement.getBatchSize();
|
||||
}
|
||||
|
||||
@Override
|
||||
public String getMappedBy() {
|
||||
return null;
|
||||
@ -353,7 +358,7 @@ public FetchStyle getFetchStyle() {
|
||||
final String outerJoinSelection = pluralAttributeElement.getOuterJoin() != null
|
||||
? pluralAttributeElement.getOuterJoin().value()
|
||||
: null;
|
||||
final int batchSize = pluralAttributeElement.getBatchSize();
|
||||
final int batchSize = getBatchSize();
|
||||
|
||||
if ( fetchSelection == null ) {
|
||||
if ( outerJoinSelection == null ) {
|
||||
|
@ -75,6 +75,8 @@ public interface PluralAttributeSource
|
||||
|
||||
public String getMappedBy();
|
||||
|
||||
public int getBatchSize();
|
||||
|
||||
/**
|
||||
* Describes the nature of the collection itself as declared by the metadata.
|
||||
*
|
||||
|
@ -36,7 +36,6 @@
|
||||
import org.hibernate.cfg.AvailableSettings;
|
||||
import org.hibernate.cfg.Configuration;
|
||||
import org.hibernate.loader.BatchFetchStyle;
|
||||
import org.hibernate.testing.FailureExpectedWithNewMetamodel;
|
||||
import org.hibernate.testing.junit4.BaseCoreFunctionalTestCase;
|
||||
import org.junit.Test;
|
||||
|
||||
@ -63,7 +62,6 @@ protected void configure(Configuration configuration) {
|
||||
|
||||
@SuppressWarnings( {"unchecked"})
|
||||
@Test
|
||||
@FailureExpectedWithNewMetamodel
|
||||
public void testBatchFetch() {
|
||||
Session s = openSession();
|
||||
Transaction t = s.beginTransaction();
|
||||
|
@ -37,7 +37,6 @@
|
||||
import static org.junit.Assert.assertTrue;
|
||||
|
||||
@SuppressWarnings( {"UnnecessaryBoxing"})
|
||||
@FailureExpectedWithNewMetamodel
|
||||
public class ABCTest extends LegacyTestCase {
|
||||
@Override
|
||||
public String[] getMappings() {
|
||||
@ -78,6 +77,7 @@ public void testFormulaAssociation() throws Throwable {
|
||||
}
|
||||
|
||||
@Test
|
||||
@FailureExpectedWithNewMetamodel
|
||||
public void testHigherLevelIndexDefinition() throws Throwable {
|
||||
String[] commands = configuration().generateSchemaCreationScript( getDialect() );
|
||||
int max = commands.length;
|
||||
@ -92,6 +92,7 @@ public void testHigherLevelIndexDefinition() throws Throwable {
|
||||
}
|
||||
|
||||
@Test
|
||||
@FailureExpectedWithNewMetamodel
|
||||
public void testSubclassing() throws Exception {
|
||||
Session s = openSession();
|
||||
Transaction t = s.beginTransaction();
|
||||
|
@ -32,7 +32,6 @@
|
||||
import org.hibernate.criterion.Example;
|
||||
import org.hibernate.criterion.Restrictions;
|
||||
import org.hibernate.dialect.SybaseASE15Dialect;
|
||||
import org.hibernate.testing.FailureExpectedWithNewMetamodel;
|
||||
import org.hibernate.testing.SkipForDialect;
|
||||
|
||||
import static org.junit.Assert.assertEquals;
|
||||
@ -43,7 +42,6 @@
|
||||
*
|
||||
* @author Emmanuel Bernard
|
||||
*/
|
||||
@FailureExpectedWithNewMetamodel
|
||||
public class QueryByExampleTest extends LegacyTestCase {
|
||||
@Override
|
||||
public String[] getMappings() {
|
||||
|
@ -27,7 +27,6 @@
|
||||
import org.hibernate.testing.TestForIssue;
|
||||
import org.junit.Test;
|
||||
|
||||
@FailureExpectedWithNewMetamodel
|
||||
public class SQLLoaderTest extends LegacyTestCase {
|
||||
static int nextInt = 1;
|
||||
static long nextLong = 1;
|
||||
@ -624,6 +623,7 @@ public void testFindBySQLSimpleByDiffSessions() throws Exception {
|
||||
}
|
||||
|
||||
@Test
|
||||
@FailureExpectedWithNewMetamodel
|
||||
public void testFindBySQLDiscriminatedSameSession() throws Exception {
|
||||
Session session = openSession();
|
||||
session.beginTransaction();
|
||||
|
@ -30,14 +30,12 @@
|
||||
import org.hibernate.SessionFactory;
|
||||
import org.hibernate.Transaction;
|
||||
import org.hibernate.stat.Statistics;
|
||||
import org.hibernate.testing.FailureExpectedWithNewMetamodel;
|
||||
|
||||
import static org.junit.Assert.assertEquals;
|
||||
|
||||
/**
|
||||
* @author Emmanuel Bernard
|
||||
*/
|
||||
@FailureExpectedWithNewMetamodel
|
||||
public class StatisticsTest extends LegacyTestCase {
|
||||
@Override
|
||||
public String[] getMappings() {
|
||||
|
Loading…
x
Reference in New Issue
Block a user