Home > Enterprise >  spring boot with hibernate and postgres giving exception column name not found even it is present
spring boot with hibernate and postgres giving exception column name not found even it is present

Time:10-01

I'm using native query as below in spring boot with postgres and hibernate.

@Query(value = "SELECT json_data from xxxschema.roles where role_id =?1", nativeQuery = true) Role getRolePrivilegesByRoleId(int id);

I'm getting following errors not sure why ?

org.postgresql.util.PSQLException: The column name role_id was not found in this ResultSet. at org.postgresql.jdbc.PgResultSet.findColumn(PgResultSet.java:2748) ~[postgresql-42.2.16.jar:42.2.16]

CodePudding user response:

You are returning Role but do not return all columns from the query mapped in the Role entity.

  • Related