log.debug("get category list start "+id);
List<CategoryResponseView> usersViewList = new ArrayList<CategoryResponseView>();
long a=System.currentTimeMillis();
CriteriaBuilder builder = em.getCriteriaBuilder();
Metamodel metamodel=em.getMetamodel();
EntityType EntrepreneurCategory_=metamodel.entity(EntrepreneurCategory.class);
CriteriaQuery<Object[]> query = builder.createQuery(Object[].class);
Root<EntrepreneurCategory> entrepreneurCategoryRoot=query.from(EntrepreneurCategory.class);
Join<EntrepreneurCategory, Category> categoryJoin = entrepreneurCategoryRoot.join("category_id",JoinType.LEFT);
Join<EntrepreneurCategory, Cluster> clusterJoin = entrepreneurCategoryRoot.join("cluster_id",JoinType.LEFT);
List<Predicate> conditions = new ArrayList();
conditions.add(builder.equal(entrepreneurCategoryRoot.get("id"), id));
TypedQuery<Object[]> typedQuery = em.createQuery(query
.multiselect(entrepreneurCategoryRoot).where(conditions.toArray(new Predicate[] {}))
);
return usersViewList;
org.hibernate.ejb.criteria.BasicPathUsageException: Cannot join to attribute of basic type at org.hibernate.ejb.criteria.path.AbstractFromImpl.constructJoin(AbstractFromImpl.java:262) at org.hibernate.ejb.criteria.path.AbstractFromImpl.join(AbstractFromImpl.java:255) at org.hibernate.ejb.criteria.path.AbstractFromImpl.join(AbstractFromImpl.java:428) at com.vs.manifesto.logic.EntrepreneurCategoryBDL.getCategoryList(EntrepreneurCategoryBDL.java:55) at com.vs.manifesto.scoreboard.services.CategoryServices.getCategoryList(CategoryServices.java:44)
Following is the model class elements
@ManyToOne
@JoinColumn(name = "category_id",referencedColumnName="id",insertable=false,updatable=false)
private Category category;
private String category_id;
public Category getCategory() {
return category;
}
public void setCategory(Category category) {
this.category = category;
}
how to resolve this problem..?
You are joined to attribute of basic type because you are join String "category_id"
You need to change to join to a category like: