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


Java EntityPersister.hasIdentifierProperty方法代码示例

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


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

示例1: 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

示例2: entityIsTransient

import org.hibernate.persister.entity.EntityPersister; //导入方法依赖的package包/类
protected void entityIsTransient(MergeEvent event, Map copyCache) {

		LOG.trace( "Merging transient instance" );

		final Object entity = event.getEntity();
		final EventSource source = event.getSession();

		final String entityName = event.getEntityName();
		final EntityPersister persister = source.getEntityPersister( entityName, entity );

		final Serializable id = persister.hasIdentifierProperty() ?
				persister.getIdentifier( entity, source ) :
				null;
		if ( copyCache.containsKey( entity ) ) {
			persister.setIdentifier( copyCache.get( entity ), id, source );
		}
		else {
			( (MergeContext) copyCache ).put( entity, source.instantiate( persister, id ), true ); //before cascade!
		}
		final Object copy = copyCache.get( entity );

		// cascade first, so that all unsaved objects get their
		// copy created before we actually copy
		//cascadeOnMerge(event, persister, entity, copyCache, Cascades.CASCADE_BEFORE_MERGE);
		super.cascadeBeforeSave( source, persister, entity, copyCache );
		copyValues( persister, entity, copy, source, copyCache, ForeignKeyDirection.FOREIGN_KEY_FROM_PARENT );

		saveTransientEntity( copy, entityName, event.getRequestedId(), source, copyCache );

		// cascade first, so that all unsaved objects get their
		// copy created before we actually copy
		super.cascadeAfterSave( source, persister, entity, copyCache );
		copyValues( persister, entity, copy, source, copyCache, ForeignKeyDirection.FOREIGN_KEY_TO_PARENT );

		event.setResult( copy );
	}
 
开发者ID:lamsfoundation,项目名称:lams,代码行数:37,代码来源:DefaultMergeEventListener.java


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