mirror of
https://github.com/hibernate/hibernate-orm
synced 2025-02-08 20:24:46 +00:00
HHH-14346 Check declaredPluralAttributes for null before access
This commit is contained in:
parent
c215601025
commit
12b284cfcf
@ -259,7 +259,7 @@ protected <Y> boolean isPrimitiveVariant(SingularAttribute<?,?> attribute, Class
|
||||
@Override
|
||||
@SuppressWarnings({ "unchecked" })
|
||||
public Set<PluralAttribute<? super J, ?, ?>> getPluralAttributes() {
|
||||
HashSet attributes = declaredAttributes == null ? new HashSet<PluralAttribute<? super J, ?, ?>>() : new HashSet<PluralAttribute<? super J, ?, ?>>( declaredPluralAttributes.values() );
|
||||
HashSet attributes = declaredPluralAttributes == null ? new HashSet<PluralAttribute<? super J, ?, ?>>() : new HashSet<PluralAttribute<? super J, ?, ?>>( declaredPluralAttributes.values() );
|
||||
if ( getSuperType() != null ) {
|
||||
attributes.addAll( getSuperType().getPluralAttributes() );
|
||||
}
|
||||
|
@ -31,6 +31,7 @@
|
||||
import org.hibernate.metamodel.internal.JpaMetaModelPopulationSetting;
|
||||
import org.hibernate.metamodel.internal.MetamodelImpl;
|
||||
|
||||
import org.hibernate.testing.TestForIssue;
|
||||
import org.junit.Test;
|
||||
|
||||
import static org.junit.Assert.assertEquals;
|
||||
@ -268,6 +269,14 @@ public void testCollection() throws Exception {
|
||||
assertTrue( flowers instanceof ListAttribute );
|
||||
}
|
||||
|
||||
@Test
|
||||
@TestForIssue( jiraKey = "HHH-14346" )
|
||||
public void testEmptyPluralAttributeSet() throws Exception {
|
||||
final EntityType<Feline> entityType = entityManagerFactory().getMetamodel().entity( Feline.class );
|
||||
final Set<PluralAttribute<? super Feline, ?, ?>> attributes = entityType.getPluralAttributes();
|
||||
assertEquals( 0, attributes.size() );
|
||||
}
|
||||
|
||||
@Test
|
||||
public void testElementCollection() throws Exception {
|
||||
final EntityType<House> entityType = entityManagerFactory().getMetamodel().entity( House.class );
|
||||
|
Loading…
x
Reference in New Issue
Block a user