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


Java EntityManager.flush方法代码示例

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


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

示例1: createEntity

import javax.persistence.EntityManager; //导入方法依赖的package包/类
/**
 * Create an entity for this test.
 *
 * This is a static method, as tests for other entities might also need it,
 * if they test an entity which requires the current entity.
 */
public static Vote createEntity(EntityManager em) {
    Vote vote = new Vote()
        .userKey(DEFAULT_USER_KEY)
        .value(DEFAULT_VALUE)
        .message(DEFAULT_MESSAGE)
        .entryDate(DEFAULT_ENTRY_DATE);
    // Add required entity
    XmEntity xmEntity = XmEntityResourceIntTest.createEntity(em);
    em.persist(xmEntity);
    em.flush();
    vote.setXmEntity(xmEntity);

    Rating rating = RatingResourceIntTest.createEntity(em);
    em.persist(rating);
    em.flush();
    vote.setRating(rating);
    return vote;
}
 
开发者ID:xm-online,项目名称:xm-ms-entity,代码行数:25,代码来源:VoteResourceIntTest.java

示例2: createEntity

import javax.persistence.EntityManager; //导入方法依赖的package包/类
/**
 * Create an entity for this test.
 *
 * This is a static method, as tests for other entities might also need it,
 * if they test an entity which requires the current entity.
 */
public static Attachment createEntity(EntityManager em) {
    Attachment attachment = new Attachment()
        .typeKey(DEFAULT_TYPE_KEY)
        .name(DEFAULT_NAME)
        .contentUrl(DEFAULT_CONTENT_URL)
        .description(DEFAULT_DESCRIPTION)
        .startDate(DEFAULT_START_DATE)
        .endDate(DEFAULT_END_DATE)
        .valueContentType(DEFAULT_VALUE_CONTENT_TYPE)
        .valueContentSize(DEFAULT_VALUE_CONTENT_SIZE);
    // Add required entity
    XmEntity xmEntity = XmEntityResourceIntTest.createEntity(em);
    em.persist(xmEntity);
    em.flush();
    attachment.setXmEntity(xmEntity);
    return attachment;
}
 
开发者ID:xm-online,项目名称:xm-ms-entity,代码行数:24,代码来源:AttachmentResourceIntTest.java

示例3: createEntity

import javax.persistence.EntityManager; //导入方法依赖的package包/类
/**
 * Create an entity for this test.
 *
 * This is a static method, as tests for other entities might also need it,
 * if they test an entity which requires the current entity.
 */
public static Location createEntity(EntityManager em) {
    Location location = new Location()
        .typeKey(DEFAULT_TYPE_KEY)
        .countryKey(DEFAULT_COUNTRY_KEY)
        .longitude(DEFAULT_LONGITUDE)
        .latitude(DEFAULT_LATITUDE)
        .name(DEFAULT_NAME)
        .addressLine1(DEFAULT_ADDRESS_LINE_1)
        .addressLine2(DEFAULT_ADDRESS_LINE_2)
        .city(DEFAULT_CITY)
        .region(DEFAULT_REGION)
        .zip(DEFAULT_ZIP);
    // Add required entity
    XmEntity xmEntity = XmEntityResourceIntTest.createEntity(em);
    em.persist(xmEntity);
    em.flush();
    location.setXmEntity(xmEntity);
    return location;
}
 
开发者ID:xm-online,项目名称:xm-ms-entity,代码行数:26,代码来源:LocationResourceIntTest.java

示例4: createEntity

import javax.persistence.EntityManager; //导入方法依赖的package包/类
/**
 * Create an entity for this test.
 *
 * This is a static method, as tests for other entities might also need it,
 * if they test an entity which requires the current entity.
 */
public static Link createEntity(EntityManager em) {
    Link link = new Link()
        .typeKey(DEFAULT_TYPE_KEY)
        .name(DEFAULT_NAME)
        .description(DEFAULT_DESCRIPTION)
        .startDate(DEFAULT_START_DATE)
        .endDate(DEFAULT_END_DATE);
    // Add required entity
    XmEntity target = XmEntityResourceIntTest.createEntity(em);
    em.persist(target);
    em.flush();
    link.setTarget(target);
    // Add required entity
    XmEntity source = XmEntityResourceIntTest.createEntity(em);
    em.persist(source);
    em.flush();
    link.setSource(source);
    return link;
}
 
