当前位置: 首页>>代码示例>>Java>>正文


Java EntityPersister.getIdentifierType方法代码示例

本文整理汇总了Java中org.hibernate.persister.entity.EntityPersister.getIdentifierType方法的典型用法代码示例。如果您正苦于以下问题:Java EntityPersister.getIdentifierType方法的具体用法?Java EntityPersister.getIdentifierType怎么用?Java EntityPersister.getIdentifierType使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在org.hibernate.persister.entity.EntityPersister的用法示例。


在下文中一共展示了EntityPersister.getIdentifierType方法的5个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。

示例1: identityRemove

import org.hibernate.persister.entity.EntityPersister; //导入方法依赖的package包/类
/**
 * Removes entity entries that have an equal identifier with the incoming entity instance
 *
 * @param list The list containing the entity instances
 * @param entityInstance The entity instance to match elements.
 * @param entityName The entity name
 * @param session The session
 */
public static void identityRemove(
		Collection list,
		Object entityInstance,
		String entityName,
		SessionImplementor session) {

	if ( entityInstance != null && ForeignKeys.isNotTransient( entityName, entityInstance, null, session ) ) {
		final EntityPersister entityPersister = session.getFactory().getEntityPersister( entityName );
		final Type idType = entityPersister.getIdentifierType();

		final Serializable idOfCurrent = ForeignKeys.getEntityIdentifierIfNotUnsaved( entityName, entityInstance, session );
		final Iterator itr = list.iterator();
		while ( itr.hasNext() ) {
			final Serializable idOfOld = ForeignKeys.getEntityIdentifierIfNotUnsaved( entityName, itr.next(), session );
			if ( idType.isEqual( idOfCurrent, idOfOld, session.getFactory() ) ) {
				itr.remove();
				break;
			}
		}

	}
}
 
开发者ID:lamsfoundation,项目名称:lams,代码行数:31,代码来源:AbstractPersistentCollection.java

示例2: infoString

import org.hibernate.persister.entity.EntityPersister; //导入方法依赖的package包/类
/**
 * Generate an info message string relating to a particular entity.
 *
 * @param persister The persister for the entity
 * @param id The entity id value
 * @param factory The session factory - Could be null!
 * @return An info string, in the form [FooBar#1]
 */
public static String infoString(
		EntityPersister persister,
		Object id, 
		SessionFactoryImplementor factory) {
	StringBuilder s = new StringBuilder();
	s.append( '[' );
	Type idType;
	if( persister == null ) {
		s.append( "<null EntityPersister>" );
		idType = null;
	}
	else {
		s.append( persister.getEntityName() );
		idType = persister.getIdentifierType();
	}
	s.append( '#' );

	if ( id == null ) {
		s.append( "<null>" );
	}
	else {
		if ( idType == null ) {
			s.append( id );
		}
		else {
			if ( factory != null ) {
				s.append( idType.toLoggableString( id, factory ) );
			}
			else {
				s.append( "<not loggable>" );
			}
		}
	}
	s.append( ']' );

	return s.toString();

}
 
开发者ID:lamsfoundation,项目名称:lams,代码行数:47,代码来源:MessageHelper.java

示例3: readRow

import org.hibernate.persister.entity.EntityPersister; //导入方法依赖的package包/类
@Override
public Object readRow(ResultSet resultSet, ResultSetProcessingContextImpl context) throws SQLException {
	final ResultSetProcessingContext.EntityReferenceProcessingState processingState =
			rootReturnReader.getIdentifierResolutionContext( context );
	// if the entity reference we are hydrating is a Return, it is possible that its EntityKey is
	// supplied by the QueryParameter optional entity information
	if ( context.shouldUseOptionalEntityInformation() && context.getQueryParameters().getOptionalId() != null ) {
		EntityKey entityKey = ResultSetProcessorHelper.getOptionalObjectKey(
				context.getQueryParameters(),
				context.getSession()
		);
		processingState.registerIdentifierHydratedForm( entityKey.getIdentifier() );
		processingState.registerEntityKey( entityKey );
		final EntityPersister entityPersister = processingState.getEntityReference().getEntityPersister();
		if ( entityPersister.getIdentifierType().isComponentType()  ) {
			final ComponentType identifierType = (ComponentType) entityPersister.getIdentifierType();
			if ( !identifierType.isEmbedded() ) {
				addKeyManyToOnesToSession(
						context,
						identifierType,
						entityKey.getIdentifier()
				);
			}
		}
	}
	return super.readRow( resultSet, context );
}
 
开发者ID:lamsfoundation,项目名称:lams,代码行数:28,代码来源:EntityLoadQueryDetails.java

示例4: buildCacheKey

import org.hibernate.persister.entity.EntityPersister; //导入方法依赖的package包/类
private CacheKey buildCacheKey(Serializable identifier, EntityPersister p) {
	return new CacheKey(
			identifier,
			p.getIdentifierType(),
			p.getRootEntityName(),
			null,                         // have to assume non tenancy
			sessionFactory
	);
}
 
开发者ID:lamsfoundation,项目名称:lams,代码行数:10,代码来源:CacheImpl.java

示例5: getOrphans

import org.hibernate.persister.entity.EntityPersister; //导入方法依赖的package包/类
/**
 * Given a collection of entity instances that used to
 * belong to the collection, and a collection of instances
 * that currently belong, return a collection of orphans
 */
@SuppressWarnings({"JavaDoc", "unchecked"})
protected static Collection getOrphans(
		Collection oldElements,
		Collection currentElements,
		String entityName,
		SessionImplementor session) throws HibernateException {

	// short-circuit(s)
	if ( currentElements.size() == 0 ) {
		// no new elements, the old list contains only Orphans
		return oldElements;
	}
	if ( oldElements.size() == 0 ) {
		// no old elements, so no Orphans neither
		return oldElements;
	}

	final EntityPersister entityPersister = session.getFactory().getEntityPersister( entityName );
	final Type idType = entityPersister.getIdentifierType();

	// create the collection holding the Orphans
	final Collection res = new ArrayList();

	// collect EntityIdentifier(s) of the *current* elements - add them into a HashSet for fast access
	final java.util.Set currentIds = new HashSet();
	final java.util.Set currentSaving = new IdentitySet();
	for ( Object current : currentElements ) {
		if ( current != null && ForeignKeys.isNotTransient( entityName, current, null, session ) ) {
			final EntityEntry ee = session.getPersistenceContext().getEntry( current );
			if ( ee != null && ee.getStatus() == Status.SAVING ) {
				currentSaving.add( current );
			}
			else {
				final Serializable currentId = ForeignKeys.getEntityIdentifierIfNotUnsaved(
						entityName,
						current,
						session
				);
				currentIds.add( new TypedValue( idType, currentId ) );
			}
		}
	}

	// iterate over the *old* list
	for ( Object old : oldElements ) {
		if ( !currentSaving.contains( old ) ) {
			final Serializable oldId = ForeignKeys.getEntityIdentifierIfNotUnsaved( entityName, old, session );
			if ( !currentIds.contains( new TypedValue( idType, oldId ) ) ) {
				res.add( old );
			}
		}
	}

	return res;
}
 
开发者ID:lamsfoundation,项目名称:lams,代码行数:61,代码来源:AbstractPersistentCollection.java


注:本文中的org.hibernate.persister.entity.EntityPersister.getIdentifierType方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。