質問
スーパー抽象クラスがあります:
@XmlSeeAlso({AndQuery.class, OrQuery.class, NotQuery.class, PropertyQuery.class, MultiQuery.class})
@XmlRootElement
public abstract class Query {
このクラスにはサブクラスがあります:
public abstract class MultiQuery extends Query {
そしてこの最後のスーパークラスには、@ XmlRootNodeアノテーションが付けられたAndQueryとOrQueryの2つのサブクラスもあります。
Queryスーパークラスを拡張するPropertyQueryクラスもあります。
次のような投稿を行っても大丈夫です:
<?xml version="1.0" encoding="UTF-8" standalone="yes"?>
<orQuery>
<query xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:type="propertyQuery">
<propertyName>SenderContractNumber</propertyName>
<propertyValue>D*</propertyValue>
</query>
<query xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:type="propertyQuery">
<propertyName>SenderContractNumber</propertyName>
<propertyValue>A*</propertyValue>
</query>
<query xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:type="andQuery">
<query xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:type="propertyQuery">
<propertyName>documentNumber</propertyName>
<propertyValue>222</propertyValue>
</query>
<query xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:type="propertyQuery">
<propertyName>documentNumber</propertyName>
<propertyValue>222</propertyValue>
</query>
</query>
</orQuery>
欲しいのは、次のようなxmlをPOSTすることです:
<orQuyery>
<query>...</query>
<andQuery>
<query>...</query>
</andQuery>
</orQuery>
上記の内容の説明
OrQueryクラスではクエリノードのみが表示されることを期待しているため、注釈を付ける必要があることを教えてください。
助けてください...
どうもありがとう
解決
多くのクエリに他のクエリを含めようとしているようです。たとえば、MultiQueryに他のクエリのリストを含めたいとしましょう。
クエリタイプのリストのみがある場合、JAXBはリストに含めるクエリのタイプを決定できません。リストに含めることができるすべてのオプションを指定できます。これにより、指定された任意のタイプを許可するために生成されるスキーマ。
例:
@XmlElements({
@XmlElement(type=AndQuery.class),
@XmlElement(type=OrQuery.class),
@XmlElement(type=NotQuery.class),
@XmlElement(type=PropertyQuery.class),
@XmlElement(type=MultiQuery.class)
})
List<Query> queries;
所属していません StackOverflow