类型"class *"尚未增强的JPA异常 [英] The type "class *" has not been enhanced JPA exception

查看:241
本文介绍了类型"class *"尚未增强的JPA异常的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我正在运行WebSphere v8,并在Java EE 6环境中使用JPA持久性.

I am running WebSphere v8, and using JPA persistence in a Java EE 6 environment.

当我尝试运行处理特定实体的代码时,遇到了此异常:

When I attempt to run code that deals with a particular entity, I run into this exception:

javax.ejb.EJBTransactionRolledbackException:嵌套异常是:javax.ejb.EJBTransactionRolledbackException:嵌套异常是:javax.ejb.EJBException:请参见嵌套异常;请参见嵌套异常.嵌套的异常是:org.apache.openjpa.persistence.ArgumentException:类型"au.com.combined.domain.changeroutine.ChangeRoutineConsumedPK"的类型未得到增强.

javax.ejb.EJBTransactionRolledbackException: nested exception is: javax.ejb.EJBTransactionRolledbackException: nested exception is: javax.ejb.EJBException: See nested exception; nested exception is: org.apache.openjpa.persistence.ArgumentException: The type "class au.com.combined.domain.changeroutine.ChangeRoutineConsumedPK" has not been enhanced.

但是,本文说,我的课程应该已经在运行时得到增强. ChangeRoutineConsumedPK是一个可嵌入类.有人可以看看我的课,然后告诉我我做错了什么吗?谢谢.

However, this article says that my classes should already be enhanced at runtime. ChangeRoutineConsumedPK is an Embeddable Class. Could someone take a look at my class and tell me what i'm doing wrong? thank you.

ChangeRoutineConsumed:

@Entity
@Table(name = ChangeRoutineConsumed.TABLE_NAME)
public class ChangeRoutineConsumed extends BaseBusinessObject {

    public static final String TABLE_NAME = "COCHANGEROUTINECONSUMED";

    @EmbeddedId
    private ChangeRoutineConsumedPK id;

    protected ChangeRoutineConsumed() {
        super();
    }

    public ChangeRoutineConsumed(@Min(1) long changeRoutineId, @NotNull String consumedBy){
        this(new ChangeRoutineConsumedPK(changeRoutineId, consumedBy));
    }

    public ChangeRoutineConsumed(@NotNull ChangeRoutineConsumedPK id){
        super();
        setId(id);
    }
    ...
    public int hashCode(){...};
    public boolean equals(Object obj){...}
}

ChangeRoutineConsumedPK:

@Embeddable
public class ChangeRoutineConsumedPK {

    @Column
    private long changeRoutineId;
    @Column
    private String consumedBy;

    public ChangeRoutineConsumedPK(){}

    public ChangeRoutineConsumedPK(long changeRoutineId, String consumedBy) {
        setChangeRoutineId(changeRoutineId);
        setConsumedBy(consumedBy);
    }
    ...

    public int hashCode() {...}
    public boolean equals(Object obj) {...}
}

推荐答案

ChangeRoutineConsumedPK类未添加到persistence.xml中,并且我关闭了自动类扫描.

The ChangeRoutineConsumedPK class was not added to the persistence.xml and i had turned off automatic class scanning.

将类添加到persistence.xml中解决了该问题

Adding the class to the persistence.xml fixed the problem

<persistence-unit ...>
...
<class>au.com.combined.domain.changeroutine.ChangeRoutineConsumedPK</class>
...
</persistence-unit>

这篇关于类型"class *"尚未增强的JPA异常的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