我有一个域对象 T,它与另一个域对象 pTW 具有 oneToMany 关系。这是我班 T 的代码
@OneToMany(cascade = CascadeType.ALL, orphanRemoval = true)
@JoinColumn(name = "t")
@OrderBy("dateRequested desc")
@ForeignKey(name = "fk_t_ptw")
private final List<PTW> pTWList = new ArrayList<PTW>();
问题是当我更新、删除或插入 T 时,pTW 中的所有信息都会被忽略。其他类型的关系不会发生此问题。注释 @OneToMany 属于 javax.persistence 包。日志根本没有显示任何问题。
我的直觉是 jar 文件可能存在一些冲突或问题。这是我在运行 mvn:dependency:tree 时为 Hibernate 得到的:
[INFO] +- org.hibernate:hibernate-core:jar:4.2.0.Final:compile
[INFO] | +- antlr:antlr:jar:2.7.7:compile
[INFO] | +- org.jboss.logging:jboss-logging:jar:3.1.0.GA:compile
[INFO] | +- org.jboss.spec.javax.transaction:jboss-transaction-api_1.1_spec:jar:1.0.0.Final:compile
[INFO] | +- dom4j:dom4j:jar:1.6.1:compile
[INFO] | \- org.javassist:javassist:jar:3.15.0-GA:compile
[INFO] +- org.hibernate:hibernate-envers:jar:4.2.0.Final:compile
[INFO] | \- org.hibernate:hibernate-entitymanager:jar:4.2.0.Final:compile
[INFO] +- org.hibernate.common:hibernate-commons-annotations:jar:4.0.1.Final:compile
[INFO] +- org.hibernate.javax.persistence:hibernate-jpa-2.0-api:jar:1.0.1.Final:compile
[INFO] +- org.hibernate:hibernate-tools:jar:4.0.0-CR1:compile
[INFO] | +- javax.transaction:jta:jar:1.1:compile
[INFO] | +- ant:ant:jar:1.6.5:compile
[INFO] | +- org.hibernate:jtidy:jar:r8-20060801:compile
[INFO] | +- org.eclipse.tycho:org.eclipse.jdt.core:jar:3.8.0.v_C03:compile
[INFO] | +- org.eclipse:text:jar:3.2.0-v20060605-1400:compile
[INFO] | | +- org.eclipse.core:commands:jar:3.3.0-I20070605-0010:compile
[INFO] | | \- org.eclipse.equinox:common:jar:3.2.0-v20060603:compile
[INFO] | \- org.eclipse.core:runtime:jar:3.2.0-v20060603:runtime
[INFO] | +- org.eclipse:osgi:jar:3.4.3.R34x_v20081215-1030:runtime
[INFO] | +- org.eclipse.core:jobs:jar:3.3.0-v20070423:runtime
[INFO] | +- org.eclipse.equinox:registry:jar:3.3.0-v20070522:runtime
[INFO] | +- org.eclipse.equinox:preferences:jar:3.2.100-v20070522:runtime
[INFO] | \- org.eclipse.core:contenttype:jar:3.2.100-v20070319:runtime
有没有人遇到过同样的问题?谢谢