org.hibernate.event.spi.EventSource.generateEntityKey()方法的使用及代码示例

x33g5p2x  于2022-01-19 转载在 其他  
字(9.2k)|赞(0)|评价(0)|浏览(114)

本文整理了Java中org.hibernate.event.spi.EventSource.generateEntityKey()方法的一些代码示例,展示了EventSource.generateEntityKey()的具体用法。这些代码示例主要来源于Github/Stackoverflow/Maven等平台,是从一些精选项目中提取出来的代码,具有较强的参考意义,能在一定程度帮忙到你。EventSource.generateEntityKey()方法的具体详情如下:
包路径:org.hibernate.event.spi.EventSource
类名称:EventSource
方法名:generateEntityKey

EventSource.generateEntityKey介绍

暂无

代码示例

代码示例来源:origin: hibernate/hibernate-orm

private void loadByDerivedIdentitySimplePkValue(
    LoadEvent event,
    LoadEventListener.LoadType options,
    EntityPersister dependentPersister,
    EmbeddedComponentType dependentIdType,
    EntityPersister parentPersister) {
  final EntityKey parentEntityKey = event.getSession().generateEntityKey( event.getEntityId(), parentPersister );
  final Object parent = doLoad( event, parentPersister, parentEntityKey, options );
  final Serializable dependent = (Serializable) dependentIdType.instantiate( parent, event.getSession() );
  dependentIdType.setPropertyValues( dependent, new Object[] {parent}, dependentPersister.getEntityMode() );
  final EntityKey dependentEntityKey = event.getSession().generateEntityKey( dependent, dependentPersister );
  event.setEntityId( dependent );
  event.setResult( doLoad( event, dependentPersister, dependentEntityKey, options ) );
}

代码示例来源:origin: hibernate/hibernate-orm

private boolean existsInDatabase(Object entity, EventSource source, EntityPersister persister) {
  EntityEntry entry = source.getPersistenceContext().getEntry( entity );
  if ( entry == null ) {
    Serializable id = persister.getIdentifier( entity, source );
    if ( id != null ) {
      final EntityKey key = source.generateEntityKey( id, persister );
      final Object managedEntity = source.getPersistenceContext().getEntity( key );
      entry = source.getPersistenceContext().getEntry( managedEntity );
    }
  }
  return entry != null && entry.isExistsInDatabase();
}

代码示例来源:origin: hibernate/hibernate-orm

private void performReplication(
    Object entity,
    Serializable id,
    Object version,
    EntityPersister persister,
    ReplicationMode replicationMode,
    EventSource source) throws HibernateException {
  if ( LOG.isTraceEnabled() ) {
    LOG.tracev( "Replicating changes to {0}", MessageHelper.infoString( persister, id, source.getFactory() ) );
  }
  new OnReplicateVisitor( source, id, entity, true ).process( entity, persister );
  source.getPersistenceContext().addEntity(
      entity,
      ( persister.isMutable() ? Status.MANAGED : Status.READ_ONLY ),
      null,
      source.generateEntityKey( id, persister ),
      version,
      LockMode.NONE,
      true,
      persister,
      true
  );
  cascadeAfterReplicate( entity, persister, replicationMode, source );
}

代码示例来源:origin: hibernate/hibernate-orm

private void doOnLoad(
    final EntityPersister persister,
    final LoadEvent event,
    final LoadEventListener.LoadType loadType) {
  try {
    final EntityKey keyToLoad = event.getSession().generateEntityKey( event.getEntityId(), persister );
    if ( loadType.isNakedEntityReturned() ) {
      //do not return a proxy!
      //(this option indicates we are initializing a proxy)
      event.setResult( load( event, persister, keyToLoad, loadType ) );
    }
    else {
      //return a proxy if appropriate
      if ( event.getLockMode() == LockMode.NONE ) {
        event.setResult( proxyOrLoad( event, persister, keyToLoad, loadType ) );
      }
      else {
        event.setResult( lockAndLoad( event, persister, keyToLoad, loadType, event.getSession() ) );
      }
    }
  }
  catch (HibernateException e) {
    LOG.unableToLoadCommand( e );
    throw e;
  }
}

代码示例来源:origin: hibernate/hibernate-orm

final EntityKey key = source.generateEntityKey( id, persister );
persistenceContext.removeProxy( key );

代码示例来源:origin: hibernate/hibernate-orm

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

代码示例来源:origin: hibernate/hibernate-orm

