当前位置: 首页>>代码示例>>Java>>正文


Java EntityManagerFactoryUtils.getTransactionalEntityManager方法代码示例

本文整理汇总了Java中org.springframework.orm.jpa.EntityManagerFactoryUtils.getTransactionalEntityManager方法的典型用法代码示例。如果您正苦于以下问题:Java EntityManagerFactoryUtils.getTransactionalEntityManager方法的具体用法?Java EntityManagerFactoryUtils.getTransactionalEntityManager怎么用?Java EntityManagerFactoryUtils.getTransactionalEntityManager使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在org.springframework.orm.jpa.EntityManagerFactoryUtils的用法示例。


在下文中一共展示了EntityManagerFactoryUtils.getTransactionalEntityManager方法的13个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。

示例1: extractIdPropertyNames

import org.springframework.orm.jpa.EntityManagerFactoryUtils; //导入方法依赖的package包/类
@Override
public String[] extractIdPropertyNames(Object entity)
{
    final EntityManager em = EntityManagerFactoryUtils.getTransactionalEntityManager(emf);
    final ClassDescriptor desc = em.unwrap(JpaEntityManager.class).getServerSession().getClassDescriptor(entity);
    if (desc != null)
    {
   	    final Collection<DatabaseMapping> fieldNames = desc.getMappings();
   	    final List<DatabaseMapping> tmp = new LinkedList<>();
   	    for (DatabaseMapping m : fieldNames)
   	    {
   	        if (m.isPrimaryKeyMapping())
   	        {
   	            tmp.add(m);
   	        }
   	    }
   	    final String[] retVal = new String[tmp.size()];
   	    for (int i = 0; i < retVal.length; i++)
   	    {
   	        retVal[i] = tmp.get(i).getAttributeName();
   	    }
   	    return retVal;
    }
    
    return null;
}
 
开发者ID:ethlo,项目名称:dachs,代码行数:27,代码来源:EclipselinkLazyIdExtractor.java

示例2: getEntityManager

import org.springframework.orm.jpa.EntityManagerFactoryUtils; //导入方法依赖的package包/类
private EntityManager getEntityManager() {
    EntityManager em = EntityManagerFactoryUtils.getTransactionalEntityManager(emf);
    if (em == null) {
        return emf.createEntityManager();
    }
    return em;
}
 
开发者ID:snowdrop,项目名称:spring-data-snowdrop,代码行数:8,代码来源:JpaDatasourceMapper.java

示例3: applyQueryImpl

import org.springframework.orm.jpa.EntityManagerFactoryUtils; //导入方法依赖的package包/类
protected void applyQueryImpl(Query query) {
    EntityManager em = EntityManagerFactoryUtils.getTransactionalEntityManager(emf);
    if (em == null) {
        entityManager = emf.createEntityManager();
        em = entityManager;
    }
    FullTextSession fullTextSession = Search.getFullTextSession(em.unwrap(Session.class));
    fullTextQuery = fullTextSession.createFullTextQuery(query, entityClass);
}
 
开发者ID:snowdrop,项目名称:spring-data-snowdrop,代码行数:10,代码来源:JpaDatasourceMapper.java

示例4: getEntityManager

import org.springframework.orm.jpa.EntityManagerFactoryUtils; //导入方法依赖的package包/类
/**
 * Return the underlying {@link EntityManager} that's actually used to perform all
 * operations.
 * @return the entity manager
 */
public final EntityManager getEntityManager() {
	EntityManager manager = EntityManagerFactoryUtils
			.getTransactionalEntityManager(this.entityManagerFactory);
	Assert.state(manager != null, "No transactional EntityManager found");
	return manager;
}
 
开发者ID:vikrammane23,项目名称:https-github.com-g0t4-jenkins2-course-spring-boot,代码行数:12,代码来源:TestEntityManager.java

示例5: openSession

import org.springframework.orm.jpa.EntityManagerFactoryUtils; //导入方法依赖的package包/类
@Override
public Session openSession() {
    EntityManager entityManager = EntityManagerFactoryUtils.getTransactionalEntityManager(entityManagerFactory);
    if (entityManager == null) {
        return new EntityManagerSessionImpl(entityManagerFactory, handleTransactions, closeEntityManager);
    }
    return new EntityManagerSessionImpl(entityManagerFactory, entityManager, false, false);
}
 
开发者ID:flowable,项目名称:flowable-engine,代码行数:9,代码来源:SpringEntityManagerSessionFactory.java

示例6: openSession

import org.springframework.orm.jpa.EntityManagerFactoryUtils; //导入方法依赖的package包/类
@Override
public Session openSession(CommandContext commandContext) {
    EntityManager entityManager = EntityManagerFactoryUtils.getTransactionalEntityManager(entityManagerFactory);
    if (entityManager == null) {
        return new EntityManagerSessionImpl(entityManagerFactory, handleTransactions, closeEntityManager);
    }
    return new EntityManagerSessionImpl(entityManagerFactory, entityManager, false, false);
}
 
