本文整理匯總了Java中org.hibernate.persister.entity.EntityPersister.setPropertyValues方法的典型用法代碼示例。如果您正苦於以下問題:Java EntityPersister.setPropertyValues方法的具體用法?Java EntityPersister.setPropertyValues怎麽用?Java EntityPersister.setPropertyValues使用的例子?那麽, 這裏精選的方法代碼示例或許可以為您提供幫助。您也可以進一步了解該方法所在類org.hibernate.persister.entity.EntityPersister
的用法示例。
在下文中一共展示了EntityPersister.setPropertyValues方法的6個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的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: 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 );
}
示例4: assemble
import org.hibernate.persister.entity.EntityPersister; //導入方法依賴的package包/類
/**
* Assemble the previously disassembled state represented by this entry into the given entity instance.
*
* Additionally manages the PreLoadEvent callbacks.
*
* @param instance The entity instance
* @param id The entity identifier
* @param persister The entity persister
* @param interceptor (currently unused)
* @param session The session
*
* @return The assembled state
*
* @throws HibernateException Indicates a problem performing assembly or calling the PreLoadEventListeners.
*
* @see org.hibernate.type.Type#assemble
* @see org.hibernate.type.Type#disassemble
*/
public Object[] assemble(
final Object instance,
final Serializable id,
final EntityPersister persister,
final Interceptor interceptor,
final EventSource session) throws HibernateException {
if ( !persister.getEntityName().equals( subclass ) ) {
throw new AssertionFailure( "Tried to assemble a different subclass instance" );
}
//assembled state gets put in a new array (we read from cache by value!)
final Object[] assembledProps = TypeHelper.assemble(
disassembledState,
persister.getPropertyTypes(),
session, instance
);
//persister.setIdentifier(instance, id); //before calling interceptor, for consistency with normal load
//TODO: reuse the PreLoadEvent
final PreLoadEvent preLoadEvent = new PreLoadEvent( session )
.setEntity( instance )
.setState( assembledProps )
.setId( id )
.setPersister( persister );
final EventListenerGroup<PreLoadEventListener> listenerGroup = session
.getFactory()
.getServiceRegistry()
.getService( EventListenerRegistry.class )
.getEventListenerGroup( EventType.PRE_LOAD );
for ( PreLoadEventListener listener : listenerGroup.listeners() ) {
listener.onPreLoad( preLoadEvent );
}
persister.setPropertyValues( instance, assembledProps );
return assembledProps;
}
示例5: 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 );
}
}
示例6: 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 );
}
}
}