How do I make a list and change results using javaEE

0

I have an object called (Bank) that has several accounts, with balance in these accounts I make payments of several expenses. What I want is to get all the expenses paid and to write down the bank accounts in a single bank transaction, but I can not find the method:

public List<Banco> bancoRepository() { 
    //carregar lista para lançamento
    return manager.createQuery("from Banco", Banco.class).getResultList();
}

and I created this method to download

@Transactional
public Banco baixarPagamentos(Banco banco) {
    banco = bancos.porId(banco.getId());
    for (Banco banco1 : bancos.bancoRepository()) {
        banco.baixarPagamentos(banco1.getSaida());
    }

    return bancos.guardar(banco);
}

But it did not work gave the following error

  

Hibernate: select next_val as id_val from hibernate_sequence for   update Hibernate: update hibernate_sequence set next_val =? Onde   next_val =? 2017-12-12 09: 53: 45,850 ERROR   [org.hibernate.internal.ExceptionMapperStandardImpl] HHH000346: Error   during managed flush [Validation failed for classes   [com.almasystems.financeiro.model.Banco] during persist time for   groups [javax.validation.groups.Default,] List of constraint   violations: [ConstraintViolationImpl {interpolatedMessage = 'should be   informed ', propertyPath = name, rootBeanClass = class   com.almasystems.financeiro.model.Banco,   messageTemplate = '{org.hibernate.validator.constraints.NotBlank.message}'}     ConstraintViolationImpl {interpolatedMessage = 'must be informed',   propertyPath = initialStream data, rootBeanClass = class   com.almasystems.financeiro.model.Banco,   messageTemplate = '{javax.validation.constraints.NotNull.message}'}     ConstraintViolationImpl {interpolatedMessage = 'must be informed',   propertyPath = code, rootBeanClass = class   com.almasystems.financeiro.model.Banco,   messageTemplate = '{org.hibernate.validator.constraints.NotBlank.message}'}     ConstraintViolationImpl {interpolatedMessage = 'must be informed',   propertyPath = company, rootBeanClass = class   com.almasystems.financeiro.model.Banco,   messageTemplate = '{javax.validation.constraints.NotNull.message}'}     ConstraintViolationImpl {interpolatedMessage = 'must be informed',   propertyPath = account, rootBeanClass = class   com.almasystems.financeiro.model.Banco,   messageTemplate = '{org.hibernate.validator.constraints.NotBlank.message}'}     ConstraintViolationImpl {interpolatedMessage = 'must be informed',   propertyPath = agency, rootBeanClass = class   com.almasystems.financeiro.model.Banco,   messageTemplate = '{org.hibernate.validator.constraints.NotBlank.message}'}     ConstraintViolationImpl {interpolatedMessage = 'must be informed',   propertyPath = operation, rootBeanClass = class   com.almasystems.financeiro.model.Banco,   messageTemplate = '{org.hibernate.validator.constraints.NotBlank.message}'}   ]]

Someone could please give you an idea. If you need more details just talk. ha has more this is the html snippet:

<p:dataTable id="tabelaBancos" paginator="true"
        rowsPerPageTemplate="5,10,15"
        value="#{lancamentoTributoBean.listaBancos}" var="banco"
        paginatorPosition="bottom" paginatorAlwaysVisible="flase"
        style="margin-top: 5px" emptyMessage="" rows="10">

        <p:column headerText="NOME">
            <h:outputText value="#{banco.nome}" />
        </p:column>
        <p:column headerText="SALDO">
            <h:outputText style="float: right;" value="#{banco.saldoInicial}">
                <f:convertNumber type="currency" />
            </h:outputText>
        </p:column>
        <f:facet name="footer">
            <p:commandButton value="Baixar"
                action="#{cadastroBancoBean.baixarPagamentos}"
                update="tabelaBancos" process="tabelaBancos" />
            <h:outputText value="#{lancamentoTributoBean.total}">
                <f:convertNumber type="currency" />
            </h:outputText>
        </f:facet>
    </p:dataTable>'
    
asked by anonymous 12.12.2017 / 13:22

1 answer

1

I have already found a solution and thank you very much to your colleagues.

I created a DownloadPage class (with a list of ItemPage ), and a ItemPage class with two strong>; LowPack ) and in the bean I created a for the list of banks

this.listaBancos = bancos.bancoRepository();

which is loaded every time I update the html page through

<f:metadata>
    <f:event listener="#{baixarPagamentoBean.inicializar}"
        type="preRenderView" />
</f:metadata>'

I created this

public void adicionarBancos() {
    for (Banco banco : getListaBancos()) {
        item = new ItemPagamento();
        item.setBanco(banco);
        item.setBaixarPagamento(baixarPagamento);
        baixarPagamento.getItens().add(0, item);
    }
}

method to set the values of the list and when I click the download button it executes the list and the method,

public void salvar() {
    this.baixarPagamento = this.baixarPagamentoService.salvar(this.baixarPagamento);
    this.lancamentoBean.salvar();
    FacesUtil.addSuccessMessage("Baixa efetuada com sucesso!");
}

In my bean, do the calculation.

    
15.12.2017 / 21:05