# Migrating from Hibernate 5 to 6 results in error that target lists have at most 1664 entries

**URL:** <https://discourse.hibernate.org/t/migrating-from-hibernate-5-to-6-results-in-error-that-target-lists-have-at-most-1664-entries/11571>\
**Category:** Hibernate ORM\
**Created:** [June 16, 2025, 9:41am UTC](https://discourse.hibernate.org/t/migrating-from-hibernate-5-to-6-results-in-error-that-target-lists-have-at-most-1664-entries/11571 "2025-06-16T09:41:16Z")\
**Posts on this page:** 4\
**Page:** 1

<div class="post-metadata">

**Author:** ![rhochreiter](https://avatars.discourse-cdn.com/v4/letter/r/8edcca/32.png) [@rhochreiter](https://discourse.hibernate.org/u/rhochreiter)\
**Post date:** [June 16, 2025, 9:41am UTC](https://discourse.hibernate.org/t/migrating-from-hibernate-5-to-6-results-in-error-that-target-lists-have-at-most-1664-entries/11571/1 "2025-06-16T09:41:16Z")

</div>

When migrating from WildFly 26 (Hibernate 5 and JavaEE 8) to WildFly 35 (Hibernate 6 and Jakarta EE 10) I am getting the error below for the same Entity-Model:

```auto
target lists can have at most 1664 entries

```

Hibernate 6 makes a lot of more joins than Hibernate 5 with the same Entity model!

This error is not specific to Postgres because it also occurs with MS SQL Server with a different number of entities.

What’s the reason for this error in Hibernate 6 and where to find relevant documentation?

WildFly 35 uses Hibernate 6.6.3.Final

---

<div class="post-metadata">

**Author:** ![rhochreiter](https://avatars.discourse-cdn.com/v4/letter/r/8edcca/32.png) [@rhochreiter](https://discourse.hibernate.org/u/rhochreiter)\
**Post date:** [June 18, 2025, 8:41am UTC](https://discourse.hibernate.org/t/migrating-from-hibernate-5-to-6-results-in-error-that-target-lists-have-at-most-1664-entries/11571/3 "2025-06-18T08:41:35Z")

</div>

Probably with some more details I’ll get an answer 😉

I have a complex entity hierarchy with lots of @ManyToOne and @OneToOne properties and FetchType.EAGER

```auto
@Entity
class A {
	// some more @ManyToOne properties
}

@Entity
class B {
	@ManyToOne(fetch = FetchType.EAGER)
	private A a;	

	@ManyToOne(fetch = FetchType.EAGER)
	private B B;

	// some more @ManyToOne properties
}

@Entity
class C {
	@ManyToOne(fetch = FetchType.EAGER)
	private A a;

	@OneToOne(fetch = FetchType.EAGER, optional = true)
	private B b;

	@ManyToOne(fetch = FetchType.EAGER)
	private C C;

	// some more @ManyToOne properties
}

```

Selecting entities of Class C worked with WildFly 26 and Hibernate 5. But after migrating to WildFly 35 with Hibernate 6 I get the error that target lists can have at most 1664 entries. Reason is, that there are a lot of more joins in Hibernate 6.

Can someone tell me, why Hibernate 6 produces more joins for EAGER properties than Hibernate 5 and where to find relevant documentation?

---

<div class="post-metadata">

**Author:** ![beikov](https://yyz1.discourse-cdn.com/flex035/user_avatar/discourse.hibernate.org/beikov/32/258_2.png) [@beikov](https://discourse.hibernate.org/u/beikov)\
**Post date:** [June 18, 2025, 1:17pm UTC](https://discourse.hibernate.org/t/migrating-from-hibernate-5-to-6-results-in-error-that-target-lists-have-at-most-1664-entries/11571/4 "2025-06-18T13:17:00Z")

</div>

This is mentioned in the migration guide for 6.0: [hibernate-orm/migration-guide.adoc at 6.0 · hibernate/hibernate-orm · GitHub](https://github.com/hibernate/hibernate-orm/blob/6.0/migration-guide.adoc#fetch-circularity-determination)

You can either specify a max fetch depth to reduce the amount of joins or even better, try to get rid of EAGER fetching, because it’s a pain and cripples performance.

---

<div class="post-metadata">

**Author:** ![rhochreiter](https://avatars.discourse-cdn.com/v4/letter/r/8edcca/32.png) [@rhochreiter](https://discourse.hibernate.org/u/rhochreiter)\
**Post date:** [June 23, 2025, 1:06pm UTC](https://discourse.hibernate.org/t/migrating-from-hibernate-5-to-6-results-in-error-that-target-lists-have-at-most-1664-entries/11571/5 "2025-06-23T13:06:50Z")

</div>

Thank you for the hint to the documentation.

Well than I have do some refactoring in my entity model!
