# Select Next Val(seq) hangs insert statement in hibernate

**URL:** <https://discourse.hibernate.org/t/select-next-val-seq-hangs-insert-statement-in-hibernate/2234>\
**Category:** Hibernate ORM\
**Created:** [February 7, 2019, 9:55am UTC](https://discourse.hibernate.org/t/select-next-val-seq-hangs-insert-statement-in-hibernate/2234 "2019-02-07T09:55:27Z")\
**Posts on this page:** 3\
**Page:** 1

<div class="post-metadata">

**Author:** ![Vivek\_Katoch](https://yyz1.discourse-cdn.com/flex035/user_avatar/discourse.hibernate.org/vivek_katoch/32/525_2.png) [@Vivek\_Katoch](https://discourse.hibernate.org/u/Vivek_Katoch)\
**Post date:** [February 7, 2019, 9:55am UTC](https://discourse.hibernate.org/t/select-next-val-seq-hangs-insert-statement-in-hibernate/2234/1 "2019-02-07T09:55:27Z")

</div>

sequence belongs to´different table  
insert statement is done for different table’

As i check postgres db locks :select nextval block insert statement

we are using hibernate orm for save operation

---

<div class="post-metadata">

**Author:** ![vlad](https://yyz1.discourse-cdn.com/flex035/user_avatar/discourse.hibernate.org/vlad/32/658_2.png) [@vlad](https://discourse.hibernate.org/u/vlad)\
**Post date:** [February 7, 2019, 10:46am UTC](https://discourse.hibernate.org/t/select-next-val-seq-hangs-insert-statement-in-hibernate/2234/2 "2019-02-07T10:46:35Z")

</div>

Try to replicate it with this [test case template](http://in.relation.to/2016/01/14/hibernate-jpa-test-case-template/) and we are going to look at it once you replicated it.

---

<div class="post-metadata">

**Author:** ![Vivek\_Katoch](https://yyz1.discourse-cdn.com/flex035/user_avatar/discourse.hibernate.org/vivek_katoch/32/525_2.png) [@Vivek\_Katoch](https://discourse.hibernate.org/u/Vivek_Katoch)\
**Post date:** [March 5, 2019, 9:17am UTC](https://discourse.hibernate.org/t/select-next-val-seq-hangs-insert-statement-in-hibernate/2234/3 "2019-03-05T09:17:16Z")

</div>

Thanks Vald, its working fine now , it was some while loop condition glitch which was running infinite cause that issue ,
