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


Java EntityManager.refresh方法代码示例

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


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

示例1: refresh

import javax.persistence.EntityManager; //导入方法依赖的package包/类
public static Candidates refresh(Candidates candidate) {
    if (candidate != null) {
        EntityManager em = EMFUtil.getEMFactory().createEntityManager();
        EntityTransaction trans = em.getTransaction();
        em.refresh(candidate);
        return candidate;
    }
    return null;
}
 
开发者ID:faizan-ali,项目名称:full-javaee-app,代码行数:10,代码来源:CandidatePersistence.java

示例2: testHandle

import javax.persistence.EntityManager; //导入方法依赖的package包/类
/**
 * Test of handle method, of class Task.
 * @throws java.lang.Exception
 * @deprecated has to be implemented on a case by case basis
 */
@Test
public void testHandle() throws Exception {
    System.out.println("handle");
    EntityManager manager = new PersistenceProvider().get();
    manager.getTransaction().begin();
    IOUtils.copyAndClose(
        getClass().getResourceAsStream("/test.txt"),
        FileUtils.openOutputStream(new File(getAllowedFolder()+"/steamapps/common/Stellaris/test.txt"))
    );
    Original original = new Original("test.txt");
    manager.persist(original);
    manager.getTransaction().commit();
    List<ProcessTask> result = get(original.getAid()).handle(manager);
    Assert.assertEquals(
        "Follow-up number is wrong",
        1,
        result.size()
    );
    manager.getTransaction().begin();
    manager.refresh(original);
    Assert.assertTrue(
        "Content was not written",
        original.getContent().length() > 0
    );
    manager.getTransaction().commit();
}
 
开发者ID:Idrinths-Stellaris-Mods,项目名称:Mod-Tools,代码行数:32,代码来源:OriginalFileFillerTest.java

示例3: refreshPessimistically

import javax.persistence.EntityManager; //导入方法依赖的package包/类
public static <T extends IscEntity> void refreshPessimistically(EntityManager em, T entity) {
    em.refresh(entity, LockModeType.PESSIMISTIC_WRITE);
}
 
开发者ID:opensecuritycontroller,项目名称:osc-core,代码行数:4,代码来源:OSCEntityManager.java

示例4: refresh

import javax.persistence.EntityManager; //导入方法依赖的package包/类
public void refresh(final AbstractBO<?> aBO) {

        if (!aBO.getEditingContext().equals(this)) {
            throw new IllegalStateException();
        }

        final EntityManager tmpEntityManager = myEntityManager;
        final EntityTransaction tmpTransaction = tmpEntityManager.getTransaction();

        tmpTransaction.begin();

        tmpEntityManager.refresh(aBO.getEntityBean());

        try {

            tmpTransaction.commit();

        } catch (final Exception anException) {

            BasicLogger.error(anException.toString());

            if ((tmpTransaction != null) && tmpTransaction.isActive()) {
                tmpTransaction.rollback();
            }

        } finally {

            this.flushCaches();
        }
    }
 
开发者ID:optimatika,项目名称:ojAlgo-extensions,代码行数:31,代码来源:EditingContext.java


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