gpt4 book ai didi

java - 类型 "class *"未被增强的JPA异常

转载 作者:行者123 更新时间:2023-11-29 05:37:15 24 4
gpt4 key购买 nike

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

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

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.

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

最佳答案

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

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

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

关于java - 类型 "class *"未被增强的JPA异常,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/19042416/

24 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com