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

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

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

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

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

THis是我的堆栈跟踪:

代码语言:javascript
运行
复制
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
运行
复制
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
运行
复制
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 13:53:25

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

代码语言:javascript
运行
复制
        <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

复制
相关文章

相似问题

领券
问题归档专栏文章快讯文章归档关键词归档开发者手册归档开发者手册 Section 归档