Java Code Examples for org.hibernate.mapping.Table#qualify()

The following examples show how to use org.hibernate.mapping.Table#qualify() . 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: Mappings.java    From cacheonix-core with GNU Lesser General Public License v2.1 6 votes vote down vote up
public Table addDenormalizedTable(
		String schema, 
		String catalog, 
		String name,
		boolean isAbstract, 
		String subselect,
		Table includedTable)
throws MappingException {
       String key = subselect==null ?
       		Table.qualify(catalog, schema, name) :
       		subselect;
	if ( tables.containsKey(key) ) {
		throw new DuplicateMappingException("table", name);
	}
	
	Table table = new DenormalizedTable(includedTable);
	table.setAbstract(isAbstract);
	table.setName(name);
	table.setSchema(schema);
	table.setCatalog(catalog);
	table.setSubselect(subselect);
	tables.put(key, table);
	return table;
}
 
Example 2
Source File: TableGenerator.java    From cacheonix-core with GNU Lesser General Public License v2.1 6 votes vote down vote up
public void configure(Type type, Properties params, Dialect dialect) {

		tableName = PropertiesHelper.getString(TABLE, params, DEFAULT_TABLE_NAME);
		columnName = PropertiesHelper.getString(COLUMN, params, DEFAULT_COLUMN_NAME);
		String schemaName = params.getProperty(SCHEMA);
		String catalogName = params.getProperty(CATALOG);

		if ( tableName.indexOf( '.' )<0 ) {
			tableName = Table.qualify( catalogName, schemaName, tableName );
		}

		query = "select " + 
			columnName + 
			" from " + 
			dialect.appendLockHint(LockMode.UPGRADE, tableName) +
			dialect.getForUpdateString();

		update = "update " + 
			tableName + 
			" set " + 
			columnName + 
			" = ? where " + 
			columnName + 
			" = ?";
	}
 
Example 3
Source File: SequenceStyleGenerator.java    From cacheonix-core with GNU Lesser General Public License v2.1 5 votes vote down vote up
public void configure(Type type, Properties params, Dialect dialect) throws MappingException {
	identifierType = type;
	boolean forceTableUse = PropertiesHelper.getBoolean( FORCE_TBL_PARAM, params, false );

	String sequenceName = PropertiesHelper.getString( SEQUENCE_PARAM, params, DEF_SEQUENCE_NAME );
	if ( sequenceName.indexOf( '.' ) < 0 ) {
		String schemaName = params.getProperty( SCHEMA );
		String catalogName = params.getProperty( CATALOG );
		sequenceName = Table.qualify( catalogName, schemaName, sequenceName );
	}
	int initialValue = PropertiesHelper.getInt( INITIAL_PARAM, params, DEFAULT_INITIAL_VALUE );
	int incrementSize = PropertiesHelper.getInt( INCREMENT_PARAM, params, DEFAULT_INCREMENT_SIZE );

	String valueColumnName = PropertiesHelper.getString( VALUE_COLUMN_PARAM, params, DEF_VALUE_COLUMN );

	String defOptStrategy = incrementSize <= 1 ? OptimizerFactory.NONE : OptimizerFactory.POOL;
	String optimizationStrategy = PropertiesHelper.getString( OPT_PARAM, params, defOptStrategy );
	if ( OptimizerFactory.NONE.equals( optimizationStrategy ) && incrementSize > 1 ) {
		log.warn( "config specified explicit optimizer of [" + OptimizerFactory.NONE + "], but [" + INCREMENT_PARAM + "=" + incrementSize + "; honoring optimizer setting" );
		incrementSize = 1;
	}
	if ( dialect.supportsSequences() && !forceTableUse ) {
		if ( OptimizerFactory.POOL.equals( optimizationStrategy ) && !dialect.supportsPooledSequences() ) {
			// TODO : may even be better to fall back to a pooled table strategy here so that the db stored values remain consistent...
			optimizationStrategy = OptimizerFactory.HILO;
		}
		databaseStructure = new SequenceStructure( dialect, sequenceName, initialValue, incrementSize );
	}
	else {
		databaseStructure = new TableStructure( dialect, sequenceName, valueColumnName, initialValue, incrementSize );
	}

	optimizer = OptimizerFactory.buildOptimizer( optimizationStrategy, identifierType.getReturnedClass(), incrementSize );
	databaseStructure.prepare( optimizer );
}
 
