本文整理汇总了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;
}
示例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();
}
示例3: refreshPessimistically
import javax.persistence.EntityManager; //导入方法依赖的package包/类
public static <T extends IscEntity> void refreshPessimistically(EntityManager em, T entity) {
em.refresh(entity, LockModeType.PESSIMISTIC_WRITE);
}
示例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();
}
}