/**
* Returns next value for sequence given by name.
*/
public static int getNext(String name) {
Sequence sequence = Sequences.query(name);
if (sequence == null) {
sequence = new Sequence(name);
}
int next = sequence.getNext();
Database.save(sequence);
return next;
}