public class ImageLog {
@ManyToOne
@JoinColumn(name = "lateral_id", nullable = false)
public Lateral lateral;
}
public class Lateral {
@ManyToOne(fetch = FetchType.EAGER)
@JoinColumn(name = "project_uuid", nullable = false, updatable = false)
public Project project;
}
public class Project {
@ManyToOne(fetch = FetchType.EAGER)
@Column(name = "company_id", insertable = false, updatable = false)
public Company company;
}
And repository query:
@Query("SELECT ilog.lateral.project FROM ImageLog ilog JOIN FETCH ilog.lateral.project.company WHERE ilog.uuid = ?1")
Optional<Project> findParentProject(UUID logUuid);
And the error appears:
org.hibernate.query.SemanticException: query specified join fetching, but the owner of the fetched association was not present in the select list [SqmSingularJoin(com.repository.project.imagelog.entity.ImageLog(ilog).lateral : lateral)]