當前位置: 首頁>>代碼示例>>Java>>正文


Java EntityPersister類代碼示例

本文整理匯總了Java中org.hibernate.persister.entity.EntityPersister的典型用法代碼示例。如果您正苦於以下問題:Java EntityPersister類的具體用法?Java EntityPersister怎麽用?Java EntityPersister使用的例子?那麽, 這裏精選的類代碼示例或許可以為您提供幫助。


EntityPersister類屬於org.hibernate.persister.entity包,在下文中一共展示了EntityPersister類的15個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的Java代碼示例。

示例1: cascadeBeforeSave

import org.hibernate.persister.entity.EntityPersister; //導入依賴的package包/類
/**
 * Handles the calls needed to perform pre-save cascades for the given entity.
 *
 * @param source The session from whcih the save event originated.
 * @param persister The entity's persister instance.
 * @param entity The entity to be saved.
 * @param anything Generally cascade-specific data
 */
protected void cascadeBeforeSave(
		EventSource source,
		EntityPersister persister,
		Object entity,
		Object anything) {

	// cascade-save to many-to-one BEFORE the parent is saved
	source.getPersistenceContext().incrementCascadeLevel();
	try {
		new Cascade( getCascadeAction(), CascadePoint.BEFORE_INSERT_AFTER_DELETE, source ).cascade(
				persister,
				entity,
				anything
		);
	}
	finally {
		source.getPersistenceContext().decrementCascadeLevel();
	}
}
 
開發者ID:lamsfoundation,項目名稱:lams,代碼行數:28,代碼來源:AbstractSaveEventListener.java

示例2: isVersionChanged

import org.hibernate.persister.entity.EntityPersister; //導入依賴的package包/類
private boolean isVersionChanged(Object entity, EventSource source, EntityPersister persister, Object target) {
	if ( !persister.isVersioned() ) {
		return false;
	}
	// for merging of versioned entities, we consider the version having
	// been changed only when:
	// 1) the two version values are different;
	//      *AND*
	// 2) The target actually represents database state!
	//
	// This second condition is a special case which allows
	// an entity to be merged during the same transaction
	// (though during a seperate operation) in which it was
	// originally persisted/saved
	boolean changed = !persister.getVersionType().isSame(
			persister.getVersion( target ),
			persister.getVersion( entity )
	);

	// TODO : perhaps we should additionally require that the incoming entity
	// version be equivalent to the defined unsaved-value?
	return changed && existsInDatabase( target, source, persister );
}
 
開發者ID:lamsfoundation,項目名稱:lams,代碼行數:24,代碼來源:DefaultMergeEventListener.java

示例3: infoString

import org.hibernate.persister.entity.EntityPersister; //導入依賴的package包/類
/**
 * Generate an info message string relating to a series of entities.
 *
 * @param persister The persister for the entities
 * @param ids The entity id values
 * @param factory The session factory
 * @return An info string, in the form [FooBar#<1,2,3>]
 */
public static String infoString(
		EntityPersister persister, 
		Serializable[] ids, 
		SessionFactoryImplementor factory) {
	StringBuilder s = new StringBuilder();
	s.append( '[' );
	if( persister == null ) {
		s.append( "<null EntityPersister>" );
	}
	else {
		s.append( persister.getEntityName() );
		s.append( "#<" );
		for ( int i=0; i<ids.length; i++ ) {
			s.append( persister.getIdentifierType().toLoggableString( ids[i], factory ) );
			if ( i < ids.length-1 ) {
				s.append( ", " );
			}
		}
		s.append( '>' );
	}
	s.append( ']' );

	return s.toString();

}
 
開發者ID:lamsfoundation,項目名稱:lams,代碼行數:34,代碼來源:MessageHelper.java

示例4: cascadeAfterReplicate

