我有一個域對象T,它與另一個域對象pTW有oneToMany關係。這是我的T類休眠oneToMany被忽略
@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:依賴關係:樹:
[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
任何人都經歷了同樣的問題?謝謝
關係編碼的方式遠非理想(我繼承了這個項目!)。我用更傳統的方式記錄了這種特殊的關係,這就是您建議的方式。不幸的是,問題仍然存在。無論如何感謝您的建議。 – alexgrimaldi