开发者ID:flowable,项目名称:flowable-engine,代码行数:9,代码来源:SpringEntityManagerSessionFactory.java

示例7: openSession

import org.springframework.orm.jpa.EntityManagerFactoryUtils; //导入方法依赖的package包/类
public Session openSession() {
  EntityManager entityManager = EntityManagerFactoryUtils.getTransactionalEntityManager(entityManagerFactory);
  if (entityManager == null) {
    return new EntityManagerSessionImpl(entityManagerFactory, handleTransactions, closeEntityManager);
  }
  return new EntityManagerSessionImpl(entityManagerFactory, entityManager, false, false);
}
 
开发者ID:logicalhacking,项目名称:SecureBPMN,代码行数:8,代码来源:SpringEntityManagerSessionFactory.java

示例8: getEM

import org.springframework.orm.jpa.EntityManagerFactoryUtils; //导入方法依赖的package包/类
/**
 * Return the Entity Manager
 * 
 * @return The Entity Manager
 */
public EntityManager getEM( )
{
    EntityManagerFactory emf = getEntityManagerFactory( );

    if ( TransactionSynchronizationManager.isSynchronizationActive( ) )
    {
        // first, get Spring entitymanager (if available)
        try
        {
            EntityManager em = EntityManagerFactoryUtils.getTransactionalEntityManager( emf );

            if ( em == null )
            {
                LOG.error( "getEM(  ) : no EntityManager found. Will use native entity manager factory [Transaction will not be supported]" );
            }
            else
            {
                LOG.debug( "EntityManager found for the current transaction : " + em.toString( ) + " - using Factory : " + emf.toString( ) );

                return em;
            }
        }
        catch( DataAccessResourceFailureException ex )
        {
            LOG.error( ex );
        }
    }

    LOG.error( "getEM(  ) : no EntityManager found. Will use native entity manager factory [Transaction will not be supported]" );

    if ( _defaultEM == null )
    {
        _defaultEM = emf.createEntityManager( );
    }
    return _defaultEM;
}
 
开发者ID:lutece-platform,项目名称:lutece-core,代码行数:42,代码来源:JPAGenericDAO.java

示例9: setUp

import org.springframework.orm.jpa.EntityManagerFactoryUtils; //导入方法依赖的package包/类
@Before
public void setUp() {
    TransactionSynchronizationManager.initSynchronization();
    em = EntityManagerFactoryUtils.getTransactionalEntityManager(emf);
}
 
开发者ID:snowdrop,项目名称:spring-data-snowdrop,代码行数:6,代码来源:JpaCrudTest.java

示例10: doGetPersistenceContext

import org.springframework.orm.jpa.EntityManagerFactoryUtils; //导入方法依赖的package包/类
protected EntityManager doGetPersistenceContext(Object testObject) {
	return EntityManagerFactoryUtils.getTransactionalEntityManager(getPersistenceUnit(testObject));
}
 
开发者ID:linux-china,项目名称:unitils,代码行数:4,代码来源:JpaModule.java

示例11: initializeFixture

import org.springframework.orm.jpa.EntityManagerFactoryUtils; //导入方法依赖的package包/类
@Before
public void initializeFixture() {
	person = new Person(1L, "johnDoe");
	entityManager = EntityManagerFactoryUtils.getTransactionalEntityManager(entityManagerFactory);
}
 
开发者ID:linux-china,项目名称:unitils,代码行数:6,代码来源:HibernateJpaJotmSpringTest.java

示例12: getEntityManager

import org.springframework.orm.jpa.EntityManagerFactoryUtils; //导入方法依赖的package包/类
/**
 * 根据领域类(实体类),返回EmtityManager
 * @param domainClass 领域类(实体类)
 * @param <T> 领域类(实体类)范型
 * @return EntityManager
 */
public static <T> EntityManager getEntityManager(Class<T> domainClass) {
	EntityManagerFactory emf = getEntityManagerFactoryStrategy.getEntityManagerFactory(domainClass);
	return EntityManagerFactoryUtils.getTransactionalEntityManager(emf);
}
 
开发者ID:muxiangqiu,项目名称:linq,代码行数:11,代码来源:JpaUtil.java

示例13: getEntityManager

import org.springframework.orm.jpa.EntityManagerFactoryUtils; //导入方法依赖的package包/类
/**
 * Get entity manager for the current transaction
 * @return
 */
protected EntityManager getEntityManager() {
    return EntityManagerFactoryUtils.getTransactionalEntityManager(entityManagerFactory);
}
 
开发者ID:zralock,项目名称:CTUConference,代码行数:8,代码来源:AbstractDAO.java


注:本文中的org.springframework.orm.jpa.EntityManagerFactoryUtils.getTransactionalEntityManager方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。