import org.hibernate.persister.entity.EntityPersister; //導入依賴的package包/類
private void cascadeAfterReplicate(
		Object entity,
		EntityPersister persister,
		ReplicationMode replicationMode,
		EventSource source) {
	source.getPersistenceContext().incrementCascadeLevel();
	try {
		new Cascade( CascadingActions.REPLICATE, CascadePoint.AFTER_UPDATE, source ).cascade(
				persister,
				entity,
				replicationMode
		);
	}
	finally {
		source.getPersistenceContext().decrementCascadeLevel();
	}
}
 
開發者ID:lamsfoundation,項目名稱:lams,代碼行數:18,代碼來源:DefaultReplicateEventListener.java

示例5: manageSharedNaturalIdCrossReference

import org.hibernate.persister.entity.EntityPersister; //導入依賴的package包/類
@Override
public void manageSharedNaturalIdCrossReference(
		EntityPersister persister,
		final Serializable id,
		Object[] state,
		Object[] previousState,
		CachedNaturalIdValueSource source) {
	if ( !persister.hasNaturalIdentifier() ) {
		// nothing to do
		return;
	}

	if ( !persister.hasNaturalIdCache() ) {
		// nothing to do
		return;
	}

	persister = locateProperPersister( persister );
	final Object[] naturalIdValues = extractNaturalIdValues( state, persister );
	final Object[] previousNaturalIdValues = previousState == null ? null : extractNaturalIdValues( previousState, persister );

	managedSharedCacheEntries( persister, id, naturalIdValues, previousNaturalIdValues, source );
}
 
開發者ID:lamsfoundation,項目名稱:lams,代碼行數:24,代碼來源:StatefulPersistenceContext.java

示例6: loadByDerivedIdentitySimplePkValue

import org.hibernate.persister.entity.EntityPersister; //導入依賴的package包/類
private void loadByDerivedIdentitySimplePkValue(
		LoadEvent event,
		LoadEventListener.LoadType options,
		EntityPersister dependentPersister,
		EmbeddedComponentType dependentIdType,
		EntityPersister parentPersister) {
	final EntityKey parentEntityKey = event.getSession().generateEntityKey( event.getEntityId(), parentPersister );
	final Object parent = doLoad( event, parentPersister, parentEntityKey, options );

	final Serializable dependent = (Serializable) dependentIdType.instantiate( parent, event.getSession() );
	dependentIdType.setPropertyValues( dependent, new Object[] {parent}, dependentPersister.getEntityMode() );
	final EntityKey dependentEntityKey = event.getSession().generateEntityKey( dependent, dependentPersister );
	event.setEntityId( dependent );

	event.setResult( doLoad( event, dependentPersister, dependentEntityKey, options ) );
}
 
開發者ID:lamsfoundation,項目名稱:lams,代碼行數:17,代碼來源:DefaultLoadEventListener.java

示例7: internalLoad

import org.hibernate.persister.entity.EntityPersister; //導入依賴的package包/類
@Override
public Object internalLoad(
		String entityName,
        Serializable id,
        boolean eager,
        boolean nullable) throws HibernateException {
	errorIfClosed();
	EntityPersister persister = getFactory().getEntityPersister( entityName );
	// first, try to load it from the temp PC associated to this SS
	Object loaded = temporaryPersistenceContext.getEntity( generateEntityKey( id, persister ) );
	if ( loaded != null ) {
		// we found it in the temp PC.  Should indicate we are in the midst of processing a result set
		// containing eager fetches via join fetch
		return loaded;
	}
	if ( !eager && persister.hasProxy() ) {
		// if the metadata allowed proxy creation and caller did not request forceful eager loading,
		// generate a proxy
		return persister.createProxy( id, this );
	}
	// otherwise immediately materialize it
	return get( entityName, id );
}
 
開發者ID:lamsfoundation,項目名稱:lams,代碼行數:24,代碼來源:StatelessSessionImpl.java

示例8: getValues

