I want to prepare a simple SQL query with join using criteriaAPI. Let's assume that I have table PERSON with column ID and PET_ID which refers table PET. In my application I have both Person and PET entity, however PET isn't mapped to an entity - person keeps only pet id as number.
@Entity
public class Person {
@Id
private int id;
@Column("PET_ID")
private int petId;
}
@Entity
public class Pet {
@Id
private int id;
}
Those are only examples but it's enough to show what I want to achieve. In Oracle I would write simple query:
SELECT _p.id, _pet.id from PERSON _p join PET _pet on _p.pet_id=_pet.id;
But I am not able to achieve this using criteriaAPI - I know that if I would have Pet entity mapped in Person class it would be easy, but with below example I already spent much time without finding any solution