0
I have an object called (Bank) that has several accounts, with balance in these accounts I make payments of various expenses. what I want is to get all the expenses paid and to give low in the bank accounts in a single bank movement, but I am not getting, search method:
public List<Banco> bancoRepository() {
//carregar lista para lançamento
return manager.createQuery("from Banco", Banco.class).getResultList();
}
and 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= ? Where 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='must be informed', propertyPath=name, rootBeanClass=class com.almasystems.financeiro.model.Banco, messageTemplate='{org.hibernate.Validator.constraints.Notblank.message}'} Constraintviolationimpl{interpolatedMessage='must be informed', propertyPath=dataSaldoInitial, 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=agencia, 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}'} ]]
Could someone please give us an idea. If you need more details, just let me know. ha ha but 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>`