Hi all,
I want to describe one thing that I fell it could be improved on Hibernate.
When an entity is configured to use @SequenceGenerator and its allocationSize is set to 1, Hibernate generates ids through SequenceHiLoGenerator as if it were using the regular SequenceGenerator but with one HUGE difference, SequenceHiLoGenerator generate method is
synchronized since it was designed with the memory trick in mind. But the problem is, when there is a huge insert load it becomes a
REALLY HUGE bottleneck (that can be identified with thread dumps). By huge load I say >100 concurrent inserts (that I guess is not that huge).
I sincerely think that Hibernate should fallback to "sequence" instead of "seqhilo" on those scenarios or at least warn the user on the console since it is really awkward to prefer having a synchronized implementation on something that can be potential slow under huge load scenarios than having an implementation that is not synchronized.
I really wanted to share this since it gave us an enormous headache recently (we switched this huge load entity to use a greater allocationSize and "fixed" the sequence but we are manually switching to "sequence" using @GenericGenerator for the rest).
What you guys (users and Hibernate developers) think about this? Wasn't it better to have it defaulted to the regular SequenceGenerator on those cases?
Best regards,
Rafael Ribeiro
I'll paste the links to SequenceHiLoGenerator.java and SequenceGenerator.java for anyone willing to look and check what I said:
http://anonsvn.jboss.org/repos/hibernate/core/tags/hibernate-3.3.1.GA/core/src/main/java/org/hibernate/id/SequenceHiLoGenerator.java http://anonsvn.jboss.org/repos/hibernate/core/tags/hibernate-3.3.1.GA/core/src/main/java/org/hibernate/id/SequenceGenerator.java