org.hibernate.internal.util.collections.ArrayHelper Java Examples
The following examples show how to use
org.hibernate.internal.util.collections.ArrayHelper.
You can vote up the ones you like or vote down the ones you don't like,
and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example #1
Source File: CriteriaLoader.java From lams with GNU General Public License v2.0 | 6 votes |
@Override protected Object[] getResultRow(Object[] row, ResultSet rs, SharedSessionContractImplementor session) throws SQLException, HibernateException { final Object[] result; if ( translator.hasProjection() ) { Type[] types = translator.getProjectedTypes(); result = new Object[types.length]; String[] columnAliases = translator.getProjectedColumnAliases(); for ( int i=0, pos=0; i<result.length; i++ ) { int numColumns = types[i].getColumnSpan( session.getFactory() ); if ( numColumns > 1 ) { String[] typeColumnAliases = ArrayHelper.slice( columnAliases, pos, numColumns ); result[i] = types[i].nullSafeGet(rs, typeColumnAliases, session, null); } else { result[i] = types[i].nullSafeGet(rs, columnAliases[pos], session, null); } pos += numColumns; } } else { result = toResultRow( row ); } return result; }
Example #2
Source File: LegacyBatchingEntityLoaderBuilder.java From lams with GNU General Public License v2.0 | 6 votes |
protected LegacyBatchingEntityLoader( OuterJoinLoadable persister, int maxBatchSize, LockMode lockMode, LockOptions lockOptions, SessionFactoryImplementor factory, LoadQueryInfluencers loadQueryInfluencers) { super( persister ); this.batchSizes = ArrayHelper.getBatchSizes( maxBatchSize ); this.loaders = new EntityLoader[ batchSizes.length ]; final EntityLoader.Builder entityLoaderBuilder = EntityLoader.forEntity( persister ) .withInfluencers( loadQueryInfluencers ) .withLockMode( lockMode ) .withLockOptions( lockOptions ); // we create a first entity loader to use it as a template for the others this.loaders[0] = entityLoaderBuilder.withBatchSize( batchSizes[0] ).byPrimaryKey(); for ( int i = 1; i < batchSizes.length; i++ ) { this.loaders[i] = entityLoaderBuilder.withEntityLoaderTemplate( this.loaders[0] ).withBatchSize( batchSizes[i] ).byPrimaryKey(); } }
Example #3
Source File: CustomLoader.java From lams with GNU General Public License v2.0 | 6 votes |
@Override protected void autoDiscoverTypes(ResultSet rs) { try { JdbcResultMetadata metadata = new JdbcResultMetadata( getFactory(), rs ); rowProcessor.prepareForAutoDiscovery( metadata ); List<String> aliases = new ArrayList<>(); List<Type> types = new ArrayList<>(); for ( ResultColumnProcessor resultProcessor : rowProcessor.getColumnProcessors() ) { resultProcessor.performDiscovery( metadata, types, aliases ); } validateAliases( aliases ); resultTypes = ArrayHelper.toTypeArray( types ); transformerAliases = ArrayHelper.toStringArray( aliases ); } catch (SQLException e) { throw new HibernateException( "Exception while trying to autodiscover types.", e ); } }
Example #4
Source File: DynamicBatchingCollectionInitializerBuilder.java From lams with GNU General Public License v2.0 | 6 votes |
@Override public void initialize(Serializable id, SharedSessionContractImplementor session) throws HibernateException { // first, figure out how many batchable ids we have... final Serializable[] batch = session.getPersistenceContext() .getBatchFetchQueue() .getCollectionBatch( collectionPersister(), id, maxBatchSize ); final int numberOfIds = ArrayHelper.countNonNull( batch ); if ( numberOfIds <= 1 ) { singleKeyLoader.loadCollection( session, id, collectionPersister().getKeyType() ); return; } final Serializable[] idsToLoad = new Serializable[numberOfIds]; System.arraycopy( batch, 0, idsToLoad, 0, numberOfIds ); batchLoader.doBatchedCollectionLoad( session, idsToLoad, collectionPersister().getKeyType() ); }
Example #5
Source File: NativeSQLQuerySpecification.java From lams with GNU General Public License v2.0 | 6 votes |
public NativeSQLQuerySpecification( String queryString, NativeSQLQueryReturn[] queryReturns, Collection querySpaces) { this.queryString = queryString; this.queryReturns = queryReturns; if ( querySpaces == null ) { this.querySpaces = Collections.EMPTY_SET; } else { Set tmp = new HashSet(); tmp.addAll( querySpaces ); this.querySpaces = Collections.unmodifiableSet( tmp ); } // pre-determine and cache the hashcode int hashCode = queryString.hashCode(); hashCode = 29 * hashCode + this.querySpaces.hashCode(); if ( this.queryReturns != null ) { hashCode = 29 * hashCode + ArrayHelper.toList( this.queryReturns ).hashCode(); } this.hashCode = hashCode; }
Example #6
Source File: JoinHelper.java From lams with GNU General Public License v2.0 | 6 votes |
/** * Get the qualified (prefixed by alias) names of the columns of the owning entity which are to be used in the join * * @param associationType The association type for the association that represents the join * @param columnQualifier The left-hand side table alias * @param propertyIndex The index of the property that represents the association/join * @param begin The index for any nested (composites) attributes * @param lhsPersister The persister for the left-hand side of the association/join * @param mapping The mapping (typically the SessionFactory). * * @return The qualified column names. */ public static String[] getAliasedLHSColumnNames( AssociationType associationType, String columnQualifier, int propertyIndex, int begin, OuterJoinLoadable lhsPersister, Mapping mapping) { if ( associationType.useLHSPrimaryKey() ) { return StringHelper.qualify( columnQualifier, lhsPersister.getIdentifierColumnNames() ); } else { final String propertyName = associationType.getLHSPropertyName(); if ( propertyName == null ) { return ArrayHelper.slice( toColumns( lhsPersister, columnQualifier, propertyIndex ), begin, associationType.getColumnSpan( mapping ) ); } else { //bad cast return ( (PropertyMapping) lhsPersister ).toColumns( columnQualifier, propertyName ); } } }
Example #7
Source File: ReactiveDynamicBatchingCollectionDelegator.java From hibernate-reactive with GNU Lesser General Public License v2.1 | 6 votes |
@Override public CompletionStage<Void> reactiveInitialize(Serializable id, SharedSessionContractImplementor session) { final Serializable[] batch = session.getPersistenceContextInternal() .getBatchFetchQueue() .getCollectionBatch( collectionPersister(), id, maxBatchSize ); final int numberOfIds = ArrayHelper.countNonNull( batch ); if ( numberOfIds <= 1 ) { return singleKeyLoader.reactiveLoadCollection( (SessionImplementor) session, id, collectionPersister().getKeyType() ); } final Serializable[] idsToLoad = new Serializable[numberOfIds]; System.arraycopy( batch, 0, idsToLoad, 0, numberOfIds ); return batchLoader.doBatchedCollectionLoad( (SessionImplementor) session, idsToLoad, collectionPersister().getKeyType() ); }
Example #8
Source File: OneToManyPersister.java From lams with GNU General Public License v2.0 | 6 votes |
/** * Generate the SQL UPDATE that updates a particular row's foreign * key to null */ @Override protected String generateDeleteRowString() { final Update update = new Update( getDialect() ) .setTableName( qualifiedTableName ) .addColumns( keyColumnNames, "null" ); if ( hasIndex && !indexContainsFormula ) { for ( int i = 0 ; i < indexColumnNames.length ; i++ ) { if ( indexColumnIsSettable[i] ) { update.addColumn( indexColumnNames[i], "null" ); } } } if ( getFactory().getSessionFactoryOptions().isCommentsEnabled() ) { update.setComment( "delete one-to-many row " + getRole() ); } //use a combination of foreign key columns and pk columns, since //the ordering of removal and addition is not guaranteed when //a child moves from one parent to another String[] rowSelectColumnNames = ArrayHelper.join( keyColumnNames, elementColumnNames ); return update.addPrimaryKeyColumns( rowSelectColumnNames ) .toStatementString(); }
Example #9
Source File: ReactiveDynamicBatchingCollectionDelegator.java From hibernate-reactive with GNU Lesser General Public License v2.1 | 6 votes |
@Override public void initialize(Serializable id, SharedSessionContractImplementor session) throws HibernateException { // first, figure out how many batchable ids we have... final Serializable[] batch = session.getPersistenceContextInternal() .getBatchFetchQueue() .getCollectionBatch( collectionPersister(), id, maxBatchSize ); final int numberOfIds = ArrayHelper.countNonNull( batch ); if ( numberOfIds <= 1 ) { singleKeyLoader.loadCollection( session, id, collectionPersister().getKeyType() ); return; } final Serializable[] idsToLoad = new Serializable[numberOfIds]; System.arraycopy( batch, 0, idsToLoad, 0, numberOfIds ); batchLoader.doBatchedCollectionLoad( (SessionImplementor) session, idsToLoad, collectionPersister().getKeyType() ); }
Example #10
Source File: AbstractCollectionReference.java From lams with GNU General Public License v2.0 | 5 votes |
protected AbstractCollectionReference( ExpandingCollectionQuerySpace collectionQuerySpace, PropertyPath propertyPath, boolean shouldIncludeJoins) { this.collectionQuerySpace = collectionQuerySpace; this.propertyPath = propertyPath; this.allowElementJoin = shouldIncludeJoins; // Currently we can only allow a join for the collection index if all of the following are true: // - collection element joins are allowed; // - index is an EntityType; // - index values are not "formulas" (e.g., a @MapKey index is translated into "formula" value(s)). // Hibernate cannot currently support eager joining of associations within a component (@Embeddable) as an index. if ( shouldIncludeJoins && collectionQuerySpace.getCollectionPersister().hasIndex() && collectionQuerySpace.getCollectionPersister().getIndexType().isEntityType() ) { final String[] indexFormulas = ( (QueryableCollection) collectionQuerySpace.getCollectionPersister() ).getIndexFormulas(); final int nNonNullFormulas = ArrayHelper.countNonNull( indexFormulas ); this.allowIndexJoin = nNonNullFormulas == 0; } else { this.allowIndexJoin = false; } // All other fields must be initialized before building this.index and this.element. this.index = buildIndexGraph(); this.element = buildElementGraph(); }
Example #11
Source File: BasicCollectionPersister.java From lams with GNU General Public License v2.0 | 5 votes |
/** * Generate the SQL UPDATE that updates a row */ @Override protected String generateUpdateRowString() { final Update update = new Update( getDialect() ) .setTableName( qualifiedTableName ); //if ( !elementIsFormula ) { update.addColumns( elementColumnNames, elementColumnIsSettable, elementColumnWriters ); //} if ( hasIdentifier ) { update.addPrimaryKeyColumns( new String[] {identifierColumnName} ); } else if ( hasIndex && !indexContainsFormula ) { update.addPrimaryKeyColumns( ArrayHelper.join( keyColumnNames, indexColumnNames ) ); } else { update.addPrimaryKeyColumns( keyColumnNames ); update.addPrimaryKeyColumns( elementColumnNames, elementColumnIsInPrimaryKey, elementColumnWriters ); } if ( getFactory().getSessionFactoryOptions().isCommentsEnabled() ) { update.setComment( "update collection row " + getRole() ); } return update.toStatementString(); }
Example #12
Source File: QueryParameterBindingsImpl.java From lams with GNU General Public License v2.0 | 5 votes |
/** * @deprecated (since 5.2) expect a different approach to org.hibernate.engine.spi.QueryParameters in 6.0 */ @Deprecated public Type[] collectPositionalBindTypes() { return ArrayHelper.EMPTY_TYPE_ARRAY; // if ( ! parameterMetadata.hasPositionalParameters() ) { // return ArrayHelper.EMPTY_TYPE_ARRAY; // } // // // callers expect these in ordinal order. In a way that is natural, but at the same // // time long term a way to find types/values by name/position would be better // // final TreeMap<QueryParameter, QueryParameterBinding> sortedPositionalParamBindings = getSortedPositionalParamBindingMap(); // final List<Type> types = CollectionHelper.arrayList( sortedPositionalParamBindings.size() ); // // for ( Map.Entry<QueryParameter, QueryParameterBinding> entry : sortedPositionalParamBindings.entrySet() ) { // if ( entry.getKey().getPosition() == null ) { // continue; // } // // Type type = entry.getValue().getBindType(); // if ( type == null ) { // type = entry.getKey().getType(); // } // // if ( type == null ) { // log.debugf( // "Binding for positional-parameter [%s] did not define type, using SerializableType", // entry.getKey().getPosition() // ); // type = SerializableType.INSTANCE; // } // // types.add( type ); // } // // return types.toArray( new Type[ types.size() ] ); }
Example #13
Source File: JoinHelper.java From lams with GNU General Public License v2.0 | 5 votes |
/** * Get the columns of the owning entity which are to be used in the join * * @param type The type representing the join * @param property The property index for the association type * @param begin ? * @param lhsPersister The persister for the left-hand-side of the join * @param mapping The mapping object (typically the SessionFactory) * * @return The columns for the left-hand-side of the join */ public static String[] getLHSColumnNames( AssociationType type, int property, int begin, OuterJoinLoadable lhsPersister, Mapping mapping) { if ( type.useLHSPrimaryKey() ) { //return lhsPersister.getSubclassPropertyColumnNames(property); return lhsPersister.getIdentifierColumnNames(); } else { final String propertyName = type.getLHSPropertyName(); if ( propertyName == null ) { //slice, to get the columns for this component //property return ArrayHelper.slice( property < 0 ? lhsPersister.getIdentifierColumnNames() : lhsPersister.getSubclassPropertyColumnNames( property ), begin, type.getColumnSpan( mapping ) ); } else { //property-refs for associations defined on a //component are not supported, so no need to slice return lhsPersister.getPropertyColumnNames( propertyName ); } } }
Example #14
Source File: ByteBuddyProxyFactory.java From lams with GNU General Public License v2.0 | 5 votes |
private Class[] toArray(Set<Class> interfaces) { if ( interfaces == null ) { return ArrayHelper.EMPTY_CLASS_ARRAY; } return interfaces.toArray( new Class[interfaces.size()] ); }
Example #15
Source File: ParamLocationRecognizer.java From lams with GNU General Public License v2.0 | 5 votes |
private OrdinalParameterDescriptor complete() { return new OrdinalParameterDescriptor( identifier, identifier - 1, null, ArrayHelper.toIntArray( sourcePositions ) ); }
Example #16
Source File: ParamLocationRecognizer.java From lams with GNU General Public License v2.0 | 5 votes |
private NamedParameterDescriptor complete() { return new NamedParameterDescriptor( name, null, ArrayHelper.toIntArray( sourcePositions ) ); }
Example #17
Source File: CallbackRegistryImpl.java From lams with GNU General Public License v2.0 | 5 votes |
@Override public void registerCallbacks(Class entityClass, Callback[] callbacks) { if ( callbacks == null || callbacks.length == 0 ) { return; } final HashMap<Class, Callback[]> map = determineAppropriateCallbackMap( callbacks[0].getCallbackType() ); Callback[] entityCallbacks = map.get( entityClass ); if ( entityCallbacks != null ) { callbacks = ArrayHelper.join( entityCallbacks, callbacks ); } map.put( entityClass, callbacks ); }
Example #18
Source File: PaddedBatchingCollectionInitializerBuilder.java From lams with GNU General Public License v2.0 | 5 votes |
@Override public void initialize(Serializable id, SharedSessionContractImplementor session) throws HibernateException { final Serializable[] batch = session.getPersistenceContext() .getBatchFetchQueue() .getCollectionBatch( collectionPersister(), id, batchSizes[0] ); final int numberOfIds = ArrayHelper.countNonNull( batch ); if ( numberOfIds <= 1 ) { loaders[batchSizes.length-1].loadCollection( session, id, collectionPersister().getKeyType() ); return; } // Uses the first batch-size bigger than the number of actual ids in the batch int indexToUse = batchSizes.length-1; for ( int i = 0; i < batchSizes.length-1; i++ ) { if ( batchSizes[i] >= numberOfIds ) { indexToUse = i; } else { break; } } final Serializable[] idsToLoad = new Serializable[ batchSizes[indexToUse] ]; System.arraycopy( batch, 0, idsToLoad, 0, numberOfIds ); for ( int i = numberOfIds; i < batchSizes[indexToUse]; i++ ) { idsToLoad[i] = id; } loaders[indexToUse].loadCollectionBatch( session, idsToLoad, collectionPersister().getKeyType() ); }
Example #19
Source File: JoinedSubclassEntityPersister.java From lams with GNU General Public License v2.0 | 5 votes |
@Override public int determineTableNumberForColumn(String columnName) { // HHH-7630: In case the naturalOrder/identifier column is explicitly given in the ordering, check here. for ( int i = 0, max = naturalOrderTableKeyColumns.length; i < max; i++ ) { final String[] keyColumns = naturalOrderTableKeyColumns[i]; if ( ArrayHelper.contains( keyColumns, columnName ) ) { return naturalOrderPropertyTableNumbers[i]; } } final String[] subclassColumnNameClosure = getSubclassColumnClosure(); for ( int i = 0, max = subclassColumnNameClosure.length; i < max; i++ ) { final boolean quoted = subclassColumnNameClosure[i].startsWith( "\"" ) && subclassColumnNameClosure[i].endsWith( "\"" ); if ( quoted ) { if ( subclassColumnNameClosure[i].equals( columnName ) ) { return getSubclassColumnTableNumberClosure()[i]; } } else { if ( subclassColumnNameClosure[i].equalsIgnoreCase( columnName ) ) { return getSubclassColumnTableNumberClosure()[i]; } } } throw new HibernateException( "Could not locate table which owns column [" + columnName + "] referenced in order-by mapping" ); }
Example #20
Source File: LegacyBatchingCollectionInitializerBuilder.java From lams with GNU General Public License v2.0 | 5 votes |
@Override public CollectionInitializer createRealBatchingOneToManyInitializer( QueryableCollection persister, int maxBatchSize, SessionFactoryImplementor factory, LoadQueryInfluencers loadQueryInfluencers) throws MappingException { final int[] batchSizes = ArrayHelper.getBatchSizes( maxBatchSize ); final Loader[] loaders = new Loader[ batchSizes.length ]; for ( int i = 0; i < batchSizes.length; i++ ) { loaders[i] = new OneToManyLoader( persister, batchSizes[i], factory, loadQueryInfluencers ); } return new LegacyBatchingCollectionInitializer( persister, batchSizes, loaders ); }
Example #21
Source File: LegacyBatchingCollectionInitializerBuilder.java From lams with GNU General Public License v2.0 | 5 votes |
@Override public CollectionInitializer createRealBatchingCollectionInitializer( QueryableCollection persister, int maxBatchSize, SessionFactoryImplementor factory, LoadQueryInfluencers loadQueryInfluencers) throws MappingException { int[] batchSizes = ArrayHelper.getBatchSizes( maxBatchSize ); Loader[] loaders = new Loader[ batchSizes.length ]; for ( int i = 0; i < batchSizes.length; i++ ) { loaders[i] = new BasicCollectionLoader( persister, batchSizes[i], factory, loadQueryInfluencers ); } return new LegacyBatchingCollectionInitializer( persister, batchSizes, loaders ); }
Example #22
Source File: StatisticsImpl.java From lams with GNU General Public License v2.0 | 5 votes |
@Override public String[] getEntityNames() { if ( sessionFactory == null ) { return ArrayHelper.toStringArray( entityStatsMap.keySet() ); } else { return sessionFactory.getMetamodel().getAllEntityNames(); } }
Example #23
Source File: PaddedBatchingCollectionInitializerBuilder.java From lams with GNU General Public License v2.0 | 5 votes |
@Override public CollectionInitializer createRealBatchingOneToManyInitializer( QueryableCollection persister, int maxBatchSize, SessionFactoryImplementor factory, LoadQueryInfluencers loadQueryInfluencers) throws MappingException { final int[] batchSizes = ArrayHelper.getBatchSizes( maxBatchSize ); final Loader[] loaders = new Loader[ batchSizes.length ]; for ( int i = 0; i < batchSizes.length; i++ ) { loaders[i] = new OneToManyLoader( persister, batchSizes[i], factory, loadQueryInfluencers ); } return new PaddedBatchingCollectionInitializer( persister, batchSizes, loaders ); }
Example #24
Source File: PaddedBatchingCollectionInitializerBuilder.java From lams with GNU General Public License v2.0 | 5 votes |
@Override public CollectionInitializer createRealBatchingCollectionInitializer( QueryableCollection persister, int maxBatchSize, SessionFactoryImplementor factory, LoadQueryInfluencers loadQueryInfluencers) throws MappingException { int[] batchSizes = ArrayHelper.getBatchSizes( maxBatchSize ); Loader[] loaders = new Loader[ batchSizes.length ]; for ( int i = 0; i < batchSizes.length; i++ ) { loaders[i] = new BasicCollectionLoader( persister, batchSizes[i], factory, loadQueryInfluencers ); } return new PaddedBatchingCollectionInitializer( persister, batchSizes, loaders ); }
Example #25
Source File: LegacyBatchingCollectionInitializerBuilder.java From lams with GNU General Public License v2.0 | 5 votes |
@Override protected CollectionInitializer createRealBatchingOneToManyInitializer( QueryableCollection persister, int maxBatchSize, SessionFactoryImplementor factory, LoadQueryInfluencers loadQueryInfluencers) throws MappingException { final int[] batchSizes = ArrayHelper.getBatchSizes( maxBatchSize ); final Loader[] loaders = new Loader[ batchSizes.length ]; for ( int i = 0; i < batchSizes.length; i++ ) { loaders[i] = new OneToManyLoader( persister, batchSizes[i], factory, loadQueryInfluencers ); } return new LegacyBatchingCollectionInitializer( persister, batchSizes, loaders ); }
Example #26
Source File: LegacyBatchingCollectionInitializerBuilder.java From lams with GNU General Public License v2.0 | 5 votes |
@Override protected CollectionInitializer createRealBatchingCollectionInitializer( QueryableCollection persister, int maxBatchSize, SessionFactoryImplementor factory, LoadQueryInfluencers loadQueryInfluencers) throws MappingException { int[] batchSizes = ArrayHelper.getBatchSizes( maxBatchSize ); Loader[] loaders = new Loader[ batchSizes.length ]; for ( int i = 0; i < batchSizes.length; i++ ) { loaders[i] = new BasicCollectionLoader( persister, batchSizes[i], factory, loadQueryInfluencers ); } return new LegacyBatchingCollectionInitializer( persister, batchSizes, loaders ); }
Example #27
Source File: StatisticsImpl.java From lams with GNU General Public License v2.0 | 5 votes |
@Override public String[] getCollectionRoleNames() { if ( sessionFactory == null ) { return ArrayHelper.toStringArray( collectionStatsMap.keySet() ); } else { return sessionFactory.getMetamodel().getAllCollectionRoles(); } }
Example #28
Source File: StringHelper.java From lams with GNU General Public License v2.0 | 5 votes |
public static int[] locateUnquoted(String string, char character) { if ( '\'' == character ) { throw new IllegalArgumentException( "Unquoted count of quotes is invalid" ); } if ( string == null ) { return new int[0]; } ArrayList locations = new ArrayList( 20 ); // Impl note: takes advantage of the fact that an escpaed single quote // embedded within a quote-block can really be handled as two seperate // quote-blocks for the purposes of this method... int stringLength = string.length(); boolean inQuote = false; for ( int indx = 0; indx < stringLength; indx++ ) { char c = string.charAt( indx ); if ( inQuote ) { if ( '\'' == c ) { inQuote = false; } } else if ( '\'' == c ) { inQuote = true; } else if ( c == character ) { locations.add( indx ); } } return ArrayHelper.toIntArray( locations ); }
Example #29
Source File: ComponentType.java From lams with GNU General Public License v2.0 | 5 votes |
@Override public void nullSafeSet( PreparedStatement st, Object value, int begin, boolean[] settable, SharedSessionContractImplementor session) throws HibernateException, SQLException { Object[] subvalues = nullSafeGetValues( value, entityMode ); int loc = 0; for ( int i = 0; i < propertySpan; i++ ) { int len = propertyTypes[i].getColumnSpan( session.getFactory() ); //noinspection StatementWithEmptyBody if ( len == 0 ) { //noop } else if ( len == 1 ) { if ( settable[loc] ) { propertyTypes[i].nullSafeSet( st, subvalues[i], begin, session ); begin++; } } else { boolean[] subsettable = new boolean[len]; System.arraycopy( settable, loc, subsettable, 0, len ); propertyTypes[i].nullSafeSet( st, subvalues[i], begin, subsettable, session ); begin += ArrayHelper.countTrue( subsettable ); } loc += len; } }
Example #30
Source File: AbstractEntityPersister.java From lams with GNU General Public License v2.0 | 5 votes |
/** * Warning: * When there are duplicated property names in the subclasses * of the class, this method may return the wrong table * number for the duplicated subclass property (note that * SingleTableEntityPersister defines an overloaded form * which takes the entity name. */ public int getSubclassPropertyTableNumber(String propertyPath) { String rootPropertyName = StringHelper.root( propertyPath ); Type type = propertyMapping.toType( rootPropertyName ); if ( type.isAssociationType() ) { AssociationType assocType = (AssociationType) type; if ( assocType.useLHSPrimaryKey() ) { // performance op to avoid the array search return 0; } else if ( type.isCollectionType() ) { // properly handle property-ref-based associations rootPropertyName = assocType.getLHSPropertyName(); } } //Enable for HHH-440, which we don't like: /*if ( type.isComponentType() && !propertyName.equals(rootPropertyName) ) { String unrooted = StringHelper.unroot(propertyName); int idx = ArrayHelper.indexOf( getSubclassColumnClosure(), unrooted ); if ( idx != -1 ) { return getSubclassColumnTableNumberClosure()[idx]; } }*/ int index = ArrayHelper.indexOf( getSubclassPropertyNameClosure(), rootPropertyName ); //TODO: optimize this better! return index == -1 ? 0 : getSubclassPropertyTableNumber( index ); }