I am trying to join to different entities from the same table using a constant value in the join statement. In SQL, I would do something like this...
SELECT
If you don't mind using Hibernate-specific annotations you could try with the @WhereJoinTable
annotation, e.g.:
@OneToOne(mappedBy = "owner", fetch = FetchType.EAGER, cascade = CascadeType.ALL)
@JoinColumn(name = "ID", referencedColumnName = "ID")
@WhereJoinTable(clause = "TYPE = 'A'")
private TypeA inspectionSnapshot;
Note that the clause
attribute must contain SQL, not JPQL, so you need to use the database column name instead of the JPA entity field name.