Skip to main content

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index] [List Home]
[eclipselink-users] How eclipselink handles Sequences?

This following is quoted from the eclipselink User Guide :

"The key difference between Oracle Type Sequencing process and the process involved in table sequencing is that EclipseLink is unaware of the INCREMENT construct on the SEQUENCE object. EclipseLink sequencing and the Oracle SEQUENCE object operate in isolation. To avoid sequencing errors in the application, set the EclipseLink preallocation size and the Oracle SEQUENCE object INCREMENT to the same value. Note that the Oracle sequence object must have a starting value equal to the preallocation size because when EclipseLink gets the next sequence value, it assume it has the previous preallocation size of values."

We have a scenario where the database is updated not only by an eclipse link based application but by stored procedures as well. for that matter, I believe that we cannot make an assumption that the eclipse link is owning the database and operates on it in isolation. 

So, if we use the increment value of the  sequence to the preallocation size defined on  the eclipse link entity definition, then there will be a lot of  sequence values unused.
But if we set the increment value of the sequence to nominal 1, then there is every chance of collision with the values generated by sequence and that generated by eclipse link.


Now my question is why can't the eclipse link update the sequence object by the preallocation size when ever it want to prefetch values? why is it updating only by the original increment size of the sequence even though it is presuming it acquired the amount o values mentioned in the preallocation size in the entity?

for example, had eclipse link done some thing like this:

on Oracle:

ALTER SEQUENCE SEQUENCE_NAME INCREMENT BY 'preallocation_size'; where ever eclipse link wanted to prefetch the values 
and then resetting it back to 
ALTER SEQUENCE SEQUENCE_NAME INCREMENT BY 'original_increment_value'; 


then there can be no error at any point , who ever may update the database from any where as long as sequence is properly used.

Can this be achieved by any setting by which I can force elipselink to always update the sequence value by preallocation size and not the INCREMENT SIZE?

Thanks and Regards,
Samba



Back to the top