In multithread environment where number of concurrent threads are larger than maximum number of connection and waitTimeout is set to pessimistic time (E.G. 5 miutes) follow situation may occurs
1. Couple of thread starts transaction those exausting connection pool. Other threads are waiting for them to start they own transaction.2. Every thread that was able to start transaction trying to save new entity with sequence generator.3. SequenceGenerator asking DataSource for new connection but connection pool has already exausted. 4. Deadlock.
Fixed in HEAD.
Will use the Connection from the current transaction.
Refer:- SequenceIdGenerator.nextId()- DefaultPersister.setIdGenValue()