JAX-WS Web サービスと休止状態を使用して moxy を動作させることができないようです。私が何をしても、うまくいき@XMLInverseReference
ません。application
の変数に入力することを期待していますSite
。私は何をしているのか、理解が間違っていますか?
受け取りました: org.hibernate.PropertyValueException: not-null property references a null or transient value: Site.application
. に追加@XMLElement
するとSite.application
、JAXB から循環参照例外が発生します。
すべてのマーシャリングとアンマーシャリングが JAX-WS WSServlet エンドポイントによって処理されることに注意してください。
また、次のようにして、jaxb.properties が正しく機能していることを確認しました。
public class Run {
public static void main(String[] args) throws Exception {
System.out.println(JAXBContext.newInstance(Site.class).getClass());
}
}
応用:
@Entity
@Table(schema = "dbo", name = "Applications")
@XmlAccessorType(XmlAccessType.NONE)
@XmlRootElement
public class Application {
@Id
@Column(name = "id", nullable = false, insertable = false, updatable = false)
@GeneratedValue(strategy = GenerationType.IDENTITY)
@RemoteProperty
@XmlElement
private Integer id;
@Column(name = "code", nullable = false, unique = true)
@NaturalId
@XmlElement
private String code;
@Column(name = "name")
@XmlElement
private String name;
@OneToMany(mappedBy = "application", fetch = FetchType.EAGER)
@Cache(usage = org.hibernate.annotations.CacheConcurrencyStrategy.READ_WRITE)
@Cascade(value = {CascadeType.MERGE, CascadeType.PERSIST, CascadeType.DELETE, CascadeType.DELETE_ORPHAN})
@Sort(type = SortType.NATURAL)
@XmlElement
private Set<Site> sites = new TreeSet<Site>();
}
サイト:
@Entity
@Table(schema = "dbo", name = "Sites")
@XmlAccessorType(XmlAccessType.NONE)
@XmlRootElement
public class Site implements Identifiable<Integer>, Comparable<Site> {
@Id
@Column(name = "id", nullable = false, insertable = false, updatable = false)
@GeneratedValue(strategy = GenerationType.IDENTITY)
private Integer id;
@Column(name = "address", unique = true)
@NaturalId(mutable = true)
@XmlID
private String address;
@Column(name = "ssl")
@XmlAttribute(required = true)
private boolean ssl;
@ManyToOne
@JoinColumn(name = "applicationCode", nullable = false, referencedColumnName = "code")
@XmlInverseReference(mappedBy = "code")
private Application application;
}
jaxb.properties
javax.xml.bind.context.factory=org.eclipse.persistence.jaxb.JAXBContextFactory