I want to keep a counter in a database which I can use for computing a value in my Java code. Each time I use the counter value I want to have it auto-incremented, that way if another thread reads the counter value it will be sure to be unique. I want to use Hibernate to do this, but it's not obvious to me how I would go about setting it up. Can anyone give me some suggestions on how I would go about it?
My first thoughts are to have an entity class which has a single field "counter", and a corresponding DAO class which has a single method getCounterValue() which will return the current counter value which will be incremented in the corresponding table. Does this seem reasonable?