@Override public M getByRecordId(final Long recordId, final InternalTenantContext context) { return transactionalSqlDao.execute( new EntitySqlDaoTransactionWrapper<M>() { @Override public M inTransaction( final EntitySqlDaoWrapperFactory<EntitySqlDao> entitySqlDaoWrapperFactory) throws Exception { final EntitySqlDao<M, E> transactional = entitySqlDaoWrapperFactory.become(realSqlDao); return transactional.getByRecordId(recordId, context); } }); }
@Override public Long getRecordId(final UUID id, final InternalTenantContext context) { return transactionalSqlDao.execute( new EntitySqlDaoTransactionWrapper<Long>() { @Override public Long inTransaction( final EntitySqlDaoWrapperFactory<EntitySqlDao> entitySqlDaoWrapperFactory) throws Exception { final EntitySqlDao<M, E> transactional = entitySqlDaoWrapperFactory.become(realSqlDao); return transactional.getRecordId(id.toString(), context); } }); }
@Override public List<M> get(final InternalTenantContext context) { return transactionalSqlDao.execute( new EntitySqlDaoTransactionWrapper<List<M>>() { @Override public List<M> inTransaction( final EntitySqlDaoWrapperFactory<EntitySqlDao> entitySqlDaoWrapperFactory) throws Exception { final EntitySqlDao<M, E> transactional = entitySqlDaoWrapperFactory.become(realSqlDao); return transactional.get(context); } }); }
@Override public void test(final InternalTenantContext context) { transactionalSqlDao.execute( new EntitySqlDaoTransactionWrapper<Void>() { @Override public Void inTransaction( final EntitySqlDaoWrapperFactory<EntitySqlDao> entitySqlDaoWrapperFactory) throws Exception { final EntitySqlDao<M, E> transactional = entitySqlDaoWrapperFactory.become(realSqlDao); transactional.test(context); return null; } }); }
@Override public void create(final M entity, final InternalCallContext context) throws U { transactionalSqlDao.execute( new EntitySqlDaoTransactionWrapper<Void>() { @Override public Void inTransaction( final EntitySqlDaoWrapperFactory<EntitySqlDao> entitySqlDaoWrapperFactory) throws Exception { final EntitySqlDao<M, E> transactional = entitySqlDaoWrapperFactory.become(realSqlDao); if (transactional.getById(entity.getId().toString(), context) != null) { throw generateAlreadyExistsException(entity, context); } transactional.create(entity, context); final M refreshedEntity = transactional.getById(entity.getId().toString(), context); postBusEventFromTransaction( entity, refreshedEntity, ChangeType.INSERT, entitySqlDaoWrapperFactory, context); return null; } }); }