當前位置: 首頁>>代碼示例>>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;未經允許,請勿轉載。