本文整理汇总了Java中org.hibernate.type.CollectionType.getAssociatedEntityName方法的典型用法代码示例。如果您正苦于以下问题:Java CollectionType.getAssociatedEntityName方法的具体用法?Java CollectionType.getAssociatedEntityName怎么用?Java CollectionType.getAssociatedEntityName使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类org.hibernate.type.CollectionType
的用法示例。
在下文中一共展示了CollectionType.getAssociatedEntityName方法的4个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: getChildCollection
import org.hibernate.type.CollectionType; //导入方法依赖的package包/类
@Override
public EntityCollection getChildCollection(String name) throws LayerException {
Type type = metadata.getPropertyType(name);
if (type instanceof CollectionType) {
CollectionType ct = (CollectionType) type;
Collection coll = (Collection) metadata.getPropertyValue(object, name, EntityMode.POJO);
if (coll == null) {
// normally should not happen, hibernate instantiates it automatically
coll = (Collection) ct.instantiate(0);
metadata.setPropertyValue(object, name, coll, EntityMode.POJO);
}
String entityName = ct.getAssociatedEntityName((SessionFactoryImplementor) sessionFactory);
ClassMetadata childMetadata = sessionFactory.getClassMetadata(entityName);
return new HibernateEntityCollection(metadata, childMetadata, object, coll);
} else {
throw new LayerException(ExceptionCode.FEATURE_MODEL_PROBLEM);
}
}
示例2: cascadeCollectionElements
import org.hibernate.type.CollectionType; //导入方法依赖的package包/类
/**
* Cascade to the collection elements
*/
private void cascadeCollectionElements(
final Object child,
final CollectionType collectionType,
final CascadeStyle style,
final Type elemType,
final Object anything,
final boolean isCascadeDeleteEnabled) throws HibernateException {
// we can't cascade to non-embedded elements
boolean embeddedElements = eventSource.getEntityMode()!=EntityMode.DOM4J ||
( (EntityType) collectionType.getElementType( eventSource.getFactory() ) ).isEmbeddedInXML();
boolean reallyDoCascade = style.reallyDoCascade(action) &&
embeddedElements && child!=CollectionType.UNFETCHED_COLLECTION;
if ( reallyDoCascade ) {
if ( log.isTraceEnabled() ) {
log.trace( "cascade " + action + " for collection: " + collectionType.getRole() );
}
Iterator iter = action.getCascadableChildrenIterator(eventSource, collectionType, child);
while ( iter.hasNext() ) {
cascadeProperty(
iter.next(),
elemType,
style,
anything,
isCascadeDeleteEnabled
);
}
if ( log.isTraceEnabled() ) {
log.trace( "done cascade " + action + " for collection: " + collectionType.getRole() );
}
}
final boolean deleteOrphans = style.hasOrphanDelete() &&
action.deleteOrphans() &&
elemType.isEntityType() &&
child instanceof PersistentCollection; //a newly instantiated collection can't have orphans
if ( deleteOrphans ) { // handle orphaned entities!!
if ( log.isTraceEnabled() ) {
log.trace( "deleting orphans for collection: " + collectionType.getRole() );
}
// we can do the cast since orphan-delete does not apply to:
// 1. newly instantiated collections
// 2. arrays (we can't track orphans for detached arrays)
final String entityName = collectionType.getAssociatedEntityName( eventSource.getFactory() );
deleteOrphans( entityName, (PersistentCollection) child );
if ( log.isTraceEnabled() ) {
log.trace( "done deleting orphans for collection: " + collectionType.getRole() );
}
}
}
示例3: getAssociatedEntityName
import org.hibernate.type.CollectionType; //导入方法依赖的package包/类
/**
* Given a collection type, determine the entity name of the elements
* contained within instance of that collection.
*
* @param collectionType The collection type to check.
*
* @return The entity name of the elements of this collection.
*/
public String getAssociatedEntityName(CollectionType collectionType) {
return collectionType.getAssociatedEntityName( sfi );
}
示例4: getAssociatedEntityName
import org.hibernate.type.CollectionType; //导入方法依赖的package包/类
/**
* Given a collection type, determine the entity name of the elements
* contained within instance of that collection.
*
* @param collectionType The collection type to check.
* @return The entity name of the elements of this collection.
*/
public String getAssociatedEntityName(CollectionType collectionType) {
return collectionType.getAssociatedEntityName( sfi );
}