# After Hibernate 6 upgrade native query on parent class fails with “ORA-17006: Invalid column name”

**URL:** <https://discourse.hibernate.org/t/after-hibernate-6-upgrade-native-query-on-parent-class-fails-with-ora-17006-invalid-column-name/11826>\
**Category:** Hibernate ORM\
**Created:** [October 14, 2025, 1:14pm UTC](https://discourse.hibernate.org/t/after-hibernate-6-upgrade-native-query-on-parent-class-fails-with-ora-17006-invalid-column-name/11826 "2025-10-14T13:14:49Z")\
**Posts on this page:** 3\
**Page:** 1

<div class="post-metadata">

**Author:** ![accelerating\_bear](https://avatars.discourse-cdn.com/v4/letter/a/6a8cbe/32.png) [@accelerating\_bear](https://discourse.hibernate.org/u/accelerating_bear)\
**Post date:** [October 14, 2025, 1:14pm UTC](https://discourse.hibernate.org/t/after-hibernate-6-upgrade-native-query-on-parent-class-fails-with-ora-17006-invalid-column-name/11826/1 "2025-10-14T13:14:49Z")

</div>

Hi,

After upgrading from **Hibernate 5** to **Hibernate 6** , a native query that used to work now fails with an _invalid column name_ error.

### Entity definitions

**Base class:**

```java
@Entity
@Table(name = "POINTS")
@Inheritance(strategy = InheritanceType.JOINED)
public class Point {

    @Id
    private Long id;

    @Column(name = "POINT_NAME")
    private String name;

    @Size(max = 250)
    @Column(name = "DESCRIPTION")
    private String description;
    
    // more columns...
}

```

**Subclass:**

```java
@Entity
@Table(name = "REFERENTIALS")
@PrimaryKeyJoinColumn(name = "REFERENTIAL_ID")
public class Referential extends Point {

    @NotNull
    @Size(max = 30)
    @Column(name = "REFERENTIAL_NAME")
    private String referentialName;
}

```

### The query

I have a mechanism that dynamically builds a native SQL query, and it produces:

```sql
SELECT points_0.*, 0 as clazz_
FROM points points_0

```

Which is executed with the entity manager :

```auto
entityManager.createNativeQuery("SELECT points_0.*, 0 as clazz_ FROM points points_0", Point.class);

```

This query worked fine with Hibernate 5.

### The problem

After upgrading to Hibernate 6, it now fails with the following error:

```auto
DEBUG o.h.e.jdbc.spi.SqlExceptionHelper - Unable to find column position by name: referential_name [n/a]
java.sql.SQLException: ORA-17006: Invalid column name

```

It looks like Hibernate 6 tries to map subclass columns (`referential_name`) even though the query only targets the base table (`POINTS`).

How can I execute a **native query that maps only to the base class (`Point`)** in Hibernate 6 without Hibernate trying to include subclass columns?

thank you !

---

<div class="post-metadata">

**Author:** ![mbladel](https://yyz1.discourse-cdn.com/flex035/user_avatar/discourse.hibernate.org/mbladel/32/2128_2.png) [@mbladel](https://discourse.hibernate.org/u/mbladel)\
**Post date:** [October 15, 2025, 1:13pm UTC](https://discourse.hibernate.org/t/after-hibernate-6-upgrade-native-query-on-parent-class-fails-with-ora-17006-invalid-column-name/11826/2 "2025-10-15T13:13:01Z")

</div>

Hello @accelerating_bear, many aspects of queries have changed from H5 to H6, and the latter now expects all columns of the entity hierarchy you’re selecting to be present. If you feel like this is a bug, feel free to create an issue in the [issue tracker](https://hibernate.atlassian.net/browse/HHH) with a [test case](https://github.com/hibernate/hibernate-test-case-templates/blob/master/orm/hibernate-orm-6/src/test/java/org/hibernate/bugs/JPAUnitTestCase.java) that reproduces the issue.

I’m wondering though, why is it you’re using a native query when you need to retrieve the entire entity class anyway? With HQL you could very easily write something like:

```sql
select p from Point p where type(p) = Point

```

And only get entities of the super-type.

---

<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:** [October 21, 2025, 5:45pm UTC](https://discourse.hibernate.org/t/after-hibernate-6-upgrade-native-query-on-parent-class-fails-with-ora-17006-invalid-column-name/11826/3 "2025-10-21T17:45:13Z")

</div>

I assume you created the [HHH-19881](https://hibernate.atlassian.net/browse/HHH-19881) Jira issue? Like I wrote in the comment, this is expected and also [documented behavior](https://docs.hibernate.org/orm/7.1/userguide/html_single/#sql-inheritance-query).
