Issue
I realize this is more of a hibernate question than Grails. In a load balanced (2 nodes) environment I see that the ids of my objects are jumping around quite a bit. Even without restarting the app server I see that the numbers skip 10 sometimes 20 numbers. I suspect the hibernate session is caching a block of sequence values. Is there a way to control this behavior with grails 1.3.7 ? Essentially I am OK with server pulling nextval from DB every time it needs one.
My domain object sequence declaration (same for 2 objects):
static mapping = {
id generator:'sequence', params:[sequence:'MY_SEQ']
}
Solution
I have since went to the database and modified the Sequence with the following DDL:
ALTER SEQUENCE MY_SEQ NOCACHE;
I think this is the best solution for this issue. Does anyone see potential problems with this approach?
Thanks all!
Answered By - dbrin
Answer Checked By - Candace Johnson (JavaFixing Volunteer)