0

I have an EstablishmentEntity which has an array of Attachment, i want to get the EstablishmentEntity that its Attachments contains an Attachment that its idChild equals the parameter i pass

@Entity
@DiscriminatorValue
public class EstablishmentEntity extends ExerciseFrameworkEntity {

    @ElementCollection
    private Set<Attachment> attachments;

}

public class Attachment implements Serializable {

    private static final long serialVersionUID = 1L;

    private String idChild;

}

I tried with this, but i get this error

Parameter value element [xxxxxxxx] did not match expected type Attachment

@Repository
public interface EstablishmentRepository extends JpaRepository<EstablishmentEntity, String> {
    
    EstablishmentEntity findByAttachmentsIn(String idChild);
    
}

1 Answer 1

1

findByAttachmentsIn expect List of Attachment for In query but you are passing String.

Use IdChild instead of In in method naming as you search by idChild of Attachment

EstablishmentEntity findByAttachmentsIdChild(String idChild);
Sign up to request clarification or add additional context in comments.

2 Comments

i get this error: Failed to create query for method public abstract EstablishmentEntity findByAttachmentsIdChild(java.lang.String)! Illegal attempt to dereference path source [null] of basic type
Use @Embeddable in Attachment class

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.