import org.hibernate.persister.entity.EntityPersister; //導入依賴的package包/類
private Object[] getValues(Object entity, EntityEntry entry, boolean mightBeDirty, SessionImplementor session) {
	final Object[] loadedState = entry.getLoadedState();
	final Status status = entry.getStatus();
	final EntityPersister persister = entry.getPersister();

	final Object[] values;
	if ( status == Status.DELETED ) {
		//grab its state saved at deletion
		values = entry.getDeletedState();
	}
	else if ( !mightBeDirty && loadedState != null ) {
		values = loadedState;
	}
	else {
		checkId( entity, persister, entry.getId(), session );

		// grab its current state
		values = persister.getPropertyValues( entity );

		checkNaturalId( persister, entry, values, loadedState, session );
	}
	return values;
}
 
開發者ID:lamsfoundation,項目名稱:lams,代碼行數:24,代碼來源:DefaultFlushEntityEventListener.java

示例9: buildBidirectionalEntityReference

import org.hibernate.persister.entity.EntityPersister; //導入依賴的package包/類
@Override
public BidirectionalEntityReference buildBidirectionalEntityReference(
		AssociationAttributeDefinition attributeDefinition,
		FetchStrategy fetchStrategy,
		EntityReference targetEntityReference) {
	final EntityType fetchedType = (EntityType) attributeDefinition.getType();
	final EntityPersister fetchedPersister = attributeDefinition.toEntityDefinition().getEntityPersister();

	if ( fetchedPersister == null ) {
		throw new WalkingException(
				String.format(
						"Unable to locate EntityPersister [%s] for bidirectional entity reference [%s]",
						fetchedType.getAssociatedEntityName(),
						attributeDefinition.getName()
				)
		);
	}

	final BidirectionalEntityReference bidirectionalEntityReference =
			new BidirectionalEntityReferenceImpl( this, attributeDefinition, targetEntityReference );
	addBidirectionalEntityReference( bidirectionalEntityReference );
	return bidirectionalEntityReference;
}
 
開發者ID:lamsfoundation,項目名稱:lams,代碼行數:24,代碼來源:AbstractExpandingFetchSource.java

示例10: deleteTransientEntity

import org.hibernate.persister.entity.EntityPersister; //導入依賴的package包/類
/**
 * We encountered a delete request on a transient instance.
 * <p/>
 * This is a deviation from historical Hibernate (pre-3.2) behavior to
 * align with the JPA spec, which states that transient entities can be
 * passed to remove operation in which case cascades still need to be
 * performed.
 *
 * @param session The session which is the source of the event
 * @param entity The entity being delete processed
 * @param cascadeDeleteEnabled Is cascading of deletes enabled
 * @param persister The entity persister
 * @param transientEntities A cache of already visited transient entities
 * (to avoid infinite recursion).
 */
protected void deleteTransientEntity(
		EventSource session,
		Object entity,
		boolean cascadeDeleteEnabled,
		EntityPersister persister,
		Set transientEntities) {
	LOG.handlingTransientEntity();
	if ( transientEntities.contains( entity ) ) {
		LOG.trace( "Already handled transient entity; skipping" );
		return;
	}
	transientEntities.add( entity );
	cascadeBeforeDelete( session, persister, entity, null, transientEntities );
	cascadeAfterDelete( session, persister, entity, transientEntities );
}
 
開發者ID:lamsfoundation,項目名稱:lams,代碼行數:31,代碼來源:DefaultDeleteEventListener.java

示例11: copyValues

import org.hibernate.persister.entity.EntityPersister; //導入依賴的package包/類
protected void copyValues(
		final EntityPersister persister,
		final Object entity,
		final Object target,
		final SessionImplementor source,
		final Map copyCache) {
	final Object[] copiedValues = TypeHelper.replace(
			persister.getPropertyValues( entity ),
			persister.getPropertyValues( target ),
			persister.getPropertyTypes(),
			source,
			target,
			copyCache
	);

	persister.setPropertyValues( target, copiedValues );
}
 
開發者ID:lamsfoundation,項目名稱:lams,代碼行數:18,代碼來源:DefaultMergeEventListener.java

示例12: addFromElement

