Java Code Examples for org.hibernate.sql.SimpleSelect#toStatementString()

The following examples show how to use org.hibernate.sql.SimpleSelect#toStatementString() . 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: ReactiveAbstractEntityPersister.java    From hibernate-reactive with GNU Lesser General Public License v2.1 6 votes vote down vote up
default String generateSelectLockString(LockOptions lockOptions) {
	final SessionFactoryImplementor factory = getFactory();
	Dialect dialect = factory.getJdbcServices().getDialect();
	final SimpleSelect select = new SimpleSelect(dialect)
			.setLockOptions( lockOptions )
			.setTableName( getRootTableName() )
			.addColumn( getRootTableIdentifierColumnNames()[0] )
			.addCondition( getRootTableIdentifierColumnNames(), "=?" );
	if ( isVersioned() ) {
		select.addCondition( getVersionColumnName(), "=?" );
	}
	if ( factory.getSessionFactoryOptions().isCommentsEnabled() ) {
		select.setComment( lockOptions.getLockMode() + " lock " + getEntityName() );
	}
	return select.toStatementString();
}
 
Example 2
Source File: PessimisticWriteSelectLockingStrategy.java    From lams with GNU General Public License v2.0 6 votes vote down vote up
protected String generateLockString(int lockTimeout) {
	final SessionFactoryImplementor factory = getLockable().getFactory();
	final LockOptions lockOptions = new LockOptions( getLockMode() );
	lockOptions.setTimeOut( lockTimeout );
	final SimpleSelect select = new SimpleSelect( factory.getDialect() )
			.setLockOptions( lockOptions )
			.setTableName( getLockable().getRootTableName() )
			.addColumn( getLockable().getRootTableIdentifierColumnNames()[0] )
			.addCondition( getLockable().getRootTableIdentifierColumnNames(), "=?" );
	if ( getLockable().isVersioned() ) {
		select.addCondition( getLockable().getVersionColumnName(), "=?" );
	}
	if ( factory.getSessionFactoryOptions().isCommentsEnabled() ) {
		select.setComment( getLockMode() + " lock " + getLockable().getEntityName() );
	}
	return select.toStatementString();
}
 
Example 3
Source File: SelectLockingStrategy.java    From lams with GNU General Public License v2.0 6 votes vote down vote up
protected String generateLockString(int timeout) {
	final SessionFactoryImplementor factory = getLockable().getFactory();
	final LockOptions lockOptions = new LockOptions( getLockMode() );
	lockOptions.setTimeOut( timeout );
	final SimpleSelect select = new SimpleSelect( factory.getDialect() )
			.setLockOptions( lockOptions )
			.setTableName( getLockable().getRootTableName() )
			.addColumn( getLockable().getRootTableIdentifierColumnNames()[0] )
			.addCondition( getLockable().getRootTableIdentifierColumnNames(), "=?" );
	if ( getLockable().isVersioned() ) {
		select.addCondition( getLockable().getVersionColumnName(), "=?" );
	}
	if ( factory.getSessionFactoryOptions().isCommentsEnabled() ) {
		select.setComment( getLockMode() + " lock " + getLockable().getEntityName() );
	}
	return select.toStatementString();
}
 
Example 4
Source File: PessimisticReadSelectLockingStrategy.java    From lams with GNU General Public License v2.0 6 votes vote down vote up
protected String generateLockString(int lockTimeout) {
	final SessionFactoryImplementor factory = getLockable().getFactory();
	final LockOptions lockOptions = new LockOptions( getLockMode() );
	lockOptions.setTimeOut( lockTimeout );
	final SimpleSelect select = new SimpleSelect( factory.getDialect() )
			.setLockOptions( lockOptions )
			.setTableName( getLockable().getRootTableName() )
			.addColumn( getLockable().getRootTableIdentifierColumnNames()[0] )
			.addCondition( getLockable().getRootTableIdentifierColumnNames(), "=?" );
	if ( getLockable().isVersioned() ) {
		select.addCondition( getLockable().getVersionColumnName(), "=?" );
	}
	if ( factory.getSessionFactoryOptions().isCommentsEnabled() ) {
		select.setComment( getLockMode() + " lock " + getLockable().getEntityName() );
	}
	return select.toStatementString();
}
 
Example 5
Source File: SelectLockingStrategy.java    From cacheonix-core with GNU Lesser General Public License v2.1 5 votes vote down vote up
protected String generateLockString() {
	SessionFactoryImplementor factory = lockable.getFactory();
	SimpleSelect select = new SimpleSelect( factory.getDialect() )
			.setLockMode( lockMode )
			.setTableName( lockable.getRootTableName() )
			.addColumn( lockable.getRootTableIdentifierColumnNames()[0] )
			.addCondition( lockable.getRootTableIdentifierColumnNames(), "=?" );
	if ( lockable.isVersioned() ) {
		select.addCondition( lockable.getVersionColumnName(), "=?" );
	}
	if ( factory.getSettings().isCommentsEnabled() ) {
		select.setComment( lockMode + " lock " + lockable.getEntityName() );
	}
	return select.toStatementString();
}