The following QueryDSL query gives the correct response :
return new JPAQuery<>(entityManager)
.select(QCategoryEntity.categoryEntity)
.from(QCategoryEntity.categoryEntity)
.where(QCategoryEntity.categoryEntity.parentCategory.id.eq(4L))
.fetch();
The following does not :
return new JPASQLQuery<>(entityManager, new DB2Templates())
.select(QCategoryEntity.categoryEntity)
.from(QCategoryEntity.categoryEntity)
.where(QCategoryEntity.categoryEntity.parentCategory.id.eq(4L))
.fetch();
The latter returns the following error :
Column "CATEGORYENTITY.PARENTCATEGORY.C_I_IDF" not found; SQL statement: select categoryEntity.* from CATEGORY categoryEntity where categoryEntity.parentCategory.C_I_IDF = ? [42122-200]
My Hibernate class looks like this :
@Entity
@Table(name = "CATEGORY")
public class CategoryEntity {
@Id
@GeneratedValue(strategy= GenerationType.IDENTITY)
@Column(name = "C_I_IDF")
protected Long id;
@ManyToOne(fetch = FetchType.LAZY)
@JoinColumn(name="C_PARENTCATEGORY")
private CategoryEntity parentCategory;
...
}
Any idea why? I generated the entity classes both withe the Hibernate annotation processor as well as the querydsl-maven-plugin which translates my schema to entities.