working with implementing Spring Data JPA and derived query methods for complex types
I'm experimenting with I'm trying to configure I'm having trouble with I'm working on a Spring Boot application using Spring Data JPA (version 2.6.3), and I have a requirement to fetch a list of entities based on a derived query method... My entity class, `Product`, has a nested class `Details` that contains fields for `color` and `size`. I'm trying to create a method that retrieves all products with a specific color and size combination, and I'm getting a `org.springframework.data.mapping.PropertyReferenceException` when I try to execute the query. Here's the relevant part of my `Product` entity: ```java @Entity public class Product { @Id @GeneratedValue(strategy = GenerationType.IDENTITY) private Long id; private String name; @Embedded private Details details; // Getters and setters } @Embeddable public class Details { private String color; private String size; // Getters and setters } ``` I've defined my repository interface like this: ```java public interface ProductRepository extends JpaRepository<Product, Long> { List<Product> findByDetails_ColorAndDetails_Size(String color, String size); } ``` When I call this repository method from my service layer, I get the following behavior: ``` org.springframework.data.mapping.PropertyReferenceException: No property details.Color found for type Product! ``` I've ensured that the fields in the `Details` class are correctly annotated, and I thought that using the `@Embedded` annotation would allow me to reference nested properties in the derived query method. I've also tried renaming the method and rechecking the casing of `Color` and `Size`, but nothing seems to work. Can anyone guide to understand what I'm doing wrong or suggest an alternative approach to achieve this functionality? Thanks for taking the time to read this! I'm working with Java in a Docker container on Windows 11. I'd be grateful for any help. I've been using Java for about a year now.