key = source.generateEntityKey( id, persister );
Object old = source.getPersistenceContext().getEntity( key );
if ( old != null ) {

代码示例来源:origin: hibernate/hibernate-orm

final EntityKey key = session.generateEntityKey( entityEntry.getId(), persister );

代码示例来源:origin: hibernate/hibernate-orm

final EntityKey key = source.generateEntityKey( event.getRequestedId(), persister );

代码示例来源:origin: hibernate/hibernate-orm

final EntityKey key = regenerate ? null : source.generateEntityKey( id, persister );

代码示例来源:origin: hibernate/hibernate-orm

final EntityKey key = source.generateEntityKey( id, persister );
if ( source.getPersistenceContext().getEntry( key ) != null ) {
  throw new PersistentObjectException(
final EntityKey key = source.generateEntityKey( id, persister );
source.getPersistenceContext().removeEntity( key );
if ( persister.hasCollections() ) {

代码示例来源:origin: hibernate/hibernate-orm

Serializable id = persister.getIdentifier( entity, source );
if ( id != null ) {
  final EntityKey key = source.generateEntityKey( id, persister );
  final Object managedEntity = source.getPersistenceContext().getEntity( key );
  entry = source.getPersistenceContext().getEntry( managedEntity );

代码示例来源:origin: hibernate/hibernate-orm

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

代码示例来源:origin: org.hibernate/com.springsource.org.hibernate.core

private void loadByDerivedIdentitySimplePkValue(
    LoadEvent event,
    LoadEventListener.LoadType options,
    EntityPersister dependentPersister,
    EmbeddedComponentType dependentIdType,
    EntityPersister parentPersister) {
  final EntityKey parentEntityKey = event.getSession().generateEntityKey( event.getEntityId(), parentPersister );
  final Object parent = doLoad( event, parentPersister, parentEntityKey, options );
  final Serializable dependent = (Serializable) dependentIdType.instantiate( parent, event.getSession() );
  dependentIdType.setPropertyValues( dependent, new Object[] {parent}, dependentPersister.getEntityMode() );
  final EntityKey dependentEntityKey = event.getSession().generateEntityKey( dependent, dependentPersister );
  event.setEntityId( dependent );
  event.setResult( doLoad( event, dependentPersister, dependentEntityKey, options ) );
}

代码示例来源:origin: org.hibernate/com.springsource.org.hibernate

private void loadByDerivedIdentitySimplePkValue(
    LoadEvent event,
    LoadEventListener.LoadType options,
    EntityPersister dependentPersister,
    EmbeddedComponentType dependentIdType,
    EntityPersister parentPersister) {
  final EntityKey parentEntityKey = event.getSession().generateEntityKey( event.getEntityId(), parentPersister );
  final Object parent = doLoad( event, parentPersister, parentEntityKey, options );
  final Serializable dependent = (Serializable) dependentIdType.instantiate( parent, event.getSession() );
  dependentIdType.setPropertyValues( dependent, new Object[] {parent}, dependentPersister.getEntityMode() );
  final EntityKey dependentEntityKey = event.getSession().generateEntityKey( dependent, dependentPersister );
  event.setEntityId( dependent );
  event.setResult( doLoad( event, dependentPersister, dependentEntityKey, options ) );
}

代码示例来源:origin: org.hibernate.orm/hibernate-core

private boolean existsInDatabase(Object entity, EventSource source, EntityTypeDescriptor entityDescriptor) {
  EntityEntry entry = source.getPersistenceContext().getEntry( entity );
  if ( entry == null ) {
    Object id = entityDescriptor.getIdentifier( entity, source );
    if ( id != null ) {
      final EntityKey key = source.generateEntityKey( id, entityDescriptor );
      final Object managedEntity = source.getPersistenceContext().getEntity( key );
      entry = source.getPersistenceContext().getEntry( managedEntity );
    }
  }
  return entry != null && entry.isExistsInDatabase();
}

代码示例来源:origin: org.hibernate/com.springsource.org.hibernate

private boolean existsInDatabase(Object entity, EventSource source, EntityPersister persister) {
  EntityEntry entry = source.getPersistenceContext().getEntry( entity );
  if ( entry == null ) {
    Serializable id = persister.getIdentifier( entity, source );
    if ( id != null ) {
      final EntityKey key = source.generateEntityKey( id, persister );
      final Object managedEntity = source.getPersistenceContext().getEntity( key );
      entry = source.getPersistenceContext().getEntry( managedEntity );
    }
  }
  return entry != null && entry.isExistsInDatabase();
}

代码示例来源:origin: org.hibernate/com.springsource.org.hibernate.core

private boolean existsInDatabase(Object entity, EventSource source, EntityPersister persister) {
  EntityEntry entry = source.getPersistenceContext().getEntry( entity );
  if ( entry == null ) {
    Serializable id = persister.getIdentifier( entity, source );
    if ( id != null ) {
      final EntityKey key = source.generateEntityKey( id, persister );
      final Object managedEntity = source.getPersistenceContext().getEntity( key );
      entry = source.getPersistenceContext().getEntry( managedEntity );
    }
  }
  return entry != null && entry.isExistsInDatabase();
}

代码示例来源:origin: org.hibernate/com.springsource.org.hibernate

private void performReplication(
    Object entity,
    Serializable id,
    Object version,
    EntityPersister persister,
    ReplicationMode replicationMode,
    EventSource source) throws HibernateException {
  if ( LOG.isTraceEnabled() ) {
    LOG.tracev( "Replicating changes to {0}", MessageHelper.infoString( persister, id, source.getFactory() ) );
  }
  new OnReplicateVisitor( source, id, entity, true ).process( entity, persister );
  source.getPersistenceContext().addEntity(
      entity,
      ( persister.isMutable() ? Status.MANAGED : Status.READ_ONLY ),
      null,
      source.generateEntityKey( id, persister ),
      version,
      LockMode.NONE,
      true,
      persister,
      true,
      false
  );
  cascadeAfterReplicate( entity, persister, replicationMode, source );
}

代码示例来源:origin: org.hibernate.orm/hibernate-core

private void performReplication(
    Object entity,
    Object id,
    Object version,
    EntityTypeDescriptor entityDescriptor,
    ReplicationMode replicationMode,
    EventSource source) throws HibernateException {
  if ( LOG.isTraceEnabled() ) {
    LOG.tracev( "Replicating changes to {0}", MessageHelper.infoString( entityDescriptor, id, source.getFactory() ) );
  }
  new OnReplicateVisitor( source, id, entity, true ).process( entity, entityDescriptor );
  source.getPersistenceContext().addEntity(
      entity,
      ( entityDescriptor.getJavaTypeDescriptor().getMutabilityPlan().isMutable() ? Status.MANAGED : Status.READ_ONLY ),
      null,
      source.generateEntityKey( id, entityDescriptor ),
      version,
      LockMode.NONE,
      true,
      entityDescriptor,
      true
  );
  cascadeAfterReplicate( entity, entityDescriptor, replicationMode, source );
}

相关文章