1
I am trying to make a system for service order just for me to train. In the service orders I can have several categories. And my doubt is time to display, for example, a ranking of the most used categories for a period x using the criteria of Hibernate. Something that the result was organized like this:
Category A - 10 times
Category B - 8 times
Category C - 5 times
What can I use in this case?
Classes are briefly mapped like this
OrderService class
@SuppressWarnings("serial")
@Entity
@Table(name = "ordem_servico")
public class OrdemServico extends GenericModel {
@NotNull
@Temporal(TemporalType.TIMESTAMP)
@Column(name = "data_os", nullable = false)
private Date dataOS;
@ManyToMany(cascade = { CascadeType.MERGE, CascadeType.REFRESH })
@JoinTable(name = "os_categoria", joinColumns = @JoinColumn(name = "id_os"),inverseJoinColumns = @JoinColumn(name = "id_categoria"))
private List<Categoria> categorias;
}
Class Category
@SuppressWarnings("serial")
@Entity
@Table(name = "categoria_os")
public class Categoria extends GenericModel {
@Column(name = "nome_cat", nullable = false, length = 40)
@NotBlank
private String nome;
public String getNome() {
return nome;
}
public void setNome(String nome) {
this.nome = nome;
}
}
Explain better the ai business rule. It is missing a field for the period as well.
– Sidney
@Sorry to keep you waiting. Type I have service orders that can have multiple categories and I wanted to make like a top 10 of most used categories
– BrunoAmorim
Each service order or all?
– Sidney
@Matheussilva of all service categories. Type one ranking
– BrunoAmorim