I am trying use mybatis-cdi within Wilfly and I need to run part of method in separate transaction - see following snippet:
@Stateless
@TransactionManagement(TransactionManagementType.CONTAINER)
public class ItemService {
@Inject
@Mapper
ItemMapper mapper;
@TransactionAttribute(TransactionAttributeType.REQUIRED)
public void doSomething() {
List<Item> items = mapper.findByTime(new Date());
for(Item i : items) {
update(i);
}
}
@TransactionAttribute(TransactionAttributeType.REQUIRES_NEW)
public void update(Item item) {
mapper.updateSomehow(item);
}
}
Is this correct way how to do it? Is this supported with mybatis-cdi, or should it be done some different way?