开发者ID:xm-online,项目名称:xm-ms-entity,代码行数:26,代码来源:LinkResourceIntTest.java

示例5: removeAll

import javax.persistence.EntityManager; //导入方法依赖的package包/类
/**
 * Removes all entities from database.
 */
public void removeAll() {
    EntityManager em = HibernateUtil.getEntityManagerFactory().createEntityManager();

    em.getTransaction().begin();

    for (T t : findAll()) {
        em.remove(em.merge(t));
    }

    em.flush();
    em.clear();

    em.getTransaction().commit();

    em.close();
}
 
开发者ID:Moccko,项目名称:campingsimulator2017,代码行数:20,代码来源:GenericDAO.java

示例6: createEntity

import javax.persistence.EntityManager; //导入方法依赖的package包/类
/**
 * Create an entity for this test.
 *
 * This is a static method, as tests for other entities might also need it,
 * if they test an entity which requires the current entity.
 */
public static Profile createEntity(EntityManager em) {
    Profile profile = new Profile()
        .userKey(DEFAULT_USER_KEY);

    // Add required entity
    Dashboard dashboard = DashboardResourceIntTest.createEntity(em);
    em.persist(dashboard);
    em.flush();
    profile.setDashboards(new HashSet<>(Collections.singletonList(dashboard)));
    return profile;
}
 
开发者ID:xm-online,项目名称:xm-ms-dashboard,代码行数:18,代码来源:ProfileResourceIntTest.java

示例7: createEntity

import javax.persistence.EntityManager; //导入方法依赖的package包/类
/**
 * Create an entity for this test.
 *
 * This is a static method, as tests for other entities might also need it,
 * if they test an entity which requires the current entity.
 */
public static DefaultProfile createEntity(EntityManager em) {
    DefaultProfile defaultProfile = new DefaultProfile()
        .roleKey(DEFAULT_ROLE_KEY);
    // Add required entity
    Dashboard dashboard = DashboardResourceIntTest.createEntity(em);
    em.persist(dashboard);
    em.flush();
    defaultProfile.setDashboard(dashboard);
    return defaultProfile;
}
 
开发者ID:xm-online,项目名称:xm-ms-dashboard,代码行数:17,代码来源:DefaultProfileResourceIntTest.java

示例8: testOriginalExceptionThrown

import javax.persistence.EntityManager; //导入方法依赖的package包/类
@Test(expected=PersistenceException.class)
public void testOriginalExceptionThrown() {
    EmSupplier emSupplier = mock(EmSupplier.class);
    EntityManager em = mock(EntityManager.class);
    when(emSupplier.get()).thenReturn(em);
    doThrow(new PersistenceException("Message")).when(em).flush();

    EntityManager emProxy = EMFTracker.createProxy(emSupplier);
    emProxy.flush();
}
 
开发者ID:apache,项目名称:aries-jpa,代码行数:11,代码来源:EmfTrackerTest.java

示例9: addCar

import javax.persistence.EntityManager; //导入方法依赖的package包/类
@Override
public void addCar(Car car) {
    EntityManager em = emf.createEntityManager();
    em.persist(car);
    em.flush();
    em.close();
}
 
开发者ID:apache,项目名称:aries-jpa,代码行数:8,代码来源:CarServiceWithEmfImpl.java

示例10: remove

import javax.persistence.EntityManager; //导入方法依赖的package包/类
/**
 * Removes an existing entity from database.
 *
 * @param entity Entity to remove.
 */
public void remove(T entity) {

    EntityManager em = HibernateUtil.getEntityManagerFactory().createEntityManager();

    em.getTransaction().begin();
    em.remove(em.merge(entity));
    em.flush();
    em.clear();
    em.getTransaction().commit();

    em.close();
}
 
开发者ID:Moccko,项目名称:campingsimulator2017,代码行数:18,代码来源:GenericDAO.java

示例11: clear

