I'm guessing how the query below could be written through JPQL:
Select all parents(side 1 of a 1-n relationship) which last child (newest id) has a specific value for a column (attribute). My entities look like
Parent.java
@Entity
class Parent {
@Id
@Column(name="ID_PARENT")
@GeneratedValue(strategy=GenerationType.IDENTITY)
private Long id;
@OneToMany(mappedBy="parent")
private List<Child> children;
}
Child.java
@Entity
class Child {
@Id
@Column(name="ID_CHILD")
@GeneratedValue(strategy=GenerationType.IDENTITY)
private Long id;
@ManyToOne()
@JoinColumn(name="ID_PARENT")
private Parent parent;
private String attribute;
}
What would JPQL look like? Thank you all