List of usage examples for javax.persistence EntityManager flush
public void flush();
From source file:portal.api.impl.PortalJpaController.java
public void saveMANOplatform(MANOplatform mp) { logger.info("Will save MANOplatform = " + mp.getName()); EntityManager entityManager = entityManagerFactory.createEntityManager(); EntityTransaction entityTransaction = entityManager.getTransaction(); entityTransaction.begin();//from w w w . ja v a 2s . c o m entityManager.persist(mp); entityManager.flush(); entityTransaction.commit(); }
From source file:portal.api.impl.PortalJpaController.java
public void saveProperty(PortalProperty p) { logger.info("Will PortalProperty = " + p.getName()); EntityManager entityManager = entityManagerFactory.createEntityManager(); EntityTransaction entityTransaction = entityManager.getTransaction(); entityTransaction.begin();/*from w ww. j a v a2s . c om*/ entityManager.persist(p); entityManager.flush(); entityTransaction.commit(); }
From source file:portal.api.impl.PortalJpaController.java
public void saveInstalledVxF(InstalledVxF is) { logger.info("Will create InstalledVxF = " + is.getUuid()); EntityManager entityManager = entityManagerFactory.createEntityManager(); EntityTransaction entityTransaction = entityManager.getTransaction(); entityTransaction.begin();/*from w w w .ja v a2 s .com*/ entityManager.persist(is); entityManager.flush(); entityTransaction.commit(); }
From source file:portal.api.impl.PortalJpaController.java
public void saveUser(PortalUser bu) { logger.info("Will save PortalUser = " + bu.getName()); EntityManager entityManager = entityManagerFactory.createEntityManager(); EntityTransaction entityTransaction = entityManager.getTransaction(); entityTransaction.begin();//w w w . j a va 2s . c o m entityManager.persist(bu); entityManager.flush(); entityTransaction.commit(); }
From source file:portal.api.impl.PortalJpaController.java
public void saveMANOprovider(MANOprovider mprovider) { logger.info("Will save MANOprovider = " + mprovider.getName()); EntityManager entityManager = entityManagerFactory.createEntityManager(); EntityTransaction entityTransaction = entityManager.getTransaction(); entityTransaction.begin();//from w w w . j ava 2 s .c om entityManager.persist(mprovider); entityManager.flush(); entityTransaction.commit(); }
From source file:portal.api.impl.PortalJpaController.java
public void saveVxFOnBoardedDescriptor(VxFOnBoardedDescriptor mprovider) { logger.info("Will save VxFOnBoardedDescriptor = " + mprovider.getDeployId()); EntityManager entityManager = entityManagerFactory.createEntityManager(); EntityTransaction entityTransaction = entityManager.getTransaction(); entityTransaction.begin();// ww w . j ava 2 s . c o m entityManager.persist(mprovider); entityManager.flush(); entityTransaction.commit(); }
From source file:portal.api.impl.PortalJpaController.java
public void saveExperimentOnBoardDescriptor(ExperimentOnBoardDescriptor mprovider) { logger.info("Will save ExperimentOnBoardDescriptors = " + mprovider.getDeployId()); EntityManager entityManager = entityManagerFactory.createEntityManager(); EntityTransaction entityTransaction = entityManager.getTransaction(); entityTransaction.begin();//from ww w.j av a2s . co m entityManager.persist(mprovider); entityManager.flush(); entityTransaction.commit(); }
From source file:com.espirit.moddev.examples.uxbridge.newsdrilldown.test.NewsITCase.java
/** * Test persistence./* w ww . j a v a 2 s. c o m*/ * * @throws Exception the exception */ @Test public void testPersistence() throws Exception { long size = countNews(); EntityManager em = emf.createEntityManager(); EntityTransaction tx = null; try { tx = em.getTransaction(); tx.begin(); News news = new News(); news.setContent("Spider-man was seen."); news.setHeadline("The amazing spider-man"); news.setFs_id(1l); news.setLanguage("DE"); news.setTeaser("spider-man"); NewsCategory sport = new NewsCategory(); sport.setFs_id(2l); sport.setName("Sport"); sport.setLanguage("DE"); NewsMetaCategory soccer = new NewsMetaCategory(); soccer.setFs_id(3l); soccer.setLanguage("DE"); soccer.setName("Fussball"); if (sport.getMetaCategories() == null) { sport.setMetaCategories(new ArrayList<NewsMetaCategory>()); } sport.getMetaCategories().add(soccer); if (news.getCategories() == null) { news.setCategories(new ArrayList<NewsCategory>()); } news.getCategories().add(sport); em.persist(news); em.flush(); tx.commit(); assertEquals("Entity not filled", size + 1, countNews()); Query query = em.createQuery("SELECT mc FROM metaCategory mc WHERE fs_id=3"); NewsMetaCategory metaCat = (NewsMetaCategory) query.getSingleResult(); assertNotNull(metaCat); query = em.createQuery( "SELECT c FROM category c join c.metaCategories mc WHERE mc.fs_id=" + metaCat.getFs_id()); NewsCategory category = (NewsCategory) query.getSingleResult(); assertNotNull(category); query = em.createQuery("SELECT n FROM news n join n.categories c WHERE c.fs_id=" + category.getFs_id()); News n = (News) query.getSingleResult(); assertNotNull(n); } finally { if (tx != null && tx.isActive()) { tx.rollback(); } em.close(); } }
From source file:com.formkiq.web.AbstractIntegrationTest.java
/** * Migrate System Properties from migration scripts. * @param em {@link EntityManager}//from w ww . j ava2s . c o m */ private void migrateSystemProperties(final EntityManager em) { this.systemDao.save(new SystemProperty("version", "0.0")); this.systemDao.save(new SystemProperty("inviteonly", "true")); this.systemDao.save(new SystemProperty("assetservice_db", "true")); this.systemDao.save(new SystemProperty("assetservice_s3", "false")); em.flush(); try { List<String> sqls = getDBSystemPropertiesMigrationScripts(); for (String sql : sqls) { em.createNativeQuery(sql).executeUpdate(); } } catch (IOException e) { throw new RuntimeException(e); } }
From source file:portal.api.impl.PortalJpaController.java
public void deleteAllUsers() { EntityManager entityManager = entityManagerFactory.createEntityManager(); EntityTransaction entityTransaction = entityManager.getTransaction(); entityTransaction.begin();//from w w w .ja v a2 s .c o m Query q = entityManager.createQuery("DELETE FROM PortalUser "); q.executeUpdate(); entityManager.flush(); entityTransaction.commit(); }