首页
学习
活动
专区
圈层
工具
发布
首页
学习
活动
专区
圈层
工具
社区首页 >问答首页 >无法针对路径解析属性[lieferungen]

无法针对路径解析属性[lieferungen]
EN

Stack Overflow用户
提问于 2012-12-19 16:10:33
回答 1查看 2K关注 0票数 1

我们在Maven测试中遇到了一个严重的问题。我们得到错误:无法针对路径解析属性lieferungen

不幸的是,其他帖子对我没有帮助。

THis是我的堆栈跟踪:

代码语言:javascript
代码运行次数:0
运行
AI代码解释
复制
Running de.shop.bestellverwaltung.service.LieferverwaltungTest
Tests run: 4, Failures: 0, Errors: 1, Skipped: 0, Time elapsed: 36.446 sec <<< FAILURE!
createLieferung(de.shop.bestellverwaltung.service.LieferverwaltungTest)  Time elapsed: 0.079 sec  <<< ERROR!
java.lang.IllegalArgumentException: Unable to resolve attribute [lieferungen] against path
    at org.hibernate.ejb.criteria.path.AbstractPathImpl.unknownAttribute(AbstractPathImpl.java:120)
    at org.hibernate.ejb.criteria.path.AbstractPathImpl.locateAttribute(AbstractPathImpl.java:229)
    at org.hibernate.ejb.criteria.path.AbstractFromImpl.fetch(AbstractFromImpl.java:595)
    at de.shop.bestellverwaltung.dao.BestellungDao.findBestellungenByIds(BestellungDao.java:36)
    at de.shop.bestellverwaltung.dao.BestellungDao$Proxy$_$$_WeldSubclass.findBestellungenByIds(BestellungDao$Proxy$_$$_WeldSubclass.java)
    at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
    at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:57)
    at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43)
    at java.lang.reflect.Method.invoke(Method.java:601)
    at org.jboss.weld.interceptor.proxy.SimpleInterceptionChain.invokeNextInterceptor(SimpleInterceptionChain.java:84)
    at org.jboss.weld.interceptor.proxy.InterceptorInvocationContext.proceed(InterceptorInvocationContext.java:127)
    at de.shop.util.LogInterceptor.log(LogInterceptor.java:87)
    at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
    at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:57)
    at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43)
    at java.lang.reflect.Method.invoke(Method.java:601)
    at org.jboss.weld.interceptor.proxy.SimpleMethodInvocation.invoke(SimpleMethodInvocation.java:30)
    at org.jboss.weld.interceptor.proxy.SimpleInterceptionChain.invokeNextInterceptor(SimpleInterceptionChain.java:68)
    at org.jboss.weld.interceptor.proxy.InterceptorMethodHandler.executeInterception(InterceptorMethodHandler.java:112)
    at org.jboss.weld.interceptor.proxy.InterceptorMethodHandler.invoke(InterceptorMethodHandler.java:88)
    at org.jboss.weld.bean.proxy.CombinedInterceptorAndDecoratorStackMethodHandler.invoke(CombinedInterceptorAndDecoratorStackMethodHandler.java:53)
    at de.shop.bestellverwaltung.dao.BestellungDao$Proxy$_$$_WeldSubclass.findBestellungenByIds(BestellungDao$Proxy$_$$_WeldSubclass.java)
    at de.shop.bestellverwaltung.service.BestellverwaltungImpl.createLieferung(BestellverwaltungImpl.java:194)
    at de.shop.bestellverwaltung.service.BestellverwaltungImpl$Proxy$_$$_WeldSubclass.createLieferung(BestellverwaltungImpl$Proxy$_$$_WeldSubclass.java)
    at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
    at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:57)
    at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43)
    at java.lang.reflect.Method.invoke(Method.java:601)
    at org.jboss.weld.interceptor.proxy.SimpleInterceptionChain.invokeNextInterceptor(SimpleInterceptionChain.java:84)
    at org.jboss.weld.interceptor.proxy.InterceptorInvocationContext.proceed(InterceptorInvocationContext.java:127)
    at de.shop.util.LogInterceptor.log(LogInterceptor.java:87)
    at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
    at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:57)
    at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43)
    at java.lang.reflect.Method.invoke(Method.java:601)
    at org.jboss.weld.interceptor.proxy.SimpleMethodInvocation.invoke(SimpleMethodInvocation.java:30)
    at org.jboss.weld.interceptor.proxy.SimpleInterceptionChain.invokeNextInterceptor(SimpleInterceptionChain.java:68)
    at org.jboss.weld.interceptor.proxy.InterceptorMethodHandler.executeInterception(InterceptorMethodHandler.java:112)
    at org.jboss.weld.interceptor.proxy.InterceptorMethodHandler.invoke(InterceptorMethodHandler.java:88)
    at org.jboss.weld.bean.proxy.CombinedInterceptorAndDecoratorStackMethodHandler.invoke(CombinedInterceptorAndDecoratorStackMethodHandler.java:53)
    at de.shop.bestellverwaltung.service.BestellverwaltungImpl$Proxy$_$$_WeldSubclass.createLieferung(BestellverwaltungImpl$Proxy$_$$_WeldSubclass.java)
    at de.shop.bestellverwaltung.service.LieferverwaltungTest.createLieferung(LieferverwaltungTest.java:136)
    at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
    at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:57)
    at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43)
    at java.lang.reflect.Method.invoke(Method.java:601)
    at org.junit.runners.model.FrameworkMethod$1.runReflectiveCall(FrameworkMethod.java:45)
    at org.junit.internal.runners.model.ReflectiveCallable.run(ReflectiveCallable.java:15)
    at org.junit.runners.model.FrameworkMethod.invokeExplosively(FrameworkMethod.java:42)
    at org.jboss.arquillian.junit.Arquillian$6$1.invoke(Arquillian.java:270)
    at org.jboss.arquillian.container.test.impl.execution.LocalTestExecuter.execute(LocalTestExecuter.java:60)
    at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
    at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:57)
    at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43)
    at java.lang.reflect.Method.invoke(Method.java:601)
    at org.jboss.arquillian.core.impl.ObserverImpl.invoke(ObserverImpl.java:94)
    at org.jboss.arquillian.core.impl.EventContextImpl.invokeObservers(EventContextImpl.java:99)
    at org.jboss.arquillian.core.impl.EventContextImpl.proceed(EventContextImpl.java:81)
    at org.jboss.arquillian.core.impl.ManagerImpl.fire(ManagerImpl.java:135)
    at org.jboss.arquillian.core.impl.ManagerImpl.fire(ManagerImpl.java:115)
    at org.jboss.arquillian.core.impl.EventImpl.fire(EventImpl.java:67)
    at org.jboss.arquillian.container.test.impl.execution.ContainerTestExecuter.execute(ContainerTestExecuter.java:38)
    at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
    at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:57)
    at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43)
    at java.lang.reflect.Method.invoke(Method.java:601)
    at org.jboss.arquillian.core.impl.ObserverImpl.invoke(ObserverImpl.java:94)
    at org.jboss.arquillian.core.impl.EventContextImpl.invokeObservers(EventContextImpl.java:99)
    at org.jboss.arquillian.core.impl.EventContextImpl.proceed(EventContextImpl.java:81)
    at org.jboss.arquillian.test.impl.TestContextHandler.createTestContext(TestContextHandler.java:89)
    at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
    at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:57)
    at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43)
    at java.lang.reflect.Method.invoke(Method.java:601)

