'JOQL query on a converted attribute
I have an entity :
@Entity
@Builder
@EqualsAndHashCode(onlyExplicitlyIncluded = true)
public class LegSchedule extends BaseEntity {
@Id
@GeneratedValue(strategy = GenerationType.IDENTITY)
@EqualsAndHashCode.Include
private Long id;
@Column(columnDefinition = "text", length = 100)
@Convert(converter = SetToJsonArrayConverter.class)
@Builder.Default
private Set<String> assignedLoads = new HashSet<>();
It contains an attribute assignedLoads, which is stored in the database as a json string using a converter, but it a Set of Strings in the entity.
I am trying to make this JPQL query work but it doesn't :
@Query(value = "FROM UnitGroup g "
+ "JOIN FETCH g.units "
+ "JOIN FETCH g.schedules "
+ "WHERE EXISTS ("
+ " SELECT 1 FROM LegSchedule s "
+ " WHERE s.group.id = g.id "
+ " AND :loadReference member of s.assignedLoads" //This doesn't work
+ " )")
Set<UnitGroup> loadGroupsAssignedOnLoadByLoadReference(@Param("loadReference") String loadReference);
Any idea on how to make it work?
Sources
This article follows the attribution requirements of Stack Overflow and is licensed under CC BY-SA 3.0.
Source: Stack Overflow
| Solution | Source |
|---|