Example 4
Source File: TableGenerator.java    From cacheonix-core with GNU Lesser General Public License v2.1 5 votes vote down vote up
public void configure(Type type, Properties params, Dialect dialect) throws MappingException {
	tableName = PropertiesHelper.getString( TABLE_PARAM, params, DEF_TABLE );
	if ( tableName.indexOf( '.' ) < 0 ) {
		String schemaName = params.getProperty( SCHEMA );
		String catalogName = params.getProperty( CATALOG );
		tableName = Table.qualify( catalogName, schemaName, tableName );
	}

	segmentColumnName = PropertiesHelper.getString( SEGMENT_COLUMN_PARAM, params, DEF_SEGMENT_COLUMN );
	segmentValue = params.getProperty( SEGMENT_VALUE_PARAM );
	if ( StringHelper.isEmpty( segmentValue ) ) {
		log.debug( "explicit segment value for id generator [" + tableName + '.' + segmentColumnName + "] suggested; using default [" + DEF_SEGMENT_VALUE + "]" );
		segmentValue = DEF_SEGMENT_VALUE;
	}
	segmentValueLength = PropertiesHelper.getInt( SEGMENT_LENGTH_PARAM, params, DEF_SEGMENT_LENGTH );
	valueColumnName = PropertiesHelper.getString( VALUE_COLUMN_PARAM, params, DEF_VALUE_COLUMN );
	initialValue = PropertiesHelper.getInt( INITIAL_PARAM, params, DEFAULT_INITIAL_VALUE );
	incrementSize = PropertiesHelper.getInt( INCREMENT_PARAM, params, DEFAULT_INCREMENT_SIZE );
	identifierType = type;

	String query = "select " + valueColumnName +
			" from " + tableName + " tbl" +
			" where tbl." + segmentColumnName + "=?";
	HashMap lockMap = new HashMap();
	lockMap.put( "tbl", LockMode.UPGRADE );
	this.query = dialect.applyLocksToSql( query, lockMap, CollectionHelper.EMPTY_MAP );

	update = "update " + tableName +
			" set " + valueColumnName + "=? " +
			" where " + valueColumnName + "=? and " + segmentColumnName + "=?";

	insert = "insert into " + tableName + " (" + segmentColumnName + ", " + valueColumnName + ") " + " values (?,?)";

	String defOptStrategy = incrementSize <= 1 ? OptimizerFactory.NONE : OptimizerFactory.POOL;
	String optimizationStrategy = PropertiesHelper.getString( OPT_PARAM, params, defOptStrategy );
	optimizer = OptimizerFactory.buildOptimizer( optimizationStrategy, identifierType.getReturnedClass(), incrementSize );
}
 
Example 5
Source File: SequenceGenerator.java    From cacheonix-core with GNU Lesser General Public License v2.1 5 votes vote down vote up
public void configure(Type type, Properties params, Dialect dialect) throws MappingException {
	sequenceName = PropertiesHelper.getString(SEQUENCE, params, "hibernate_sequence");
	parameters = params.getProperty(PARAMETERS);
	String schemaName = params.getProperty(SCHEMA);
	String catalogName = params.getProperty(CATALOG);

	if (sequenceName.indexOf( '.' ) < 0) {
		sequenceName = Table.qualify( catalogName, schemaName, sequenceName );
	}

	this.identifierType = type;
	sql = dialect.getSequenceNextValString(sequenceName);
}
 
Example 6
Source File: Mappings.java    From cacheonix-core with GNU Lesser General Public License v2.1 4 votes vote down vote up
public Table getTable(String schema, String catalog, String name) {
       String key = Table.qualify(catalog, schema, name);
	return (Table) tables.get(key);
}
 
Example 7
Source File: DatabaseMetadata.java    From cacheonix-core with GNU Lesser General Public License v2.1 4 votes vote down vote up
private Object identifier(String catalog, String schema, String name) {
	return Table.qualify(catalog,schema,name);
}
 
Example 8
Source File: MultipleHiLoPerTableGenerator.java    From cacheonix-core with GNU Lesser General Public License v2.1 4 votes vote down vote up
public void configure(Type type, Properties params, Dialect dialect) throws MappingException {
	tableName = PropertiesHelper.getString(ID_TABLE, params, DEFAULT_TABLE);
	pkColumnName = PropertiesHelper.getString(PK_COLUMN_NAME, params, DEFAULT_PK_COLUMN);
	valueColumnName = PropertiesHelper.getString(VALUE_COLUMN_NAME, params, DEFAULT_VALUE_COLUMN);
	String schemaName = params.getProperty(SCHEMA);
	String catalogName = params.getProperty(CATALOG);
	keySize = PropertiesHelper.getInt(PK_LENGTH_NAME, params, DEFAULT_PK_LENGTH);
	String keyValue = PropertiesHelper.getString(PK_VALUE_NAME, params, params.getProperty(TABLE) );

	if ( tableName.indexOf( '.' )<0 ) {
		tableName = Table.qualify( catalogName, schemaName, tableName );
	}

	query = "select " +
		valueColumnName +
		" from " +
		dialect.appendLockHint(LockMode.UPGRADE, tableName) +
		" where " + pkColumnName + " = '" + keyValue + "'" +
		dialect.getForUpdateString();

	update = "update " +
		tableName +
		" set " +
		valueColumnName +
		" = ? where " +
		valueColumnName +
		" = ? and " +
		pkColumnName +
		" = '" + 
		keyValue 
		+ "'";
	
	insert = "insert into " + tableName +
		"(" + pkColumnName + ", " +	valueColumnName + ") " +
		"values('"+ keyValue +"', ?)";


	//hilo config
	maxLo = PropertiesHelper.getInt(MAX_LO, params, Short.MAX_VALUE);
	lo = maxLo + 1; // so we "clock over" on the first invocation
	returnClass = type.getReturnedClass();
}