Java Code Examples for org.hibernate.dialect.Dialect#supportsRowValueConstructorSyntaxInInList()

The following examples show how to use org.hibernate.dialect.Dialect#supportsRowValueConstructorSyntaxInInList() . 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: InlineIdsSubSelectValuesListUpdateHandlerImpl.java    From lams with GNU General Public License v2.0 6 votes vote down vote up
public InlineIdsSubSelectValuesListUpdateHandlerImpl(
		SessionFactoryImplementor factory,
		HqlSqlWalker walker) {
	super( factory, walker );

	Dialect dialect = factory().getServiceRegistry().getService( JdbcServices.class ).getDialect();
	if ( !dialect.supportsRowValueConstructorSyntaxInInList() ) {
		throw new UnsupportedOperationException(
				"The " + getClass().getSimpleName() +
						" can only be used with Dialects that support IN clause row-value expressions (for composite identifiers)!"
		);
	}
	if ( !dialect.supportsValuesList() ) {
		throw new UnsupportedOperationException(
				"The " + getClass().getSimpleName() +
						" can only be used with Dialects that support VALUES lists!"
		);
	}
}
 
Example 2
Source File: InlineIdsSubSelectValuesListDeleteHandlerImpl.java    From lams with GNU General Public License v2.0 6 votes vote down vote up
public InlineIdsSubSelectValuesListDeleteHandlerImpl(
		SessionFactoryImplementor factory,
		HqlSqlWalker walker) {
	super( factory, walker );

	Dialect dialect = factory().getServiceRegistry().getService( JdbcServices.class ).getDialect();
	if ( !dialect.supportsRowValueConstructorSyntaxInInList() ) {
		throw new UnsupportedOperationException(
				"The " + getClass().getSimpleName() +
						" can only be used with Dialects that support IN clause row-value expressions (for composite identifiers)!"
		);
	}
	if ( !dialect.supportsValuesList() ) {
		throw new UnsupportedOperationException(
				"The " + getClass().getSimpleName() +
						" can only be used with Dialects that support VALUES lists!"
		);
	}
}
 
Example 3
Source File: ReactiveDynamicBatchingEntityLoader.java    From hibernate-reactive with GNU Lesser General Public License v2.1 5 votes vote down vote up
static String expandBatchIdPlaceholder(
		String sql,
		Serializable[] ids,
		String alias,
		String[] keyColumnNames,
		Dialect dialect) {
	if ( keyColumnNames.length == 1 ) {
		// non-composite
		return StringHelper.replace( sql, StringHelper.BATCH_ID_PLACEHOLDER, StringHelper.repeat( "?", ids.length, "," ) );
	}
	else {
		// composite
		if ( dialect.supportsRowValueConstructorSyntaxInInList() ) {
			final String tuple = '(' + StringHelper.repeat( "?", keyColumnNames.length, "," ) + ')';
			return StringHelper.replace( sql, StringHelper.BATCH_ID_PLACEHOLDER, StringHelper.repeat( tuple, ids.length, "," ) );
		}
		else {
			final String keyCheck = '(' + StringHelper.joinWithQualifierAndSuffix(
					keyColumnNames,
					alias,
					" = ?",
					" and "
			) + ')';
			return StringHelper.replace( sql, StringHelper.BATCH_ID_PLACEHOLDER, StringHelper.repeat( keyCheck, ids.length, " or " ) );
		}
	}
}
 
Example 4
Source File: StringHelper.java    From lams with GNU General Public License v2.0 5 votes vote down vote up
public static StringBuilder buildBatchFetchRestrictionFragment(
		String alias,
		String[] columnNames,
		Dialect dialect) {
	// the general idea here is to just insert a placeholder that we can easily find later...
	if ( columnNames.length == 1 ) {
		// non-composite key
		return new StringBuilder( StringHelper.qualify( alias, columnNames[0] ) )
				.append( " in (" ).append( BATCH_ID_PLACEHOLDER ).append( ")" );
	}
	else {
		// composite key - the form to use here depends on what the dialect supports.
		if ( dialect.supportsRowValueConstructorSyntaxInInList() ) {
			// use : (col1, col2) in ( (?,?), (?,?), ... )
			StringBuilder builder = new StringBuilder();
			builder.append( "(" );
			boolean firstPass = true;
			String deliminator = "";
			for ( String columnName : columnNames ) {
				builder.append( deliminator ).append( StringHelper.qualify( alias, columnName ) );
				if ( firstPass ) {
					firstPass = false;
					deliminator = ",";
				}
			}
			builder.append( ") in (" );
			builder.append( BATCH_ID_PLACEHOLDER );
			builder.append( ")" );
			return builder;
		}
		else {
			// use : ( (col1 = ? and col2 = ?) or (col1 = ? and col2 = ?) or ... )
			//		unfortunately most of this building needs to be held off until we know
			//		the exact number of ids :(
			return new StringBuilder( "(" ).append( BATCH_ID_PLACEHOLDER ).append( ")" );
		}
	}
}
 
