Hi, I have a problem implementing a ranking system for my users.
User are ranked for an amount of points and I wanted to "accelerate" queries regarding the rank so I did a separate table like this:
Code:
public class UserRanking{
@Id
@GeneratedValue(strategy = GenerationType.AUTO)
private Long rank;
@OneToOne
private User user;
@Column
private Long points;
I delete records and next bulkupdate the table with an insert into statement once every 5 minutes using hibernatetemplate.updateBatch method.
Obviously, this strategy needs a reset of the value generator. I'm not sure this is the best approach for a ranking.
Any solutions on this? A better approach?
I thought on putting the rank in the user object and updating each record, but it may be very slow and querying the table with 'order by rank' may also be slow.
Thanks in advance!