import javax.persistence.EntityManager; //导入方法依赖的package包/类
public static void clear(final EntityManager em, JpaQueryFactory factory) {
	factory.initalize(new JpaQueryFactoryContext() {
		@Override
		public EntityManager getEntityManager() {
			return em;
		}

		@Override
		public MetaPartition getMetaPartition() {
			JpaMetaProvider jpaMetaProvider = new JpaMetaProvider(em.getEntityManagerFactory());
			MetaLookup metaLookup = new MetaLookup();
			metaLookup.addProvider(jpaMetaProvider);
			metaLookup.initialize();
			return jpaMetaProvider.getPartition();
		}
	});
	clear(em, factory.query(OneToOneTestEntity.class).buildExecutor().getResultList());
	clear(em, factory.query(ManyToManyTestEntity.class).buildExecutor().getResultList());
	clear(em, factory.query(ManyToManyOppositeEntity.class).buildExecutor().getResultList());
	clear(em, factory.query(TestSubclassWithSuperclassPk.class).buildExecutor().getResultList());
	clear(em, factory.query(RelatedEntity.class).buildExecutor().getResultList());
	clear(em, factory.query(TestEntity.class).buildExecutor().getResultList());
	clear(em, factory.query(OtherRelatedEntity.class).buildExecutor().getResultList());
	clear(em, factory.query(CountryTranslationEntity.class).buildExecutor().getResultList());
	clear(em, factory.query(CountryEntity.class).buildExecutor().getResultList());
	clear(em, factory.query(LangEntity.class).buildExecutor().getResultList());
	clear(em, factory.query(BasicAttributesTestEntity.class).buildExecutor().getResultList());
	clear(em, factory.query(RenamedTestEntity.class).buildExecutor().getResultList());
	clear(em, factory.query(UuidTestEntity.class).buildExecutor().getResultList());
	em.flush();
	em.clear();
}
 
开发者ID:crnk-project,项目名称:crnk-framework,代码行数:33,代码来源:AbstractJpaTest.java

示例12: persist

import javax.persistence.EntityManager; //导入方法依赖的package包/类
public void persist(Object obj){
	EntityManager em=this.getEntityManager();
	try{
		em.persist(obj);
	}finally{
		em.flush();
		em.close();
	}
}
 
开发者ID:bsteker,项目名称:bdf2,代码行数:10,代码来源:TaskManager.java

示例13: createEntity

import javax.persistence.EntityManager; //导入方法依赖的package包/类
/**
 * Create an entity for this test.
 *
 * This is a static method, as tests for other entities might also need it,
 * if they test an entity which requires the current entity.
 */
public static Rating createEntity(EntityManager em) {
    Rating rating = new Rating()
        .typeKey(DEFAULT_TYPE_KEY)
        .value(DEFAULT_VALUE)
        .startDate(DEFAULT_START_DATE)
        .endDate(DEFAULT_END_DATE);
    // Add required entity
    XmEntity xmEntity = XmEntityResourceIntTest.createEntity(em);
    em.persist(xmEntity);
    em.flush();
    rating.setXmEntity(xmEntity);
    return rating;
}
 
开发者ID:xm-online,项目名称:xm-ms-entity,代码行数:20,代码来源:RatingResourceIntTest.java

示例14: createEntity

import javax.persistence.EntityManager; //导入方法依赖的package包/类
/**
 * Create an entity for this test.
 *
 * This is a static method, as tests for other entities might also need it,
 * if they test an entity which requires the current entity.
 */
public static Profile createEntity(EntityManager em, XmEntity xmEntity) {
    Profile profile = new Profile()
        .userKey(DEFAULT_USER_KEY);
    // Add required entity

    em.persist(xmEntity);
    em.flush();
    profile.setXmentity(xmEntity);
    return profile;
}
 
开发者ID:xm-online,项目名称:xm-ms-entity,代码行数:17,代码来源:ProfileResourceIntTest.java

示例15: createEntity

import javax.persistence.EntityManager; //导入方法依赖的package包/类
/**
 * Create an entity for this test.
 *
 * This is a static method, as tests for other entities might also need it,
 * if they test an entity which requires the current entity.
 */
public static Calendar createEntity(EntityManager em) {
    Calendar calendar = new Calendar()
        .typeKey(DEFAULT_TYPE_KEY)
        .name(DEFAULT_NAME)
        .description(DEFAULT_DESCRIPTION)
        .startDate(DEFAULT_START_DATE)
        .endDate(DEFAULT_END_DATE);
    // Add required entity
    XmEntity xmEntity = XmEntityResourceIntTest.createEntity(em);
    em.persist(xmEntity);
    em.flush();
    calendar.setXmEntity(xmEntity);
    return calendar;
}
 
开发者ID:xm-online,项目名称:xm-ms-entity,代码行数:21,代码来源:CalendarResourceIntTest.java


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