热门标签 | HotTags
当前位置:  开发笔记 > 编程语言 > 正文

深入解析org.hibernate.event.spi.EventSource.getFactory()方法及其应用实例

本文整理了Java中org.hibernate.event.spi.EventSource.getFactory()方法的一些代码示例,展示了EventSource.getFactory()的具体用法

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

EventSource.getFactory介绍

暂无

代码示例

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

private Iterable postLoadEventListeners(EventSource session) {
return session
.getFactory()
.getServiceRegistry()
.getService( EventListenerRegistry.class )
.getEventListenerGroup( EventType.POST_LOAD )
.listeners();
}

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

protected EntityPersister getPersister( final LoadEvent event ) {
if ( event.getInstanceToLoad() != null ) {
//the load() which takes an entity does not pass an entityName
event.setEntityClassName( event.getInstanceToLoad().getClass().getName() );
return event.getSession().getEntityPersister(
null,
event.getInstanceToLoad()
);
}
else {
return event.getSession().getFactory().getEntityPersister( event.getEntityClassName() );
}
}

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

public boolean onPreUpdate(PreUpdateEvent event) {
validate(
event.getEntity(), event.getPersister().getEntityMode(), event.getPersister(),
event.getSession().getFactory(), GroupsPerOperation.Operation.UPDATE
);
return false;
}

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

public boolean onPreInsert(PreInsertEvent event) {
validate(
event.getEntity(), event.getPersister().getEntityMode(), event.getPersister(),
event.getSession().getFactory(), GroupsPerOperation.Operation.INSERT
);
return false;
}

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

public boolean onPreDelete(PreDeleteEvent event) {
validate(
event.getEntity(), event.getPersister().getEntityMode(), event.getPersister(),
event.getSession().getFactory(), GroupsPerOperation.Operation.DELETE
);
return false;
}

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

/**
* Schedules a collection for deletion.
*
* @param role The persister representing the collection to be removed.
* @param collectionKey The collection key (differs from owner-id in the case of property-refs).
* @param source The session from which the request originated.
*
* @throws HibernateException
*/
void removeCollection(CollectionPersister role, Serializable collectionKey, EventSource source)
throws HibernateException {
if ( LOG.isTraceEnabled() ) {
LOG.tracev(
"Collection dereferenced while transient {0}",
MessageHelper.collectionInfoString( role, ownerIdentifier, source.getFactory() )
);
}
source.getActionQueue().addAction( new CollectionRemoveAction( owner, role, collectionKey, false, source ) );
}

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

@SuppressWarnings({"unchecked"})
private void entityIsDeleted(PersistEvent event, Map createCache) {
final EventSource source = event.getSession();
final Object entity = source.getPersistenceContext().unproxy( event.getObject() );
final EntityPersister persister = source.getEntityPersister( event.getEntityName(), entity );
LOG.tracef(
"un-scheduling entity deletion [%s]",
MessageHelper.infoString(
persister,
persister.getIdentifier( entity, source ),
source.getFactory()
)
);
if ( createCache.put( entity, entity ) == null ) {
justCascade( createCache, source, entity, persister );
}
}
}

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

/**
* Performs the process of loading an entity from the configured
* underlying datasource.
*
* @param event The load event
* @param persister The persister for the entity being requested for load
*
* @return The object loaded from the datasource, or null if not found.
*/
protected Object loadFromDatasource(
final LoadEvent event,
final EntityPersister persister) {
Object entity = persister.load(
event.getEntityId(),
event.getInstanceToLoad(),
event.getLockOptions(),
event.getSession()
);
if ( event.isAssociationFetch() && event.getSession().getFactory().getStatistics().isStatisticsEnabled() ) {
event.getSession().getFactory().getStatistics().fetchEntity( event.getEntityClassName() );
}
return entity;
}

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

final Iterable flushListeners = source.getFactory().getServiceRegistry()
.getService( EventListenerRegistry.class )
.getEventListenerGroup( EventType.FLUSH_ENTITY )

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

/**
* Reattach a detached (disassociated) initialized or uninitialized
* collection wrapper, using a snapshot carried with the collection
* wrapper
*/
protected void reattachCollection(PersistentCollection collection, CollectionType type)
throws HibernateException {
if ( collection.wasInitialized() ) {
CollectionPersister collectiOnPersister= getSession().getFactory()
.getCollectionPersister( type.getRole() );
getSession().getPersistenceContext()
.addInitializedDetachedCollection( collectionPersister, collection );
}
else {
if ( !isCollectionSnapshotValid(collection) ) {
throw new HibernateException( "could not reassociate uninitialized transient collection" );
}
CollectionPersister collectiOnPersister= getSession().getFactory()
.getCollectionPersister( collection.getRole() );
getSession().getPersistenceContext()
.addUninitializedDetachedCollection( collectionPersister, collection );
}
}

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

