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>'