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

The following examples show how to use org.hibernate.sql.SimpleSelect#addColumn() . 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 5 votes vote down vote up
/**
 * Generate the SQL that selects the version number by id
 */
protected String generateSelectVersionString() {
	SimpleSelect select = new SimpleSelect( getFactory().getDialect() )
			.setTableName( getVersionedTableName() );
	if ( isVersioned() ) {
		select.addColumn( versionColumnName );
	}
	else {
		select.addColumns( rootTableKeyColumnNames );
	}
	if ( getFactory().getSessionFactoryOptions().isCommentsEnabled() ) {
		select.setComment( "get version " + getEntityName() );
	}
	return select.addCondition( rootTableKeyColumnNames, "=?" ).toStatementString();
}
 
Example 2
Source File: UnionSubclassEntityPersister.java    From lams with GNU General Public License v2.0 5 votes vote down vote up
/**
 * Generate the SQL that selects a row by id
 */
protected String generateSelectString(LockMode lockMode) {
	SimpleSelect select = new SimpleSelect( getFactory().getDialect() )
			.setLockMode( lockMode )
			.setTableName( getTableName() )
			.addColumns( getIdentifierColumnNames() )
			.addColumns(
					getSubclassColumnClosure(),
					getSubclassColumnAliasClosure(),
					getSubclassColumnLazyiness()
			)
			.addColumns(
					getSubclassFormulaClosure(),
					getSubclassFormulaAliasClosure(),
					getSubclassFormulaLazyiness()
			);
	//TODO: include the rowids!!!!
	if ( hasSubclasses() ) {
		if ( isDiscriminatorFormula() ) {
			select.addColumn( getDiscriminatorFormula(), getDiscriminatorAlias() );
		}
		else {
			select.addColumn( getDiscriminatorColumnName(), getDiscriminatorAlias() );
		}
	}
	if ( getFactory().getSettings().isCommentsEnabled() ) {
		select.setComment( "load " + getEntityName() );
	}
	return select.addCondition( getIdentifierColumnNames(), "=?" ).toStatementString();
}
 
Example 3
Source File: AbstractEntityPersister.java    From cacheonix-core with GNU Lesser General Public License v2.1 5 votes vote down vote up
/**
 * Generate the SQL that selects the version number by id
 */
protected String generateSelectVersionString() {
	SimpleSelect select = new SimpleSelect( getFactory().getDialect() )
			.setTableName( getVersionedTableName() );
	if ( isVersioned() ) {
		select.addColumn( versionColumnName );
	}
	else {
		select.addColumns( rootTableKeyColumnNames );
	}
	if ( getFactory().getSettings().isCommentsEnabled() ) {
		select.setComment( "get version " + getEntityName() );
	}
	return select.addCondition( rootTableKeyColumnNames, "=?" ).toStatementString();
}
 
Example 4
Source File: UnionSubclassEntityPersister.java    From cacheonix-core with GNU Lesser General Public License v2.1 5 votes vote down vote up
/**
 * Generate the SQL that selects a row by id
 */
protected String generateSelectString(LockMode lockMode) {
	SimpleSelect select = new SimpleSelect( getFactory().getDialect() )
		.setLockMode(lockMode)
		.setTableName( getTableName() )
		.addColumns( getIdentifierColumnNames() )
		.addColumns( 
				getSubclassColumnClosure(), 
				getSubclassColumnAliasClosure(),
				getSubclassColumnLazyiness()
		)
		.addColumns( 
				getSubclassFormulaClosure(), 
				getSubclassFormulaAliasClosure(),
				getSubclassFormulaLazyiness()
		);
	//TODO: include the rowids!!!!
	if ( hasSubclasses() ) {
		if ( isDiscriminatorFormula() ) {
			select.addColumn( getDiscriminatorFormula(), getDiscriminatorAlias() );
		}
		else {
			select.addColumn( getDiscriminatorColumnName(), getDiscriminatorAlias() );
		}
	}
	if ( getFactory().getSettings().isCommentsEnabled() ) {
		select.setComment( "load " + getEntityName() );
	}
	return select.addCondition( getIdentifierColumnNames(), "=?" ).toStatementString();
}