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


Java TxType.REQUIRED属性代码示例

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


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

示例1: create

@SuppressWarnings("unchecked")
@Override
@Transactional(TxType.REQUIRED)
public E create(final E transientInstance) throws MessageLabelException {
    log.trace("Create a new entity {}", getModelClass().getName());
    if (transientInstance == null) {
        log.warn("Try to create a null object !");
        throw new NullDataException();
    }
    validateEntity((IEntity<Serializable>) transientInstance);
    mapsId(transientInstance);
    reSet(transientInstance);
    getEntityManager().persist(transientInstance);
    // rebuild Set fields because they are hashed with null entity pk.
    reSet(transientInstance);
    log.trace("New entity {} created", transientInstance);
    return transientInstance;
}
 
开发者ID:qjafcunuas,项目名称:jbromo,代码行数:18,代码来源:AbstractEntityDao.java

示例2: delete

@Override
@Transactional(TxType.REQUIRED)
public boolean delete(final E detachedInstance) throws MessageLabelException {
    log.trace("Delete one entity {}", getModelClass().getName());
    if (detachedInstance == null) {
        log.warn("Try to delete a null object !");
        throw new NullDataException();
    }
    final E persistedInstance = findByPk(detachedInstance.getPrimaryKey());
    if (persistedInstance == null) {
        log.trace("Entity {} {} doesn't exist for deletion", getModelClass().getName(), detachedInstance.getPrimaryKey());
        return false;
    }
    getEntityManager().remove(persistedInstance);
    log.trace("Entity {} {} deleted", getModelClass().getName(), persistedInstance.getPrimaryKey());
    return true;
}
 
开发者ID:qjafcunuas,项目名称:jbromo,代码行数:17,代码来源:AbstractEntityDao.java

示例3: save

@Override
@Transactional(TxType.REQUIRED)
public <S extends Office> S save(S entity) {
	logger.info("Transaction should be started by Blueprint interceptor");
	if (entity.isNew()) {
		em.persist(entity);
	} else {
		em.merge(entity);
	}
	return entity;
}
 
开发者ID:antoniomaria,项目名称:karaf4-eclipselink-jpa,代码行数:11,代码来源:OfficeRepositoryImpl.java

示例4: update

@SuppressWarnings("unchecked")
@Override
@Transactional(TxType.REQUIRED)
public E update(final E detachedInstance) throws MessageLabelException {
    log.trace("Update one entity {}", getModelClass().getName());
    if (detachedInstance == null) {
        log.warn("Try to update a null object !");
        throw new NullDataException();
    }
    validateEntity((IEntity<Serializable>) detachedInstance);
    mapsId(detachedInstance);
    reSet(detachedInstance);

    // Clear xxxToMany relationship before merging entity, and add their
    // after merged.
    final Map<Field, Collection<IEntity<?>>> map = oneToMany(detachedInstance);
    // Merge the entity.
    final E entity = getEntityManager().merge(detachedInstance);
    // Recollection oneToMany relationship in the entity.
    oneToMany(entity, map);
    oneToMany(detachedInstance, map);

    // Flush and reset Set object.
    getEntityManager().flush();
    reSet(detachedInstance);
    reSet(entity);

    log.trace("Entity {} updated", entity);
    return entity;
}
 
开发者ID:qjafcunuas,项目名称:jbromo,代码行数:30,代码来源:AbstractEntityDao.java

示例5: save

@Override
@Transactional(TxType.REQUIRED)
public E save(final E detachedInstance) throws MessageLabelException {
    if (EntityUtil.isNullPk(detachedInstance)) {
        return create(detachedInstance);
    } else {
        return update(detachedInstance);
    }
}
 
开发者ID:qjafcunuas,项目名称:jbromo,代码行数:9,代码来源:AbstractEntityDao.java

示例6: getConcert

@GET
@Produces(MediaType.APPLICATION_JSON)
@Path("/{id}")
@Transactional(value=TxType.REQUIRED)
public Event getConcert(@PathParam("id") long id) {
	System.out.println("ConcertResource.getConcert(" + id + ")");
	return emf.createEntityManager().find(Event.class, id);
}
 
开发者ID:LearningTree,项目名称:TicketManorJava,代码行数:8,代码来源:EventResource.java

示例7: getSportsEvent

@GET
@Produces(MediaType.APPLICATION_JSON)
@Path("/{id}")
@Transactional(value=TxType.REQUIRED)
public Event getSportsEvent(@PathParam("id") long id) {
	System.out.println("ConcertResource.getConcert(" + id + ")");
	return emf.createEntityManager().find(Event.class, id);
}
 
开发者ID:LearningTree,项目名称:TicketManorJava,代码行数:8,代码来源:SportsResource.java

示例8: getItem

@GET
@Produces(MediaType.APPLICATION_JSON)
@Path("/{id}")
@Transactional(value=TxType.REQUIRED)
public Venue getItem(@PathParam("id") long id) {
	System.out.println("VenueResource.getItem(" + id + ")");
	return emf.createEntityManager().find(Venue.class, id);
}
 
开发者ID:LearningTree,项目名称:TicketManorJava,代码行数:8,代码来源:VenueResource.java


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