HHH-10956 reduced runtime complexity, added Component.getProperty(int)

Component.getProperty(String) was looping and comparing, but we already now the position of the property
This commit is contained in:
Jason Pyeron 2020-04-25 10:53:05 -04:00 committed by Andrea Boriero
parent 2db3ce2643
commit 0804de87b4
2 changed files with 13 additions and 2 deletions

View File

@ -342,6 +342,18 @@ public class Component extends SimpleValue implements MetaAttributable {
return java.util.Collections.unmodifiableMap( tuplizerImpls );
}
/**
* Returns the {@link Property} at the specified position in this {@link Component}.
*
* @param index index of the {@link Property} to return
* @return {@link Property}
* @throws IndexOutOfBoundsException - if the index is out of range(index < 0 || index >=
* {@link #getPropertySpan()})
*/
public Property getProperty(int index) {
return properties.get( index );
}
public Property getProperty(String propertyName) throws MappingException {
Iterator iter = getPropertyIterator();
while ( iter.hasNext() ) {

View File

@ -377,8 +377,7 @@ public abstract class AbstractEntityTuplizer implements EntityTuplizer {
if ( subType.isAssociationType() ) {
throw new HibernateException( "No part of a composite identifier may be null" );
}
final String name = names[i];
final Property p = ( (Component) identifier ).getProperty( name );
final Property p = ( (Component) identifier ).getProperty( i );
final SimpleValue v = (SimpleValue) p.getValue();
if ( v.getIdentifierGenerator() == null ) {
throw new HibernateException( "No part of a composite identifier may be null" );