users@jaxb.java.net

Re: Is there a way to mark up my xsd files so that xjc will generate java classes with hibernate annotations?

From: Kiran Narasareddy <kiran.narasareddy_at_gmail.com>
Date: Sat, 22 Jan 2011 06:20:44 +0530

Just replied to your previous mail. Please check. Hope it helps.

Regards
Kiran Narasareddy

Sent from my HTC
On 22-Jan-2011 6:11 AM, "Andy Davidson" <andy_davidson_at_apple.com> wrote:
> Hi
>
> Is there a way to mark up my xsd files so that xjc will generate java
classes with hibernate annotations? Worst comes to worst, the hybernate
mapping can be specified in an xml file. The advantage of adding <appinfo>
to the xsd files is that xsd file changes will trigger java compiler errors.
This is should be faster and easier to track down.
>
> for example
>
> <annotation>
> <appinfo>
> <jaxb:decorate>@Entity</jaxb:decorate>
> <jaxb:decorate>@Table(name = "employee")</jaxb:decorate>
> </appinfo>
> </annotation>
> <complexType name="Employee">
> <sequence>
> < annotation >
> <appinfo>
> <jaxb:decorate>@Id</jaxb:decorate>
> <jaxb:decorate>@Entity</jaxb:decorate>
> <appinfo>
> </annotation>
> <element name="id" type="integer"/>
>
> <annotation>
> <appinfo>
> <jaxb:decorate>@Column(name = "name")</jaxb:decorate>
> <appinfo>
> </annotation>
> <element name="name" type="string" />
>
>
> <sequence>
> </complexType>
>
>
>
> inaddition to the jaxb annontation, xjc would add the extra hybernate
annontations
>
> @Entity
> @Table(name = "employee")
> @XmlAccessorType(XmlAccessType.FIELD)
> @XmlType(name = "Employee", propOrder = {
> "id",
> "name"
> })
> public class Employee implements Serializable {
> public Employee() {
>
> }
> @Id
> @Column(name = "id")
> Integer id;
>
> @Column(name = "name")
> String name;
>
> public Integer getId() {
> return id;
> }
>
> public void setId(Integer id) {
> this.id = id;
> }
>
> public String getName() {
> return name;
> }
>
> public void setName(String name) {
> this.name = name;
> }
>
> }
>
> thanks
>
> Andy