以下是我的域类(Lieferung):

代码语言:javascript
代码运行次数:0
运行
AI代码解释
复制
public class Lieferung implements java.io.Serializable {
    private static final long serialVersionUID = -2297631209213102849L;

    private static final String PREFIX = "Lieferung.";
    public static final String FIND_LIEFERUNGEN_BY_LIEFERNR_FETCH_BESTELLUNGEN =
                               PREFIX + "findLieferungenByLieferNrFetchBestellungen";
    public static final String PARAM_LIEFERNR = "lieferNr";

    @Id
    @GeneratedValue
    @Column(name = "lid", unique = true, nullable = false, updatable = false, precision = LONG_ANZ_ZIFFERN)
    private Long lid;

    @Column(nullable = false)
    @Temporal(TIMESTAMP)
    private Date aktualisiert;

    @Column(nullable = false)
    @Temporal(TIMESTAMP)
    private Date erzeugt;

    @Column
    @Temporal(TIMESTAMP)
    private Date lieferungsdatum;

    @ManyToOne
    @JoinColumn(name = "bestellung_fk")
    private Bestellung bestellung;

这是我的域类Bestellung:

代码语言:javascript
代码运行次数:0
运行
AI代码解释
复制
public class Bestellung implements java.io.Serializable {
    private static final long serialVersionUID = -2703770025221749393L;

    private static final String PREFIX = "Bestellung.";
    public static final String FIND_BESTELLUNGEN_BY_KUNDE = PREFIX + "findBestellungenByKunde";
    public static final String FIND_BESTELLUNG_BY_ID_FETCH_LIEFERUNG =
                               PREFIX + "findBestellungenByIdFetchLieferung";
    public static final String FIND_KUNDE_BY_ID = PREFIX + "findBestellungKundeById";

