Is it possible to add annotations to the generated classes by adding
annotation elements to an xsd file. For example, I would like to add an
@Entity attribute to each generated class as well as an @Id attribute (plus
maybe an @GeneratedValue) to selected fields.
So, If I have an xsd file that looks something like:
<xsd:element name="Address" type="tns:AddressType"/>
<xsd:complexType name="AddressType">
<xsd:sequence>
<xsd:element name="Id" type="xsd:long"/>
<xsd:element name="Street" type="xsd:string"/>
<xsd:element name="City" type="xsd:string"/>
<xsd:element name="Zip" type="xsd:string"/>
</xsd:sequence>
</xsd:complexType>
I would like to have a class like:
@XmlAccessorType(XmlAccessType.FIELD)
@XmlType(name = "AddressType", propOrder = {
"street",
"city",
"zip"
})
@Entity()
public class AddressType implements Serializable{
@XmlElement(name = "SId", namespace = "
http://xml.netbeans.org/schema/Types", required = true)
@Id @GeneratedValue long id;
@XmlElement(name = "Street", namespace = "
http://xml.netbeans.org/schema/Types", required = true)
protected String street;
...
}
thanks!
-Lucas
P.S. Currently I am hand editing each class by adding the annotations, this
works, but makes development a pain, since I have to remember which classes
are annotated how when ever I rebuild the classes.
P.P.S Obviously I am trying use the generated class with the Java
Persistence API, If anyone has a good solution to this, I would love to hear
about it!!