@Override
public void noCascade(
EventSource session,
Object parent,
EntityPersister persister,
Type propertyType,
int propertyIndex) {
if ( propertyType.isEntityType() ) {
Object child = persister.getPropertyValue( parent, propertyIndex );
String childEntityName = ((EntityType) propertyType).getAssociatedEntityName( session.getFactory() );
if ( child != null
&& !isInManagedState( child, session )
&& !(child instanceof HibernateProxy) //a proxy cannot be transient and it breaks ForeignKeys.isTransient
&& ForeignKeys.isTransient( childEntityName, child, null, session ) ) {
String parentEntityName = persister.getEntityName();
String propertyName = persister.getPropertyNames()[propertyIndex];
throw new TransientPropertyValueException(
"object references an unsaved transient instance - save the transient instance before flushing",
childEntityName,
parentEntityName,
propertyName
);
}
}
}

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

if ( source.getFactory().getStatistics().isStatisticsEnabled() ) {
source.getFactory().getStatistics().flush();

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

private void evictCachedCollections(Type[] types, Serializable id, EventSource source)
throws HibernateException {
for ( Type type : types ) {
if ( type.isCollectionType() ) {
CollectionPersister collectiOnPersister= source.getFactory().getMetamodel().collectionPersister( ( (CollectionType) type ).getRole() );
if ( collectionPersister.hasCache() ) {
final CollectionDataAccess cache = collectionPersister.getCacheAccessStrategy();
final Object ck = cache.generateCacheKey(
id,
collectionPersister,
source.getFactory(),
source.getTenantIdentifier()
);
final SoftLock lock = cache.lockItem( source, ck, null );
cache.remove( source, ck );
source.getActionQueue().registerProcess( (success, session) -> cache.unlockItem( session, ck, lock ) );
}
}
else if ( type.isComponentType() ) {
CompositeType actype = (CompositeType) type;
evictCachedCollections( actype.getSubtypes(), id, source );
}
}
}
}

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

/**
* Handle the given merge event.
*
* @param event The merge event to be handled.
*
* @throws HibernateException
*/
public void onMerge(MergeEvent event) throws HibernateException {
final EntityCopyObserver entityCopyObserver = createEntityCopyObserver( event.getSession().getFactory() );
final MergeContext mergeCOntext= new MergeContext( event.getSession(), entityCopyObserver );
try {
onMerge( event, mergeContext );
entityCopyObserver.topLevelMergeComplete( event.getSession() );
}
finally {
entityCopyObserver.clear();
mergeContext.clear();
}
}

代码示例来源: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

CollectionPersister persister = session.getFactory().getCollectionPersister( type.getRole() );

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

private boolean isUpdateNecessary(final FlushEntityEvent event, final boolean mightBeDirty) {
final Status status = event.getEntityEntry().getStatus();
if ( mightBeDirty || status == Status.DELETED ) {
// compare to cached state (ignoring collections unless versioned)
dirtyCheck( event );
if ( isUpdateNecessary( event ) ) {
return true;
}
else {
if ( SelfDirtinessTracker.class.isInstance( event.getEntity() ) ) {
( (SelfDirtinessTracker) event.getEntity() ).$$_hibernate_clearDirtyAttributes();
}
event.getSession()
.getFactory()
.getCustomEntityDirtinessStrategy()
.resetDirty( event.getEntity(), event.getEntityEntry().getPersister(), event.getSession() );
return false;
}
}
else {
return hasDirtyCollections( event, event.getEntityEntry().getPersister(), status );
}
}

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

@SuppressWarnings( value = {"unchecked"} )
private void logFlushResults(FlushEvent event) {
if ( !LOG.isDebugEnabled() ) {
return;
}
final EventSource session = event.getSession();
final PersistenceContext persistenceCOntext= session.getPersistenceContext();
LOG.debugf(
"Flushed: %s insertions, %s updates, %s deletions to %s objects",
session.getActionQueue().numberOfInsertions(),
session.getActionQueue().numberOfUpdates(),
session.getActionQueue().numberOfDeletions(),
persistenceContext.getNumberOfManagedEntities()
);
LOG.debugf(
"Flushed: %s (re)creations, %s updates, %s removals to %s collections",
session.getActionQueue().numberOfCollectionCreations(),
session.getActionQueue().numberOfCollectionUpdates(),
session.getActionQueue().numberOfCollectionRemovals(),
persistenceContext.getCollectionEntries().size()
);
new EntityPrinter( session.getFactory() ).toString(
persistenceContext.getEntitiesByKey().entrySet()
);
}

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

