It is well known that we can get an entity and all its children in a single JPQL query using the join fetch command. However, I cannot get this work to work with my own request. I get [Ljava.lang.Object; cannot be cast to com.myapp.SearchResult [Ljava.lang.Object; cannot be cast to com.myapp.SearchResult .
What happens is that I have a @SqlResultSetMapping configuration with multiple @EntityResult s. Some related entities are one-to-one. One of the relationships is a one-to-many relationship. Instead of a JPA that establishes a parent-child relationship, it returns one list of objects in a row, with each element in the list having one of the defined entity types.
Any idea how to make this work work as intended? Any examples of this case?
source share