Skip to main content
AI Assist is now on Stack Overflow. Start a chat to get instant answers from across the network. Sign up to save and share your chats.
added 102 characters in body
Source Link
zbig
  • 4k
  • 2
  • 31
  • 38

What you are trying to achieve is forbidden by JPA spec. single-valued path expressions are valid in select clause but collection-valued path expressions are not valid. See chapter 4.8 of the spec. I cite Pro JPA book:

The following query is illegal: SELECT d.employees FROM Department d

The same is applies for Criteria queries. Why not just query for Unit and call getDocumentList()?

EDIT: You can also try to reverse the query:

SELECT d FROM Document d WHERE d.unit.id=:id 

What you are trying to achieve is forbidden by JPA spec. single-valued path expressions are valid in select clause but collection-valued path expressions are not valid. See chapter 4.8 of the spec. I cite Pro JPA book:

The following query is illegal: SELECT d.employees FROM Department d

The same is applies for Criteria queries. Why not just query for Unit and call getDocumentList()?

What you are trying to achieve is forbidden by JPA spec. single-valued path expressions are valid in select clause but collection-valued path expressions are not valid. See chapter 4.8 of the spec. I cite Pro JPA book:

The following query is illegal: SELECT d.employees FROM Department d

The same is applies for Criteria queries. Why not just query for Unit and call getDocumentList()?

EDIT: You can also try to reverse the query:

SELECT d FROM Document d WHERE d.unit.id=:id 
Source Link
zbig
  • 4k
  • 2
  • 31
  • 38

What you are trying to achieve is forbidden by JPA spec. single-valued path expressions are valid in select clause but collection-valued path expressions are not valid. See chapter 4.8 of the spec. I cite Pro JPA book:

The following query is illegal: SELECT d.employees FROM Department d

The same is applies for Criteria queries. Why not just query for Unit and call getDocumentList()?