Example 5
Source File: StringHelper.java    From lams with GNU General Public License v2.0 5 votes vote down vote up
public static String expandBatchIdPlaceholder(
		String sql,
		Serializable[] ids,
		String alias,
		String[] keyColumnNames,
		Dialect dialect) {
	if ( keyColumnNames.length == 1 ) {
		// non-composite
		return StringHelper.replace( sql, BATCH_ID_PLACEHOLDER, repeat( "?", ids.length, "," ) );
	}
	else {
		// composite
		if ( dialect.supportsRowValueConstructorSyntaxInInList() ) {
			final String tuple = "(" + StringHelper.repeat( "?", keyColumnNames.length, "," ) + ")";
			return StringHelper.replace( sql, BATCH_ID_PLACEHOLDER, repeat( tuple, ids.length, "," ) );
		}
		else {
			final String keyCheck = "(" + joinWithQualifierAndSuffix(
					keyColumnNames,
					alias,
					" = ?",
					" and "
			) + ")";
			return replace( sql, BATCH_ID_PLACEHOLDER, repeat( keyCheck, ids.length, " or " ) );
		}
	}
}
 
Example 6
Source File: AbstractCteValuesListBulkIdHandler.java    From lams with GNU General Public License v2.0 5 votes vote down vote up
public AbstractCteValuesListBulkIdHandler(
		SessionFactoryImplementor sessionFactory, HqlSqlWalker walker,
		String catalog, String schema) {
	super( sessionFactory, walker );
	Dialect dialect = sessionFactory.getServiceRegistry().getService( JdbcServices.class ).getDialect();
	if ( !dialect.supportsNonQueryWithCTE() ) {
		throw new UnsupportedOperationException(
				"The " + getClass().getSimpleName() +
						" can only be used with Dialects that support CTE that can take UPDATE or DELETE statements as well!"
		);
	}
	if ( !dialect.supportsValuesList() ) {
		throw new UnsupportedOperationException(
				"The " + getClass().getSimpleName() +
						" can only be used with Dialects that support VALUES lists!"
		);
	}
	if ( !dialect.supportsRowValueConstructorSyntaxInInList() ) {
		throw new UnsupportedOperationException(
				"The " + getClass().getSimpleName() +
						" can only be used with Dialects that support IN clause row-value expressions (for composite identifiers)!"
		);
	}

	this.jdbcEnvironment = sessionFactory.getServiceRegistry().getService(
			JdbcServices.class ).getJdbcEnvironment();
	this.catalog = catalog;
	this.schema = schema;
}
 
Example 7
Source File: InlineIdsInClauseUpdateHandlerImpl.java    From lams with GNU General Public License v2.0 5 votes vote down vote up
public InlineIdsInClauseUpdateHandlerImpl(
		SessionFactoryImplementor factory,
		HqlSqlWalker walker) {
	super( factory, walker );
	Dialect dialect = factory.getServiceRegistry().getService( JdbcServices.class ).getDialect();
	if ( !dialect.supportsRowValueConstructorSyntaxInInList() ) {
		throw new UnsupportedOperationException(
				"The " + getClass().getSimpleName() +
						" can only be used with Dialects that support IN clause row-value expressions (for composite identifiers)!"
		);
	}
}
 
Example 8
Source File: InlineIdsIdsInClauseDeleteHandlerImpl.java    From lams with GNU General Public License v2.0 5 votes vote down vote up
public InlineIdsIdsInClauseDeleteHandlerImpl(
		SessionFactoryImplementor factory,
		HqlSqlWalker walker) {
	super( factory, walker );
	Dialect dialect = factory.getServiceRegistry().getService( JdbcServices.class ).getDialect();
	if ( !dialect.supportsRowValueConstructorSyntaxInInList() ) {
		throw new UnsupportedOperationException(
				"The " + getClass().getSimpleName() +
						" can only be used with Dialects that support IN clause row-value expressions (for composite identifiers)!"
		);
	}
}
 
Example 9
Source File: ReactiveDynamicBatchingEntityLoader.java    From hibernate-reactive with GNU Lesser General Public License v2.1 4 votes vote down vote up
private static StringBuilder buildBatchFetchRestrictionFragment(
		String alias,
		String[] columnNames,
		Dialect dialect) {
	// the general idea here is to just insert a placeholder that we can easily find later...
	if ( columnNames.length == 1 ) {
		// non-composite key
		return new StringBuilder( StringHelper.qualify( alias, columnNames[0] ) )
				.append( " in (" ).append( StringHelper.BATCH_ID_PLACEHOLDER ).append( ')' );
	}
	else {
		// composite key - the form to use here depends on what the dialect supports.
		if ( dialect.supportsRowValueConstructorSyntaxInInList() ) {
			// use : (col1, col2) in ( (?,?), (?,?), ... )
			StringBuilder builder = new StringBuilder();
			builder.append( '(' );
			boolean firstPass = true;
			String deliminator = "";
			for ( String columnName : columnNames ) {
				builder.append( deliminator ).append( StringHelper.qualify( alias, columnName ) );
				if ( firstPass ) {
					firstPass = false;
					deliminator = ",";
				}
			}
			builder.append( ") in (" );
			builder.append( StringHelper.BATCH_ID_PLACEHOLDER );
			builder.append( ')' );
			return builder;
		}
		else {
			// use : ( (col1 = ? and col2 = ?) or (col1 = ? and col2 = ?) or ... )
			//		unfortunately most of this building needs to be held off until we know
			//		the exact number of ids :(
			final StringBuilder stringBuilder = new StringBuilder();
			stringBuilder.append( '(' )
					.append( StringHelper.BATCH_ID_PLACEHOLDER )
					.append( ')' );
			return stringBuilder;
		}
	}
}