Skip to content

Another "multivalued paths are only allowed" problem with JPA query methods #4192

@ML-Marco

Description

@ML-Marco
@Entity
public class MyEntity {

	@Id
	@GeneratedValue(strategy = GenerationType.IDENTITY)
	private Long id;

	@ManyToMany
	@JoinTable(name = "entity_stuff_join_table", joinColumns = {@JoinColumn(name = "fk_stuff")}, inverseJoinColumns = @JoinColumn(name = "fk_my_entity"))
	private List<Stuff> stuffList;
@Repository
public interface MyEntityRepository extends JpaRepository<MyEntity, Long> {

	void existsByStuffList(List<Stuff> stuffList);
	void existsByStuffList(Stuff stuff);
}

When calling either method this exception is thrown:

Multivalued paths are only allowed for the 'member of' operator; Bad SELECT m.id id FROM MyEntity m WHERE m.stuffList = :stuff grammar [JPQL]

The second method worked with Spring 6. I didn't test the first one but would assume that it worked too.

Edit: I just confirmed that both methods worked in Spring Data JPA 3.5.8. Make sure to call the first method with an immutable list of size one.

Metadata

Metadata

Assignees

No one assigned

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions