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


Java EntityPersister.getPropertyTypes方法代码示例

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


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

示例1: findNonNullableTransientEntities

import org.hibernate.persister.entity.EntityPersister; //导入方法依赖的package包/类
/**
 * Find all non-nullable references to entities that have not yet
 * been inserted in the database, where the foreign key
 * is a reference to an unsaved transient entity. .
 *
 * @param entityName - the entity name
 * @param entity - the entity instance
 * @param values - insertable properties of the object (including backrefs),
 * possibly with substitutions
 * @param isEarlyInsert - true if the entity needs to be executed as soon as possible
 * (e.g., to generate an ID)
 * @param session - the session
 *
 * @return the transient unsaved entity dependencies that are non-nullable,
 *         or null if there are none.
 */
public static NonNullableTransientDependencies findNonNullableTransientEntities(
		String entityName,
		Object entity,
		Object[] values,
		boolean isEarlyInsert,
		SessionImplementor session) {
	final Nullifier nullifier = new Nullifier( entity, false, isEarlyInsert, session );
	final EntityPersister persister = session.getEntityPersister( entityName, entity );
	final String[] propertyNames = persister.getPropertyNames();
	final Type[] types = persister.getPropertyTypes();
	final boolean[] nullability = persister.getPropertyNullability();
	final NonNullableTransientDependencies nonNullableTransientEntities = new NonNullableTransientDependencies();
	for ( int i = 0; i < types.length; i++ ) {
		collectNonNullableTransientEntities(
				nullifier,
				values[i],
				propertyNames[i],
				types[i],
				nullability[i],
				session,
				nonNullableTransientEntities
		);
	}
	return nonNullableTransientEntities.isEmpty() ? null : nonNullableTransientEntities;
}
 
开发者ID:lamsfoundation,项目名称:lams,代码行数:42,代码来源:ForeignKeys.java

示例2: getTypedValues

import org.hibernate.persister.entity.EntityPersister; //导入方法依赖的package包/类
@Override
public TypedValue[] getTypedValues(Criteria criteria, CriteriaQuery criteriaQuery) {
	final EntityPersister meta = criteriaQuery.getFactory().getEntityPersister(
			criteriaQuery.getEntityName( criteria )
	);
	final String[] propertyNames = meta.getPropertyNames();
	final Type[] propertyTypes = meta.getPropertyTypes();

	final Object[] values = meta.getPropertyValues( exampleEntity );
	final List<TypedValue> list = new ArrayList<TypedValue>();
	for ( int i=0; i<propertyNames.length; i++ ) {
		final Object value = values[i];
		final Type type = propertyTypes[i];
		final String name = propertyNames[i];

		final boolean isVersionProperty = i == meta.getVersionProperty();

		if ( ! isVersionProperty && isPropertyIncluded( value, name, type ) ) {
			if ( propertyTypes[i].isComponentType() ) {
				addComponentTypedValues( name, value, (CompositeType) type, list, criteria, criteriaQuery );
			}
			else {
				addPropertyTypedValue( value, type, list );
			}
		}
	}

	return list.toArray( new TypedValue[ list.size() ] );
}
 
开发者ID:lamsfoundation,项目名称:lams,代码行数:30,代码来源:Example.java

示例3: noCascade