import org.hibernate.persister.entity.EntityPersister; //導入依賴的package包/類
FromElement addFromElement() throws SemanticException {
	final FromClause parentFromClause = fromClause.getParentFromClause();
	if ( parentFromClause != null ) {
		// Look up class name using the first identifier in the path.
		final String pathAlias = PathHelper.getAlias( path );
		final FromElement parentFromElement = parentFromClause.getFromElement( pathAlias );
		if ( parentFromElement != null ) {
			return createFromElementInSubselect( path, pathAlias, parentFromElement, classAlias );
		}
	}

	final EntityPersister entityPersister = fromClause.getSessionFactoryHelper().requireClassPersister( path );

	final FromElement elem = createAndAddFromElement(
			path,
			classAlias,
			entityPersister,
			(EntityType) ( (Queryable) entityPersister ).getType(),
			null
	);

	// Add to the query spaces.
	fromClause.getWalker().addQuerySpaces( entityPersister.getQuerySpaces() );

	return elem;
}
 
開發者ID:lamsfoundation,項目名稱:lams,代碼行數:27,代碼來源:FromElementFactory.java

示例13: registerInsertedKey

import org.hibernate.persister.entity.EntityPersister; //導入依賴的package包/類
@Override
public void registerInsertedKey(EntityPersister persister, Serializable id) {
	// we only are worried about registering these if the persister defines caching
	if ( persister.hasCache() ) {
		if ( insertedKeysMap == null ) {
			insertedKeysMap = new HashMap<String, List<Serializable>>();
		}
		final String rootEntityName = persister.getRootEntityName();
		List<Serializable> insertedEntityIds = insertedKeysMap.get( rootEntityName );
		if ( insertedEntityIds == null ) {
			insertedEntityIds = new ArrayList<Serializable>();
			insertedKeysMap.put( rootEntityName, insertedEntityIds );
		}
		insertedEntityIds.add( id );
	}
}
 
開發者ID:lamsfoundation,項目名稱:lams,代碼行數:17,代碼來源:StatefulPersistenceContext.java

示例14: CachedNaturalId

import org.hibernate.persister.entity.EntityPersister; //導入依賴的package包/類
public CachedNaturalId(EntityPersister persister, Object[] values) {
	this.persister = persister;
	this.values = values;

	final int prime = 31;
	int hashCodeCalculation = 1;
	hashCodeCalculation = prime * hashCodeCalculation + persister.hashCode();

	final int[] naturalIdPropertyIndexes = persister.getNaturalIdentifierProperties();
	naturalIdTypes = new Type[ naturalIdPropertyIndexes.length ];
	int i = 0;
	for ( int naturalIdPropertyIndex : naturalIdPropertyIndexes ) {
		final Type type = persister.getPropertyType( persister.getPropertyNames()[ naturalIdPropertyIndex ] );
		naturalIdTypes[i] = type;
		final int elementHashCode = values[i] == null ? 0 :type.getHashCode( values[i], persister.getFactory() );
		hashCodeCalculation = prime * hashCodeCalculation + elementHashCode;
		i++;
	}

	this.hashCode = hashCodeCalculation;
}
 
開發者ID:lamsfoundation,項目名稱:lams,代碼行數:22,代碼來源:NaturalIdXrefDelegate.java

示例15: PostUpdateEvent

import org.hibernate.persister.entity.EntityPersister; //導入依賴的package包/類
public PostUpdateEvent(
		Object entity, 
		Serializable id,
		Object[] state,
		Object[] oldState,
		int[] dirtyProperties,
		EntityPersister persister,
		EventSource source
) {
	super(source);
	this.entity = entity;
	this.id = id;
	this.state = state;
	this.oldState = oldState;
	this.dirtyProperties = dirtyProperties;
	this.persister = persister;
}
 
開發者ID:lamsfoundation,項目名稱:lams,代碼行數:18,代碼來源:PostUpdateEvent.java


注:本文中的org.hibernate.persister.entity.EntityPersister類示例由純淨天空整理自Github/MSDocs等開源代碼及文檔管理平台,相關代碼片段篩選自各路編程大神貢獻的開源項目,源碼版權歸原作者所有,傳播和使用請參考對應項目的License;未經允許,請勿轉載。