类型"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>