Reputation: 75
I have a JPA Typed query join issue. When I use the following code
SELECT cve from CubeValuesEntity cve inner join CubeConfigEntity cce
on cve.cubeConfigId=cce.cubeConfigId
I get a QuerySyntaxException: Path expected for join! which I believe the fix to that error is the following
SELECT cve from CubeValuesEntity cve inner join cve.CubeConfigEntity cce
on cve.cubeConfigId=cce.cubeConfigId
However I now get QueryException: could not resolve property: CubeConfigEntity which makes no sense at all.
Here is the actual java code I used:
TypedQuery<CubeValuesEntity> query = em.createQuery(
"SELECT cve from CubeValuesEntity cve inner join cve.CubeConfigEntity cce on cve.cubeConfigId=cce.cubeConfigId where " + "cce.cubeType = :cubeType
and cce.name = :name and cve.axisType = :axisType", CubeValuesEntity.class)
.setParameter("cubeType", cubeType).setParameter("name", name).setParameter("axisType", axisType);
return query.getResultList();
Here are my entities
public class CubeValuesEntity extends AbstractDomainObject {
private static final long serialVersionUID = 1L;
private int cubeValueId;
private int cubeConfigId;
private String axisType;
private int axisNumber;
private String axisLabel;
private BigDecimal axisFactor;
public class CubeConfigEntity extends AbstractDomainObject {
private int cubeConfigId;
private String cubeType;
private String name;
private String yAxisName;
private Integer yAxisCubeSize;
private String xAxisName;
private Integer xAxisCubeSize;
private String reductionType;
private BigDecimal midLowRange;
private BigDecimal midHighRange;
Thanks for your help.
Upvotes: 0
Views: 324
Reputation: 1234
I belive you're mixing JQL and SQL here.
Assuming you have a XToOne relation between CubeValuesEntity and CubeConfigEntity, a property named "cubeConfig":
So, simply try this:
"SELECT cv from CubeValuesEntity cv inner join cv.cubeConfig cc where..."
br, Jens
Upvotes: 1