下面列出了org.hibernate.internal.util.collections.ArrayHelper#join ( ) 实例代码,或者点击链接到github查看源代码,也可以在右侧发表评论。
/**
* Generate the SQL UPDATE that updates a particular row's foreign
* key to null
*/
@Override
protected String generateDeleteRowString() {
final Update update = new Update( getDialect() )
.setTableName( qualifiedTableName )
.addColumns( keyColumnNames, "null" );
if ( hasIndex && !indexContainsFormula ) {
for ( int i = 0 ; i < indexColumnNames.length ; i++ ) {
if ( indexColumnIsSettable[i] ) {
update.addColumn( indexColumnNames[i], "null" );
}
}
}
if ( getFactory().getSessionFactoryOptions().isCommentsEnabled() ) {
update.setComment( "delete one-to-many row " + getRole() );
}
//use a combination of foreign key columns and pk columns, since
//the ordering of removal and addition is not guaranteed when
//a child moves from one parent to another
String[] rowSelectColumnNames = ArrayHelper.join( keyColumnNames, elementColumnNames );
return update.addPrimaryKeyColumns( rowSelectColumnNames )
.toStatementString();
}
public CollectionElementLoader(
QueryableCollection collectionPersister,
SessionFactoryImplementor factory,
LoadQueryInfluencers loadQueryInfluencers) throws MappingException {
super( factory, loadQueryInfluencers );
this.keyType = collectionPersister.getKeyType();
this.indexType = collectionPersister.getIndexType();
this.persister = (OuterJoinLoadable) collectionPersister.getElementPersister();
this.entityName = persister.getEntityName();
JoinWalker walker = new EntityJoinWalker(
persister,
ArrayHelper.join(
collectionPersister.getKeyColumnNames(),
collectionPersister.toColumns( "index" )
),
1,
LockMode.NONE,
factory,
loadQueryInfluencers
);
initFromWalker( walker );
postInstantiate();
if ( LOG.isDebugEnabled() ) {
LOG.debugf( "Static select for entity %s: %s", entityName, getSQLString() );
}
}
@Override
public void registerCallbacks(Class entityClass, Callback[] callbacks) {
if ( callbacks == null || callbacks.length == 0 ) {
return;
}
final HashMap<Class, Callback[]> map = determineAppropriateCallbackMap( callbacks[0].getCallbackType() );
Callback[] entityCallbacks = map.get( entityClass );
if ( entityCallbacks != null ) {
callbacks = ArrayHelper.join( entityCallbacks, callbacks );
}
map.put( entityClass, callbacks );
}
@Override
public int[] sqlTypes(Mapping mapping) throws MappingException {
return ArrayHelper.join( discriminatorType.sqlTypes( mapping ), identifierType.sqlTypes( mapping ) );
}
@Override
public Size[] dictatedSizes(Mapping mapping) throws MappingException {
return ArrayHelper.join( discriminatorType.dictatedSizes( mapping ), identifierType.dictatedSizes( mapping ) );
}
@Override
public Size[] defaultSizes(Mapping mapping) throws MappingException {
return ArrayHelper.join( discriminatorType.defaultSizes( mapping ), identifierType.defaultSizes( mapping ) );
}