import org.hibernate.persister.entity.EntityPersister; //导入方法依赖的package包/类
@Override
public void noCascade(
		EventSource session,
		Object child,
		Object parent,
		EntityPersister persister,
		int propertyIndex) {
	if ( child == null ) {
		return;
	}
	Type type = persister.getPropertyTypes()[propertyIndex];
	if ( type.isEntityType() ) {
		String childEntityName = ((EntityType) type).getAssociatedEntityName( session.getFactory() );

		if ( !isInManagedState( child, session )
				&& !(child instanceof HibernateProxy) //a proxy cannot be transient and it breaks ForeignKeys.isTransient
				&& ForeignKeys.isTransient( childEntityName, child, null, session ) ) {
			String parentEntiytName = persister.getEntityName();
			String propertyName = persister.getPropertyNames()[propertyIndex];
			throw new TransientPropertyValueException(
					"object references an unsaved transient instance - save the transient instance before flushing",
					childEntityName,
					parentEntiytName,
					propertyName
			);

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

示例4: toString

import org.hibernate.persister.entity.EntityPersister; //导入方法依赖的package包/类
/**
 * Renders an entity to a string.
 *
 * @param entityName the entity name
 * @param entity an actual entity object, not a proxy!
 * @return the entity rendered to a string
 */
public String toString(String entityName, Object entity) throws HibernateException {
	EntityPersister entityPersister = factory.getEntityPersister( entityName );

	if ( entityPersister == null ) {
		return entity.getClass().getName();
	}

	Map<String,String> result = new HashMap<String,String>();

	if ( entityPersister.hasIdentifierProperty() ) {
		result.put(
			entityPersister.getIdentifierPropertyName(),
			entityPersister.getIdentifierType().toLoggableString( entityPersister.getIdentifier( entity ), factory )
		);
	}

	Type[] types = entityPersister.getPropertyTypes();
	String[] names = entityPersister.getPropertyNames();
	Object[] values = entityPersister.getPropertyValues( entity );
	for ( int i=0; i<types.length; i++ ) {
		if ( !names[i].startsWith("_") ) {
			String strValue = values[i]==LazyPropertyInitializer.UNFETCHED_PROPERTY ?
				values[i].toString() :
				types[i].toLoggableString( values[i], factory );
			result.put( names[i], strValue );
		}
	}
	return entityName + result.toString();
}
 
开发者ID:lamsfoundation,项目名称:lams,代码行数:37,代码来源:EntityPrinter.java

示例5: NaturalIdCacheKey

import org.hibernate.persister.entity.EntityPersister; //导入方法依赖的package包/类
/**
 * Construct a new key for a caching natural identifier resolutions into the second level cache.
 * Note that an entity name should always be the root entity name, not a subclass entity name.
 *
 * @param naturalIdValues The naturalIdValues associated with the cached data
 * @param persister The persister for the entity
 * @param session The originating session
 */
public NaturalIdCacheKey(
		final Object[] naturalIdValues,
		final EntityPersister persister,
		final SessionImplementor session) {

	this.entityName = persister.getRootEntityName();
	this.tenantId = session.getTenantIdentifier();

	this.naturalIdValues = new Serializable[naturalIdValues.length];

	final SessionFactoryImplementor factory = session.getFactory();
	final int[] naturalIdPropertyIndexes = persister.getNaturalIdentifierProperties();
	final Type[] propertyTypes = persister.getPropertyTypes();

	final int prime = 31;
	int result = 1;
	result = prime * result + ( ( this.entityName == null ) ? 0 : this.entityName.hashCode() );
	result = prime * result + ( ( this.tenantId == null ) ? 0 : this.tenantId.hashCode() );
	for ( int i = 0; i < naturalIdValues.length; i++ ) {
		final int naturalIdPropertyIndex = naturalIdPropertyIndexes[i];
		final Type type = propertyTypes[naturalIdPropertyIndex];
		final Object value = naturalIdValues[i];

		result = prime * result + (value != null ? type.getHashCode( value, factory ) : 0);

		// The natural id may not be fully resolved in some situations.  See HHH-7513 for one of them
		// (re-attaching a mutable natural id uses a database snapshot and hydration does not resolve associations).
		// TODO: The snapshot should probably be revisited at some point.  Consider semi-resolving, hydrating, etc.
		if (type instanceof EntityType && type.getSemiResolvedType( factory ).getReturnedClass().isInstance( value )) {
			this.naturalIdValues[i] = (Serializable) value;
		}
		else {
			this.naturalIdValues[i] = type.disassemble( value, session, null );
		}
	}

	this.hashCode = result;
	initTransients();
}
 
开发者ID:lamsfoundation,项目名称:lams,代码行数:48,代码来源:NaturalIdCacheKey.java

示例6: process

import org.hibernate.persister.entity.EntityPersister; //导入方法依赖的package包/类
@Override
void process(Object object, EntityPersister persister) throws HibernateException {
	final Object[] values = persister.getPropertyValues( object );
	final Type[] types = persister.getPropertyTypes();
	processEntityPropertyValues( values, types );
	if ( isSubstitutionRequired() ) {
		persister.setPropertyValues( object, values );
	}
}
 
开发者ID:lamsfoundation,项目名称:lams,代码行数:10,代码来源:WrapVisitor.java

示例7: createDeletedState

import org.hibernate.persister.entity.EntityPersister; //导入方法依赖的package包/类
private Object[] createDeletedState(EntityPersister persister, Object[] currentState, EventSource session) {
		Type[] propTypes = persister.getPropertyTypes();
		final Object[] deletedState = new Object[propTypes.length];
//		TypeFactory.deepCopy( currentState, propTypes, persister.getPropertyUpdateability(), deletedState, session );
		boolean[] copyability = new boolean[propTypes.length];
		java.util.Arrays.fill( copyability, true );
		TypeHelper.deepCopy( currentState, propTypes, copyability, deletedState, session );
		return deletedState;
	}
 
开发者ID:lamsfoundation,项目名称:lams,代码行数:10,代码来源:DefaultDeleteEventListener.java

示例8: onFlushEntity

import org.hibernate.persister.entity.EntityPersister; //导入方法依赖的package包/类
/**
 * Flushes a single entity's state to the database, by scheduling
 * an update action, if necessary
 */
public void onFlushEntity(FlushEntityEvent event) throws HibernateException {
	final Object entity = event.getEntity();
	final EntityEntry entry = event.getEntityEntry();
	final EventSource session = event.getSession();
	final EntityPersister persister = entry.getPersister();
	final Status status = entry.getStatus();
	final Type[] types = persister.getPropertyTypes();

	final boolean mightBeDirty = entry.requiresDirtyCheck( entity );

	final Object[] values = getValues( entity, entry, mightBeDirty, session );

	event.setPropertyValues( values );

	//TODO: avoid this for non-new instances where mightBeDirty==false
	boolean substitute = wrapCollections( session, persister, types, values );

	if ( isUpdateNecessary( event, mightBeDirty ) ) {
		substitute = scheduleUpdate( event ) || substitute;
	}

	if ( status != Status.DELETED ) {
		// now update the object .. has to be outside the main if block above (because of collections)
		if ( substitute ) {
			persister.setPropertyValues( entity, values );
		}

		// Search for collections by reachability, updating their role.
		// We don't want to touch collections reachable from a deleted object
		if ( persister.hasCollections() ) {
			new FlushVisitor( session, entity ).processEntityPropertyValues( values, types );
		}
	}

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

示例9: toSqlString

import org.hibernate.persister.entity.EntityPersister; //导入方法依赖的package包/类
@Override
public String toSqlString(Criteria criteria, CriteriaQuery criteriaQuery) {
	final StringBuilder buf = new StringBuilder().append( '(' );
	final EntityPersister meta = criteriaQuery.getFactory().getEntityPersister(
			criteriaQuery.getEntityName( criteria )
	);
	final String[] propertyNames = meta.getPropertyNames();
	final Type[] propertyTypes = meta.getPropertyTypes();

	final Object[] propertyValues = meta.getPropertyValues( exampleEntity );
	for ( int i=0; i<propertyNames.length; i++ ) {
		final Object propertyValue = propertyValues[i];
		final String propertyName = propertyNames[i];

		final boolean isVersionProperty = i == meta.getVersionProperty();
		if ( ! isVersionProperty && isPropertyIncluded( propertyValue, propertyName, propertyTypes[i] ) ) {
			if ( propertyTypes[i].isComponentType() ) {
				appendComponentCondition(
					propertyName,
					propertyValue,
					(CompositeType) propertyTypes[i],
					criteria,
					criteriaQuery,
					buf
				);
			}
			else {
				appendPropertyCondition(
					propertyName,
					propertyValue,
					criteria,
					criteriaQuery,
					buf
				);
			}
		}
	}

	if ( buf.length()==1 ) {
		buf.append( "1=1" );
	}

	return buf.append( ')' ).toString();
}
 
开发者ID:lamsfoundation,项目名称:lams,代码行数:45,代码来源:Example.java

示例10: cascade

import org.hibernate.persister.entity.EntityPersister; //导入方法依赖的package包/类
/**
 * Cascade an action from the parent entity instance to all its children.  This
 * form is typically called from within cascade actions.
 *
 * @param persister The parent's entity persister
 * @param parent The parent reference.
 * @param anything Anything ;)   Typically some form of cascade-local cache
 * which is specific to each CascadingAction type
 */
public void cascade(final EntityPersister persister, final Object parent, final Object anything) {
	if ( persister.hasCascades() || action.requiresNoCascadeChecking() ) {
		// performance opt
		final boolean traceEnabled = LOG.isTraceEnabled();
		if ( traceEnabled ) {
			LOG.tracev( "Processing cascade {0} for: {1}", action, persister.getEntityName() );
		}

		final Type[] types = persister.getPropertyTypes();
		final CascadeStyle[] cascadeStyles = persister.getPropertyCascadeStyles();
		final boolean hasUninitializedLazyProperties = persister.hasUninitializedLazyProperties( parent );
		for ( int i=0; i<types.length; i++) {
			final CascadeStyle style = cascadeStyles[i];
			final String propertyName = persister.getPropertyNames()[i];
			if ( hasUninitializedLazyProperties && persister.getPropertyLaziness()[i] && ! action.performOnLazyProperty() ) {
				//do nothing to avoid a lazy property initialization
				continue;
			}

			if ( style.doCascade( action ) ) {
				cascadeProperty(
						parent,
						persister.getPropertyValue( parent, i ),
						types[i],
						style,
						propertyName,
						anything,
						false
				);
			}
			else if ( action.requiresNoCascadeChecking() ) {
				action.noCascade(
						eventSource,
						persister.getPropertyValue( parent, i ),
						parent,
						persister,
						i
				);
			}
		}

		if ( traceEnabled ) {
			LOG.tracev( "Done processing cascade {0} for: {1}", action, persister.getEntityName() );
		}
	}
}
 
开发者ID:lamsfoundation,项目名称:lams,代码行数:56,代码来源:Cascade.java

示例11: checkNullability

import org.hibernate.persister.entity.EntityPersister; //导入方法依赖的package包/类
/**
 * Check nullability of the class persister properties
 *
 * @param values entity properties
 * @param persister class persister
 * @param isUpdate whether it is intended to be updated or saved
 *
 * @throws PropertyValueException Break the nullability of one property
 * @throws HibernateException error while getting Component values
 */
public void checkNullability(
		final Object[] values,
		final EntityPersister persister,
		final boolean isUpdate) throws HibernateException {
	/*
	 * Typically when Bean Validation is on, we don't want to validate null values
	 * at the Hibernate Core level. Hence the checkNullability setting.
	 */
	if ( checkNullability ) {
		/*
		  * Algorithm
		  * Check for any level one nullability breaks
		  * Look at non null components to
		  *   recursively check next level of nullability breaks
		  * Look at Collections contraining component to
		  *   recursively check next level of nullability breaks
		  *
		  *
		  * In the previous implementation, not-null stuffs where checked
		  * filtering by level one only updateable
		  * or insertable columns. So setting a sub component as update="false"
		  * has no effect on not-null check if the main component had good checkeability
		  * In this implementation, we keep this feature.
		  * However, I never see any documentation mentioning that, but it's for
		  * sure a limitation.
		  */

		final boolean[] nullability = persister.getPropertyNullability();
		final boolean[] checkability = isUpdate ?
			persister.getPropertyUpdateability() :
			persister.getPropertyInsertability();
		final Type[] propertyTypes = persister.getPropertyTypes();

		for ( int i = 0; i < values.length; i++ ) {

			if ( checkability[i] && values[i]!= LazyPropertyInitializer.UNFETCHED_PROPERTY ) {
				final Object value = values[i];
				if ( !nullability[i] && value == null ) {

					//check basic level one nullablilty
					throw new PropertyValueException(
							"not-null property references a null or transient value",
							persister.getEntityName(),
							persister.getPropertyNames()[i]
						);

				}
				else if ( value != null ) {
					//values is not null and is checkable, we'll look deeper
					final String breakProperties = checkSubElementsNullability( propertyTypes[i], value );
					if ( breakProperties != null ) {
						throw new PropertyValueException(
							"not-null property references a null or transient value",
							persister.getEntityName(),
							buildPropertyPath( persister.getPropertyNames()[i], breakProperties )
						);
					}

				}
			}

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

示例12: checkNaturalId

import org.hibernate.persister.entity.EntityPersister; //导入方法依赖的package包/类
private void checkNaturalId(
		EntityPersister persister,
		EntityEntry entry,
		Object[] current,
		Object[] loaded,
		SessionImplementor session) {
	if ( persister.hasNaturalIdentifier() && entry.getStatus() != Status.READ_ONLY ) {
		if ( !persister.getEntityMetamodel().hasImmutableNaturalId() ) {
			// SHORT-CUT: if the natural id is mutable (!immutable), no need to do the below checks
			// EARLY EXIT!!!
			return;
		}

		final int[] naturalIdentifierPropertiesIndexes = persister.getNaturalIdentifierProperties();
		final Type[] propertyTypes = persister.getPropertyTypes();
		final boolean[] propertyUpdateability = persister.getPropertyUpdateability();

		final Object[] snapshot = loaded == null
				? session.getPersistenceContext().getNaturalIdSnapshot( entry.getId(), persister )
				: session.getPersistenceContext().getNaturalIdHelper().extractNaturalIdValues( loaded, persister );

		for ( int i = 0; i < naturalIdentifierPropertiesIndexes.length; i++ ) {
			final int naturalIdentifierPropertyIndex = naturalIdentifierPropertiesIndexes[i];
			if ( propertyUpdateability[naturalIdentifierPropertyIndex] ) {
				// if the given natural id property is updatable (mutable), there is nothing to check
				continue;
			}

			final Type propertyType = propertyTypes[naturalIdentifierPropertyIndex];
			if ( !propertyType.isEqual( current[naturalIdentifierPropertyIndex], snapshot[i] ) ) {
				throw new HibernateException(
						String.format(
								"An immutable natural identifier of entity %s was altered from %s to %s",
								persister.getEntityName(),
								propertyTypes[naturalIdentifierPropertyIndex].toLoggableString(
										snapshot[i],
										session.getFactory()
								),
								propertyTypes[naturalIdentifierPropertyIndex].toLoggableString(
										current[naturalIdentifierPropertyIndex],
										session.getFactory()
								)
						)
				);
			}
		}
	}
}
 
开发者ID:lamsfoundation,项目名称:lams,代码行数:49,代码来源:DefaultFlushEntityEventListener.java


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