# Using a SQL Server sequence with Hibernate

**URL:** <https://discourse.hibernate.org/t/using-a-sql-server-sequence-with-hibernate/113>\
**Category:** Hibernate ORM\
**Created:** [January 22, 2018, 11:14am UTC](https://discourse.hibernate.org/t/using-a-sql-server-sequence-with-hibernate/113 "2018-01-22T11:14:31Z")\
**Posts on this page:** 5\
**Page:** 1

<div class="post-metadata">

**Author:** ![satish](https://avatars.discourse-cdn.com/v4/letter/s/aca169/32.png) [@satish](https://discourse.hibernate.org/u/satish)\
**Post date:** [January 22, 2018, 11:14am UTC](https://discourse.hibernate.org/t/using-a-sql-server-sequence-with-hibernate/113/1 "2018-01-22T11:14:31Z")

</div>

Hi Everyone,

I have created a sequence in Sqlserver 2012, when I’m using this sequence in hibernate application I’m getting the below error.

IdentifierGenerationException:integral holder was not intialized

Please help me to resolve the issue.

Regards  
Satish

---

<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:** [January 22, 2018, 11:29am UTC](https://discourse.hibernate.org/t/using-a-sql-server-sequence-with-hibernate/113/2 "2018-01-22T11:29:37Z")

</div>

I assume you are using a very old Hibernate version since I can’t even find that log message in Hibernate 5.3.

I that’s the case, you should probably upgrade to either  
4.2.13 or 4.3.6 since they have the fix for [HHH-9169](https://hibernate.atlassian.net/browse/HHH-9169).

---

<div class="post-metadata">

**Author:** ![satish](https://avatars.discourse-cdn.com/v4/letter/s/aca169/32.png) [@satish](https://discourse.hibernate.org/u/satish)\
**Post date:** [January 22, 2018, 11:49am UTC](https://discourse.hibernate.org/t/using-a-sql-server-sequence-with-hibernate/113/3 "2018-01-22T11:49:28Z")

</div>

Thank you for the swift response.  
Can you please give me some example to do this scenario.

Regards  
Satish

---

<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:** [January 22, 2018, 12:13pm UTC](https://discourse.hibernate.org/t/using-a-sql-server-sequence-with-hibernate/113/4 "2018-01-22T12:13:04Z")

</div>

Assuming you have a `my_sequence` sequence, this is how your mapping should look like:

```auto
@Id
@GeneratedValue(
	strategy = GenerationType.SEQUENCE,
	generator = "sequence-generator"
)
@SequenceGenerator(
	name = "sequence-generator",
	sequenceName = "my_sequence"
)
private Long id;

```

For more details, check out [this article](https://vladmihalcea.com/hibernate-identity-sequence-and-table-sequence-generator/).

---

<div class="post-metadata">

**Author:** ![alfonz19](https://yyz1.discourse-cdn.com/flex035/user_avatar/discourse.hibernate.org/alfonz19/32/2440_2.png) [@alfonz19](https://discourse.hibernate.org/u/alfonz19)\
**Post date:** [July 18, 2024, 11:02am UTC](https://discourse.hibernate.org/t/using-a-sql-server-sequence-with-hibernate/113/5 "2024-07-18T11:02:05Z")

</div>

fyi just upgraded to hibernate 6 and I’m getting this message. I probably broke some sequence-related annotations and it’s my bad, but this clearly exist somewhere.

IIUC. this will happen if you have sequence defined with min-value, start-value equal to Integer.MIN\_VALUE which is abused to have meaning of ‘undefined’ sequence value.

Here:  
org.hibernate.id.IdentifierGeneratorHelper.BasicHolder#checkInitialized
