本文整理汇总了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;
}
示例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;
}
示例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);
}
示例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);
}
示例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);
}
示例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);
}
示例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;
}
示例9: setUp
import org.springframework.orm.jpa.EntityManagerFactoryUtils; //导入方法依赖的package包/类
@Before
public void setUp() {
TransactionSynchronizationManager.initSynchronization();
em = EntityManagerFactoryUtils.getTransactionalEntityManager(emf);
}
示例10: doGetPersistenceContext
import org.springframework.orm.jpa.EntityManagerFactoryUtils; //导入方法依赖的package包/类
protected EntityManager doGetPersistenceContext(Object testObject) {
return EntityManagerFactoryUtils.getTransactionalEntityManager(getPersistenceUnit(testObject));
}
示例11: initializeFixture
import org.springframework.orm.jpa.EntityManagerFactoryUtils; //导入方法依赖的package包/类
@Before
public void initializeFixture() {
person = new Person(1L, "johnDoe");
entityManager = EntityManagerFactoryUtils.getTransactionalEntityManager(entityManagerFactory);
}
示例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);
}
示例13: getEntityManager
import org.springframework.orm.jpa.EntityManagerFactoryUtils; //导入方法依赖的package包/类
/**
* Get entity manager for the current transaction
* @return
*/
protected EntityManager getEntityManager() {
return EntityManagerFactoryUtils.getTransactionalEntityManager(entityManagerFactory);
}