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


Java EntityPersister.getPropertyValues方法代碼示例

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


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

示例1: insert

import org.hibernate.persister.entity.EntityPersister; //導入方法依賴的package包/類
@Override
public Serializable insert(String entityName, Object entity) {
	errorIfClosed();
	EntityPersister persister = getEntityPersister( entityName, entity );
	Serializable id = persister.getIdentifierGenerator().generate( this, entity );
	Object[] state = persister.getPropertyValues( entity );
	if ( persister.isVersioned() ) {
		boolean substitute = Versioning.seedVersion(
				state, persister.getVersionProperty(), persister.getVersionType(), this
		);
		if ( substitute ) {
			persister.setPropertyValues( entity, state );
		}
	}
	if ( id == IdentifierGeneratorHelper.POST_INSERT_INDICATOR ) {
		id = persister.insert(state, entity, this);
	}
	else {
		persister.insert(id, state, entity, this);
	}
	persister.setIdentifier( entity, id, this );
	return id;
}
 
開發者ID:lamsfoundation,項目名稱:lams,代碼行數:24,代碼來源:StatelessSessionImpl.java

示例2: update

import org.hibernate.persister.entity.EntityPersister; //導入方法依賴的package包/類
@Override
public void update(String entityName, Object entity) {
	errorIfClosed();
	EntityPersister persister = getEntityPersister(entityName, entity);
	Serializable id = persister.getIdentifier( entity, this );
	Object[] state = persister.getPropertyValues( entity );
	Object oldVersion;
	if ( persister.isVersioned() ) {
		oldVersion = persister.getVersion( entity );
		Object newVersion = Versioning.increment( oldVersion, persister.getVersionType(), this );
		Versioning.setVersion(state, newVersion, persister);
		persister.setPropertyValues( entity, state );
	}
	else {
		oldVersion = null;
	}
	persister.update(id, state, null, false, null, oldVersion, entity, null, this);
}
 
開發者ID:lamsfoundation,項目名稱:lams,代碼行數:19,代碼來源:StatelessSessionImpl.java

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

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

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

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

示例8: reassociate

import org.hibernate.persister.entity.EntityPersister; //導入方法依賴的package包/類
/**
 * Associates a given entity (either transient or associated with another session) to
 * the given session.
 *
 * @param event The event triggering the re-association
 * @param object The entity to be associated
 * @param id The id of the entity.
 * @param persister The entity's persister instance.
 *
 * @return An EntityEntry representing the entity within this session.
 */
protected final EntityEntry reassociate(AbstractEvent event, Object object, Serializable id, EntityPersister persister) {

	if ( log.isTraceEnabled() ) {
		log.tracev(
				"Reassociating transient instance: {0}",
				MessageHelper.infoString( persister, id, event.getSession().getFactory() )
		);
	}

	final EventSource source = event.getSession();
	final EntityKey key = source.generateEntityKey( id, persister );

	source.getPersistenceContext().checkUniqueness( key, object );

	//get a snapshot
	Object[] values = persister.getPropertyValues( object );
	TypeHelper.deepCopy(
			values,
			persister.getPropertyTypes(),
			persister.getPropertyUpdateability(),
			values,
			source
	);
	Object version = Versioning.getVersion( values, persister );

	EntityEntry newEntry = source.getPersistenceContext().addEntity(
			object,
			( persister.isMutable() ? Status.MANAGED : Status.READ_ONLY ),
			values,
			key,
			version,
			LockMode.NONE,
			true,
			persister,
			false,
			true //will be ignored, using the existing Entry instead
	);

	new OnLockVisitor( source, id, object ).process( object, persister );

	persister.afterReassociate( object, source );

	return newEntry;

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


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