0
I am developing a system for restaurant and I have a datagrid that updates the other.
For example: I click on the class and update the product datagrid.
It works, but the result is slow.
I’m wearing a <h:commandLink>
with update:
<p:commandLink actionListener="#{mesaControle.setClasseFiltro(grupo)}"
action="#{mesaControle.validaBuscarProduto()}"
update="form:produtos">
<button style="background-color: #0b66b1; height: 55px; width: 100px;">
<br/>
<strong style="color: #f6f6f6">#{grupo.nome}</strong></button>
</p:commandLink>
And filter as follows:
public List<Produto> listaClasse(Classe produtoFiltro) {
Query q = em.createQuery("FROM Produto As a WHERE a.classe = :para order by id asc");
q.setParameter("para", produtoFiltro);
return q.getResultList();
}
Everything works perfectly, but the performance leaves to be desired.
How can I improve performance?
What does it take? Query in database or update component in view?
– igventurelli
Guy is probably updating the component in the view, I need something dynamic, something that when I click the button, it already renders on the side.. At the moment it takes 2 to 3 seconds after the click .
– Leandro Santos
Puts a
System.out.println()
at the beginning and end of the method of consulting the bank and compare if one takes longer than the other... I think that’s what is holding up hehe– igventurelli
beauty I will try and put and result
– Leandro Santos
guy, being the research that is slowing down you know some other way he does this research] I noticed that in the class that has more products it takes a little longer.
– Leandro Santos
You knew it! Hehe. Dude, in this case there are a few things you can do: create index for your table (if it doesn’t exist yet), limit the amount of records searched per datagrid page, and I don’t think you need to do
FROM Produto As a
. I guess justFROM Produto a
already works (not that that’s the problem)– igventurelli
Let’s go continue this discussion in chat.
– Leandro Santos