    public static final String PARAM_KUNDEID = "kundeId";
    public static final String PARAM_ID = "id";

    @Id
    @GeneratedValue
    @Column(name = "bid", unique = true, nullable = false, updatable = false, precision = LONG_ANZ_ZIFFERN)
    @Min(value = MIN_ID, message = "{bestellverwaltung.bestellung.id.min}", groups = IdGroup.class)
    private Long bid = KEINE_ID;



    @OneToMany(fetch = EAGER, cascade = { PERSIST, REMOVE })
    @JoinColumn(name = "bid_fk", nullable = false)
    private List<Bestellposition> bestellpositionen;

    @OneToMany(cascade = { PERSIST, REMOVE }, mappedBy = "bestellung")
    private List<Lieferung> lieferung;

你还需要更多的信息。我非常绝望。在这里坐了4天。

EN

回答 1

Stack Overflow用户

发布于 2021-09-08 05:53:25

当我使用select(root.get("COLUMN_NAME"))时,我看到了类似的错误。最后,我必须使用Hibernate JPA2元模型生成器将元模型类生成到“目标/生成的类/注释”中。你只需要添加一个依赖jar并重新构建,在我的例子中不需要使用maven-compiler-plugin

代码语言:javascript
代码运行次数:0
运行
AI代码解释
复制
        <dependency>
            <groupId>org.hibernate</groupId>
            <artifactId>hibernate-jpamodelgen</artifactId>
            <version>${some_version_in_properties}</version>
        </dependency>

并且,启用IDEA的注释处理,例如在Intellij IDEA中。

https://docs.jboss.org/hibernate/stable/jpamodelgen/reference/en-US/html_single/

名称以_结尾的新类将位于类路径中。例如,对于实体类Entity,您将获得Entity_.class

然后,使用select(root.get(Entity_.propName))选择路径。

票数 0
EN
页面原文内容由Stack Overflow提供。腾讯云小微IT领域专用引擎提供翻译支持
原文链接:

https://stackoverflow.com/questions/13956450

复制
相关文章
针对属性的条件编译优化
随着时间的推移,Swift 引入了许多新的属性,用来在源代码中传递额外信息。现有代码可以利用新的构造来改进,引入新功能,提供新的编译检查,更好的性能等等。但是,现有代码引入新属性意味着不能在旧的编译器上使用。自然而然你会想到用条件编译来解决该问题。例如可以使用#if 检查编译器版本,查看是否可以使用@preconcurrency属性:
DerekYuYi
2022/11/09
9320
constructor属性解析
JavaScript中constructor属性一直不是很清楚,今日终于弄清了其中缘由,下面举例说明。 首先是一个典型的JavaScript实例声明: function Person(){ this.name = name; } var p = new Person('Joe'); console.log(p.constructor === Person); //true console.log(p.__proto__ === Person.prototype); //true 如果此时对Person的
寒月十八
2018/01/30
7190
python 解析url路径
原理:使用urlparse,先解析整个url,然后使用split('/')方式构造为词典,下面就可以直接读取
py3study
2020/01/07
2.1K0
python相对路径文件无法读取,更改工作路径
这是最坑的地方,一般很难想到这个。就是先取看看你当前的工作路径,否则你怎么写相路径都是没用的。当我想去访问另外一个层级的文件时,可以看到因为他将路径定义到了pachong这个路径下,所以他是怎么也查不到当前我要的文件的。
萌萌哒的瓤瓤
2020/08/26
2.9K0
python相对路径文件无法读取,更改工作路径
无法解析外部符号
本人在写qt工程的时候遇到无法解析外部符号 原因:只写了类声明,但还没有写实现类,造成调用时无法解析。 解决方法,把还没有实现类的声明给注释掉。
全栈程序员站长
2022/09/07
2.7K0
无法解析外部符号
java中无法解析为类型_java无法解析导入的包
.odt文件是openoffice软件产生的文档格式,可以直接用office打开,这其实就是一个压缩包,可以使用解压软件打开,里面有一个content.xml文件,这个文件内有<text:p>标签,标签内就是展示出来的内容。
全栈程序员站长
2022/10/28
4.8K0
Python3 解析路径
pathinfo = get_path_info('E:\\web\\python\\demo.txt');
py3study
2020/01/03
9100
Swift Codable 记录解析路径
在我们的工作中,各种特殊情况都有可能遇到,某些特定情况下,需要我们记录模型的解析路径,例如:
韦弦zhy
2021/11/24
8310
@FeignClient path属性路径前缀带路径变量时报错处理
FeignClient注解中使用path属性定义url前缀时,如果使用了路径变量,则会报错 例如
路过君
2021/10/15
3.3K0
针对网站链接-使用rel=”nofollow”属性提升网站seo
seo的优化做得好,毫无疑问可以提升网站的排名,增强百度,Google,搜狗等搜索引擎对网站的爬取,不断提升网站的权重,从而提高网站的曝光率,进而提升转化
itclanCoder
2022/03/31
5310
通过反射方式无法获取对象属性
最近在一个项目上开发的接口与业务方联调时计算参数签名总是对不上,经过排查后定位到原因: 1.父类定义的属性列表,全部为public类型 2.子类中未定义新的属性,所有属性都继承自父类 3.在计算签名时传递的是子类对象,子类对象使用反射方式调用getDeclaredFields()方法无法获取到从父类继承的属性
编程随笔
2021/12/21
2.9K0
Android常见XML属性解析
android:id的设置,通常有三种方式,分别是以下这三种: android:id=”@+id/xxx” android:id=”@android:id/tabhost” android:id=”@id/xxx”
小小工匠
2021/08/16
1.2K0
Spring Boot 属性配置解析
Spring Boot 3.1.0 支持的属性配置方式与2.x版本没有什么变动,按照以下的顺序处理,后面的配置将覆盖前面的配置: 1、SpringApplication.setDefaultProperties 指定的默认属性 2、@PropertySource注解配置 3、Jar包内部的application.properties 和 YAML 变量 4、Jar包内部的application-{profile}.properties 和 YAML 变量 5、Jar包外部的application.properties 和 YAML 变量 6、Jar包外部的application-{profile}.properties 和 YAML 变量 7、RandomValuePropertySource的随机值属性 8、操作系统环境变量 9、Java System属性 (System.getProperties()) 10、JNDI属性 11、ServletContext 初始化参数 12、ServletConfig 初始化参数 13、嵌入在环境变量或系统属性中的SPRING_APPLICATION_JSON 的属性 14、命令行参数 15、测试环境properties 属性 16、测试环境的@TestPropertySource 注解 17、Devtools 全局配置
阿提说说
2023/10/16
3910
Spring Boot 属性配置解析
Image无法使用相对路径导入
不能是使用相对路径的原因在于,图片资源未导入dotnet程序,所以在程序外部,通过绝对路径的方式查找加载。
sofu456
2019/07/09
1.8K0
Image无法使用相对路径导入
Coredns 添加主机名解析,无法解析
可以看到符合 k8s cluster.local 格式的域名 forward 是 coredns ,而其他的域名 forward 是 /etc/resolv.conf (主机系统的 dns),所以是解析不到自己添加在 coredns 中的主机名的。
tanmx
2023/10/18
4770
单源最短路径解析
1,设0为源点,建立两个集合S,T,S保存节点0,T集合保存节点1,2,3,4。(S,T是官方定义名称,个人理解S应该是source的缩写,T是target的缩写,看了英文是不是就明白点了)
Kiba518
2018/08/23
5030
针对 Bash 的不完整路径展开(补全)功能
bash-complete-partial-path 通过添加不完整的路径展开(类似于 Zsh)来增强 Bash(它在 Linux 上,macOS 使用 gnu-sed,Windows 使用 MSYS)中的路径补全。如果你想在 Bash 中使用这个省时特性,而不必切换到 Zsh,它将非常有用。
用户8639654
2021/10/21
1K0
深入解析最短路径算法
转载自:http://blog.csdn.net/fengchaokobe/article/details/7478774
全栈程序员站长
2022/09/05
6260
Linux知识体系之路径属性与目录
  最近在看鸟哥的Linux私房菜,我觉得这本书还是很不错的。这里进行相关的总结。
用户3003813
2018/09/06
7290
Linux知识体系之路径属性与目录
点击加载更多

相似问题

获取子类时出错:无法针对路径[null]解析属性[lastName]

11

Hibernate:无法针对非常简单的对象层次结构的路径解析属性

34

HQL:期望加入的路径!无法解析属性

13

无法使用附加属性解析属性路径中的所有属性引用

14

解析字段/属性路径?

28
添加站长 进交流群

领取专属 10元无门槛券

AI混元助手 在线答疑

扫码加入开发者社群
关注 腾讯云开发者公众号

洞察 腾讯核心技术

剖析业界实践案例

扫码关注腾讯云开发者公众号
领券
问题归档专栏文章快讯文章归档关键词归档开发者手册归档开发者手册 Section 归档
查看详情【社区公告】 技术创作特训营有奖征文