本文整理汇总了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;
}
示例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);
}
示例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;
}
示例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() ] );
}
示例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();
}
示例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 );
}
}
示例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();
}
示例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;
}