@NotFound breaks native query

See project to reproduce the error : GitHub - gaetannandelec-ibboost/hibernate6-not-found-issue

I have the following class :

Parent :

@Entity
@Table(name = "parents")
public class Parent {

	@Id
	@GeneratedValue(strategy = GenerationType.IDENTITY)
	@Column
	private Long id;

	@Column
	private String name;

	@ManyToOne(fetch = FetchType.EAGER)
	@JoinColumn(name = "child_fk")
	@NotFound(action = NotFoundAction.IGNORE)
	protected Child child;

	@ManyToOne(fetch = FetchType.EAGER)
	@JoinColumn(name = "animal_fk")
	protected Animal animal;
...
}

Child

@Entity
@Table(name = "childs")
public class Child {

	@Id
	@Column(name = "record_id")
	@GeneratedValue(strategy = GenerationType.IDENTITY)
	private Long recordId;

	@Column
	private String name;
..
}

Please note that the id here is not called id but recordId

Animal :

@Entity
@Table(name = "animals")
public class Animal implements Serializable {

	@Id
	@GeneratedValue(strategy = GenerationType.IDENTITY)
	@Column
	private Long id;

	@Column
	private String name;
...
}

I have the following DAO :

@Query(nativeQuery = true, countQuery = "select 1", value = "select ji.* from parents ji inner join animals ju on ju.id = ji.animal_fk where ju.id is not null and ji.child_fk = :childID limit 1")
Parent findByCriteria(@Param(childID) Long childID);

It gives the following error :

org.springframework.dao.InvalidDataAccessResourceUsageException: Unable to find column position by name: record_id; SQL [n/a]

If i remove the @NotFound(action = NotFoundAction.IGNORE) or rename the Child Id property id. It works

You can try out 6.2.0-SNAPSHOT. This was fixed as part of [HHH-16191] - Hibernate JIRA in this commit: HHH-16191 change @NotFound semantic, do not force a join but trigger … · hibernate/hibernate-orm@10bfcab · GitHub