-
-
Notifications
You must be signed in to change notification settings - Fork 69
Description
Hello,
I'm currently using rsql-jpa-specifications
in a Spring Boot project and facing a challenge with querying entities based on conditions that span multiple child entities. I would appreciate any guidance or solutions you could offer, whether it's a native feature or requires custom code.
I have a parent entity MyEntity
that has a one-to-many relationship with a child entity Property
. Each Property
entity has two fields: key
and value
.
@Entity
public class MyEntity {
@Id
@GeneratedValue(strategy = GenerationType.IDENTITY)
private Long id;
@OneToMany(mappedBy = "myEntity")
private Set<Property> properties;
// Getters and setters
}
@Entity
public class Property {
@Id
@GeneratedValue(strategy = GenerationType.IDENTITY)
private Long id;
private String key;
private String value;
@ManyToOne
@JoinColumn(name = "my_entity_id")
private MyEntity myEntity;
// Getters and setters
}
I'm looking to query MyEntity based on conditions across multiple Property entities. Specifically, I want to find instances of MyEntity that have at least one Property with key equal to "Foo" and another Property with key equal to "Bar" AND value equal to "Baz".
Is there a way to construct such a query using rsql-jpa-specifications? If the library does not support this functionality directly, could you provide some advice on how I might implement this logic, possibly by extending the library or integrating custom specifications?
Thank you for your help!