类型“class *”尚未增强JPA异常

时间:2013-09-27 03:54:15

标签: java jpa openjpa

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

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

  

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

但是,this article表示我的类应该已经在运行时得到增强。 ChangeRoutineConsumedPK是一个可嵌入的类。有人可以看看我的班级并告诉我我做错了什么吗?谢谢。

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) {...}
}

2 个答案:

答案 0 :(得分:3)

ChangeRoutineConsumedPK类未添加到persistence.xml中,我已关闭自动类扫描。

将类添加到persistence.xml修复了问题

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

答案 1 :(得分:0)

如果你在执行中从主类传递下面的参数执行 java -javaagent:/openjpa.jar com.xyz.Main

如果在运行配置&gt;中使用eclipse给出上述值参数&gt; VM参数。