@Override
public Object processCollection(Object collection, CollectionType type) throws HibernateException {
if ( collection == CollectionType.UNFETCHED_COLLECTION ) {
return null;
}
final EventSource session = getSession();
final CollectionPersister persister = session.getFactory().getMetamodel().collectionPersister( type.getRole() );
if ( isUpdate ) {
removeCollection( persister, extractCollectionKeyFromOwner( persister ), session );
}
if ( collection != null && collection instanceof PersistentCollection ) {
final PersistentCollection wrapper = (PersistentCollection) collection;
wrapper.setCurrentSession( (SessionImplementor) session );
if ( wrapper.wasInitialized() ) {
session.getPersistenceContext().addNewCollection( persister, wrapper );
}
else {
reattachCollection( wrapper, type );
}
}
else {
// otherwise a null or brand new collection
// this will also (inefficiently) handle arrays, which
// have no snapshot, so we can't do any better
//processArrayOrNewCollection(collection, type);
}
return null;
}

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

LOG.tracev(
"Loading entity: {0}",
MessageHelper.infoString( persister, event.getEntityId(), event.getSession().getFactory() )
);

推荐阅读
  • 本文介绍如何使用布局文件在Android应用中排列多行TextView和Button,使其占据屏幕的特定比例,并提供示例代码以帮助理解和实现。 ... [详细]
  • 本文详细探讨了JDBC(Java数据库连接)的内部机制,重点分析其作为服务提供者接口(SPI)框架的应用。通过类图和代码示例,展示了JDBC如何注册驱动程序、建立数据库连接以及执行SQL查询的过程。 ... [详细]
  • 本题探讨如何通过最大流算法解决农场排水系统的设计问题。题目要求计算从水源点到汇合点的最大水流速率,使用经典的EK(Edmonds-Karp)和Dinic算法进行求解。 ... [详细]
  • 毕业设计:基于机器学习与深度学习的垃圾邮件(短信)分类算法实现
    本文详细介绍了如何使用机器学习和深度学习技术对垃圾邮件和短信进行分类。内容涵盖从数据集介绍、预处理、特征提取到模型训练与评估的完整流程,并提供了具体的代码示例和实验结果。 ... [详细]
  • 深入解析 Spring Security 用户认证机制
    本文将详细介绍 Spring Security 中用户登录认证的核心流程,重点分析 AbstractAuthenticationProcessingFilter 和 AuthenticationManager 的工作原理。通过理解这些组件的实现,读者可以更好地掌握 Spring Security 的认证机制。 ... [详细]
  • 探讨如何真正掌握Java EE,包括所需技能、工具和实践经验。资深软件教学总监李刚分享了对毕业生简历中常见问题的看法,并提供了详尽的标准。 ... [详细]
  • 本文探讨了在使用Azure Active Directory进行用户身份验证时,结合AddAuthentication和RequireAuthenticatedUser的必要性及其潜在冗余问题。 ... [详细]
  • 本文介绍了 Winter-1-C A + B II 问题的详细解题思路和测试数据。该问题要求计算两个大整数的和,并输出结果。我们将深入探讨如何处理大整数运算,确保在给定的时间和内存限制下正确求解。 ... [详细]
  • 本文介绍了一种根据用户选择动态切换屏幕界面的方法,通过定义不同的选择块(Selection Block),实现灵活的用户交互体验。 ... [详细]
  • 哈密顿回路问题旨在寻找一个简单回路,该回路包含图中的每个顶点。本文将介绍如何判断给定的路径是否构成哈密顿回路。 ... [详细]
  • 本文深入探讨了HTTP请求和响应对象的使用,详细介绍了如何通过响应对象向客户端发送数据、处理中文乱码问题以及常见的HTTP状态码。此外,还涵盖了文件下载、请求重定向、请求转发等高级功能。 ... [详细]
  • PHP 过滤器详解
    本文深入探讨了 PHP 中的过滤器机制,包括常见的 $_SERVER 变量、filter_has_var() 函数、filter_id() 函数、filter_input() 函数及其数组形式、filter_list() 函数以及 filter_var() 和其数组形式。同时,详细介绍了各种过滤器的用途和用法。 ... [详细]
  • 本题探讨了在一个有向图中,如何根据特定规则将城市划分为若干个区域,使得每个区域内的城市之间能够相互到达,并且划分的区域数量最少。题目提供了时间限制和内存限制,要求在给定的城市和道路信息下,计算出最少需要划分的区域数量。 ... [详细]
  • 本文详细探讨了HTML表单中GET和POST请求的区别,包括它们的工作原理、数据传输方式、安全性及适用场景。同时,通过实例展示了如何在Servlet中处理这两种请求。 ... [详细]
  • 本文详细介绍了 org.apache.commons.io.IOCase 类中的 checkCompareTo() 方法,通过多个代码示例展示其在不同场景下的使用方法。 ... [详细]
author-avatar
diuhunpo_813
这个家伙很懒,什么也没留下!
PHP1.CN | 中国最专业的PHP中文社区 | DevBox开发工具箱 | json解析格式化 |PHP资讯 | PHP教程 | 数据库技术 | 服务器技术 | 前端开发技术 | PHP框架 | 开发工具 | 在线工具
Copyright © 1998 - 2020 PHP1.CN. All Rights Reserved | 京公网安备 11010802041100号 | 京ICP备19059560号-4 | PHP1.CN 第一PHP社区 版权所有