【问题标题】:JPA - java.lang.IllegalArgumentException: The attribute [productName] is not present in the managed typeJPA - java.lang.IllegalArgumentException:托管类型中不存在属性 [productName]
【发布时间】:2015-12-11 05:50:36
【问题描述】:

我正在使用 Criteria API 的多选选择以下列

代码 sn-p

criteriaQuery.multiselect(root.get(MasterCat_.prodId),
joinProduct.get(ProductList_.prName).alias("productName"));

criteriaQuery.orderBy(criteriaBuilder.desc
(root.get(mywrapperclass.getOrderBy())); 

按照上面的代码 sn-p 顺序,我从客户端传递productName

在构造函数表达式中我有

public ProductListUtil(Long logId, String productName) {            
            this.logId = logId;
            productName = productName;
            }

我得到的错误是java.lang.IllegalArgumentException: The attribute [productName] is not present in the managed type

我该如何解决这个问题?

异常堆栈跟踪

java.lang.IllegalArgumentException:属性 [productName] 不存在于托管类型 [EntityTypeImpl@5185929:ProductList [javaType: class test.entity.ProductList 描述符:RelationalDescriptor(test.entity.ProductList --> [DatabaseTable (PRODUCT_LISTS)]),映射:8]]。 在 org.eclipse.persistence.internal.jpa.metamodel.ManagedTypeImpl.getAttribute(ManagedTypeImpl.java:148) 在 org.eclipse.persistence.internal.jpa.querydef.FromImpl.get(FromImpl.java:312) 在 test.service.ProductListService.getProductListsList(ProductListService.java:129) 在 test.service.ProductListService.getProductLists(ProductListService.java:101) 在 test.service.ProductListService.getProductLists(ProductListService.java:94) 在 sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method) 在 sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:39) 在 sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:25) 在 java.lang.reflect.Method.invoke(Method.java:597) 在 com.sun.jersey.spi.container.JavaMethodInvokerFactory$1.invoke(JavaMethodInvokerFactory.java:60)

【问题讨论】:

  • 这并不是说构造函数中没有 arg ...它说类中没有具有该名称的属性。有吗?
  • @NeilStockton 非常感谢您指出这一点。

标签: jpa eclipselink jpa-2.0 criteria criteria-api


【解决方案1】:

这并不是说构造函数中没有 arg ......它说在具有该名称的类中没有属性。

【讨论】:

    猜你喜欢
    • 1970-01-01
    • 2019-04-28
    • 2017-06-21
    • 2019-12-30
    • 2019-11-01
    • 2019-10-14
    • 2018-03-11
    • 2019-04-16
    • 2015-09-18
    相关资源
    最近更新 更多