Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

prevent schemagen from adding the super-class to the schema?

how do i prevent schemagen from adding the super-class to the schema?

I have tried using XMLTransient on the super-class, and on its fields but they still show up in the schema .

for example :

@XmlTransient
public class Asset {

   @XmlTransient
   public Long ID;
}

public class Movie extends Asset {

}

creates this schema :

<xs:complexType name="asset">
<xs:sequence>
<xs:element name="ID" type="xs:long" minOccurs="0"/>
</xs:sequence>
</xs:complexType>

<xs:complexType name="movie">
<xs:complexContent>
<xs:extension base="asset">
<xs:sequence/>
</xs:extension>
</xs:complexContent>
</xs:complexType>

the schema that i would like to see is :

<xs:complexType name="movie">
<xs:complexContent>
<xs:sequence/>
</xs:extension>
</xs:complexContent>
</xs:complexType>
like image 900
shay Avatar asked Nov 15 '22 12:11

shay


1 Answers

You have found the answer yourself. If you add the @XMLTransient annotation to a field, it will be omitted by JAXB Java-to-schema generation. This is stated here XMLTransient documentation.

If your schemagen tool you are using doesn't do this, than it has a fault in its implementation.

like image 70
Leni Kirilov Avatar answered Dec 24 '22 04:12

Leni Kirilov