Win a copy of Practical SVG this week in the HTML/CSS/JavaScript forum!
  • Post Reply Bookmark Topic Watch Topic
  • New Topic

JPA: could not resolve property

 
zhao yu
Greenhorn
Posts: 2
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Hi.everyone,My name is 赵宇, I'm a Chinase.English name is zhaoyubetter
I like java but there ara too much problem appear . My English is not very well.
So I come here one to Learn Java EE one to Learn Englis
Thanks for Everyone .

Today appear a problem and I can't to solve it .

Detail:
I use JPA and Spring. workspace is MyEclipse6.0

public class ProductTypeServiceBean extends DaoSupport implements ProductTypeService {
/**重载删除方法,更新产品类型显示属性(不进行物理删除 **/
@Override
public <T> void delete(Class<T> entityClass, Object[] entityIds) {
/**
* 用JPA规范中的createQuery进行面向对象查询(ProductType为实体名称
* (bVisible=?1).setParameter(1, false) 表示的是用未知参数方法.
*/
if (entityIds != null && entityIds.length > 0) {
StringBuffer jpql = new StringBuffer();
for (int i = 0; i < entityIds.length; i++) {
jpql.append("?").append(i + 2).append(",");
}
jpql.deleteCharAt(jpql.length() - 1); // 删除最后的逗号
Query query = em.createQuery(
"UPDATE ProductType o SET o.bVisible=?1 WHERE o.iTypeId IN ("
+ jpql.toString() + ")").setParameter(1, false);
for (int i = 0; i < entityIds.length; i++) {
query.setParameter(i+2, entityIds[i]);
}
query.executeUpdate();
}

Caused by: org.hibernate.QueryException: could not resolve property: bVisible of: yu.bean.product.ProductType [UPDATE yu.bean.product.ProductType o SET o.bVisible=?1 WHERE o.iTypeId IN (?2)]
 
zhao yu
Greenhorn
Posts: 2
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Thanks
The problem is solved.
 
  • Post Reply Bookmark Topic Watch Topic
  • New Topic
Boost this thread!