# The collection-valued path xxx cannot be resolved to a valid association field

**URL:** https://discourse.hibernate.org/t/the-collection-valued-path-xxx-cannot-be-resolved-to-a-valid-association-field/3743
**Category:** Hibernate ORM
**Created:** [February 13, 2020, 2:50pm UTC](https://discourse.hibernate.org/t/the-collection-valued-path-xxx-cannot-be-resolved-to-a-valid-association-field/3743 "2020-02-13T14:50:36Z")
**Posts on this page:** 1
**Page:** 1

<div class="post-metadata">

### Author: ![jboblitz](https://avatars.discourse-cdn.com/v4/letter/j/9fc29f/32.png) [@jboblitz](https://discourse.hibernate.org/u/jboblitz)
#### Post date: [February 13, 2020, 2:50pm UTC](https://discourse.hibernate.org/t/the-collection-valued-path-xxx-cannot-be-resolved-to-a-valid-association-field/3743/1 "2020-02-13T14:50:36Z")

</div>

Hello,

I new to the forum and to Hibernate and have been tasked with migrating from openjpa to Hibernate. Most everything has gone well, but I am encountering a problem which does not seem to be solvable …

Here is the situation:  
I have a Table “Department” which is modeled as an Entity. There is a second table “DepartmentRoles” which contains two columns - the departmentId as an FK to Department and a text field which contains the Role - this is NOT modeled as an Entity. Instead it is mapped as an ElementCollection in Department. Up to this point, all seems well. However, the is a defined NamedQuery which attempts to query based on the role - this looks like

```auto
@NamedQuery(name = "ac.Department.role", query = "SELECT c.uniqueId, c.code, FROM Department c WHERE c.active = true AND :role MEMBER OF c.roles ORDER BY c.code"),

```

This worked just fine in openjpa - but now the complier is complaining that

```auto
The collection-valued path 'c.roles' cannot be resolved to a valid association field.

```

Roles is mapped as

```auto
    @ElementCollection(fetch = FetchType.LAZY, targetClass = DepartmentRole.class)
    @CollectionTable(schema = "bds", name = "DepartmentRole", joinColumns = @JoinColumn(name = "departmentId"))
    @Enumerated(EnumType.STRING)
    @Column(name = "role")
    private Set<DepartmentRole> roles = new HashSet<>();

```

I tried switching to a JOIN a la “LEFT JOIN c.roles r” (tip from [Hibernate Tips: How to use @ElementCollection entries in a query](https://thoughts-on-java.org/hibernate-tips-query-elementcollection/)

and using an IN elements() - the first gave the same error, elements apparently is not valid.

So - the question is - how do I get this to work. As I said earlier, this worked fine under openjpa - so I’m hoping it is a “small” matter.
