Java Code Examples for org.hibernate.internal.util.collections.ArrayHelper#isAllFalse()

The following examples show how to use org.hibernate.internal.util.collections.ArrayHelper#isAllFalse() . 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: AbstractEntityPersister.java    From lams with GNU General Public License v2.0 6 votes vote down vote up
private String determinePkByNaturalIdQuery(boolean[] valueNullness) {
	if ( !hasNaturalIdentifier() ) {
		throw new HibernateException(
				"Attempt to build natural-id -> PK resolution query for entity that does not define natural id"
		);
	}

	// performance shortcut for cases where the natural-id is defined as completely non-nullable
	if ( isNaturalIdNonNullable() ) {
		if ( valueNullness != null && !ArrayHelper.isAllFalse( valueNullness ) ) {
			throw new HibernateException( "Null value(s) passed to lookup by non-nullable natural-id" );
		}
		if ( cachedPkByNonNullableNaturalIdQuery == null ) {
			cachedPkByNonNullableNaturalIdQuery = generateEntityIdByNaturalIdSql( null );
		}
		return cachedPkByNonNullableNaturalIdQuery;
	}

	// Otherwise, regenerate it each time
	return generateEntityIdByNaturalIdSql( valueNullness );
}
 
Example 2
Source File: Property.java    From lams with GNU General Public License v2.0 5 votes vote down vote up
public boolean isInsertable() {
	// if the property mapping consists of all formulas, 
	// make it non-insertable
	final boolean[] columnInsertability = value.getColumnInsertability();
	return insertable && (
			columnInsertability.length==0 ||
			!ArrayHelper.isAllFalse( columnInsertability )
		);
}
 
Example 3
Source File: Property.java    From lams with GNU General Public License v2.0 4 votes vote down vote up
public boolean isUpdateable() {
	// if the property mapping consists of all formulas,
	// make it non-updateable
	return updateable && !ArrayHelper.isAllFalse( value.getColumnUpdateability() );
}
 
Example 4
Source File: BasicCollectionPersister.java    From lams with GNU General Public License v2.0 4 votes vote down vote up
@Override
protected int doUpdateRows(Serializable id, PersistentCollection collection, SharedSessionContractImplementor session)
		throws HibernateException {
	if ( ArrayHelper.isAllFalse( elementColumnIsSettable ) ) {
		return 0;
	}

	try {
		final Expectation expectation = Expectations.appropriateExpectation( getUpdateCheckStyle() );
		final boolean callable = isUpdateCallable();
		final int jdbcBatchSizeToUse = session.getConfiguredJdbcBatchSize();
		boolean useBatch = expectation.canBeBatched() && jdbcBatchSizeToUse > 1;
		final Iterator entries = collection.entries( this );

		final List elements = new ArrayList();
		while ( entries.hasNext() ) {
			elements.add( entries.next() );
		}

		final String sql = getSQLUpdateRowString();
		int count = 0;
		if ( collection.isElementRemoved() ) {
			// the update should be done starting from the end to the list
			for ( int i = elements.size() - 1; i >= 0; i-- ) {
				count = doUpdateRow(
						id,
						collection,
						session,
						expectation,
						callable,
						useBatch,
						elements,
						sql,
						count,
						i
				);
			}
		}
		else {
			for ( int i = 0; i < elements.size(); i++ ) {
				count = doUpdateRow(
						id,
						collection,
						session,
						expectation,
						callable,
						useBatch,
						elements,
						sql,
						count,
						i
				);
			}
		}
		return count;
	}
	catch (SQLException sqle) {
		throw session.getJdbcServices().getSqlExceptionHelper().convert(
				sqle,
				"could not update collection rows: " + MessageHelper.collectionInfoString(
						this,
						collection,
						id,
						session
				),
				getSQLUpdateRowString()
		);
	}
}