Quantcast

@XmlTransient with hasMany relationships (Many-To-Many)

classic Classic list List threaded Threaded
1 message Options
Reply | Threaded
Open this post in threaded view
|  
Report Content as Inappropriate
star

@XmlTransient with hasMany relationships (Many-To-Many)

Martin S.
Hey all,
    I am fairly new to Grail and CXF and I have a questions regarding the @XmlTransient annotation with Many-to-Many relationship. I have the following 2 domain classes where a Technician can have multiple Service Type and a Service Type can be applied to multiple Technician ... pretty straight forward.

class Technician {

    static hasMany = [serviceTypes:ServiceType]
   
    // Automatic Timestamping
    Date dateCreated, lastUpdated
       
    String firstName
    String lastName
    boolean active = true
               
    static constraints = {
        firstName(blank:false, maxSize:100)
        lastName(blank:false, maxSize:100)
    }
}

class ServiceType {
   
    static hasMany = [technicians:Technician]
    static belongsTo = Technician
   
    String code
    String description
    boolean active = true
   
    static constraints = {
        code(blank:false, maxSize:50)
        description(blank:false, maxSize:100)       
    }
}

When I use the Grails CXF plugin to generate the web service automatically I get the following XML response (see below). How can I apply the @XmlTransient on Service Types so that they are not return as part of the XML ? Also why is it returning the Service Type 'active' (boolean) property in the XML like this ?

<soap:Envelope xmlns:soap="http://schemas.xmlsoap.org/soap/envelope/">
   <soap:Body>
      <ns1:retrieveTechnicianResponse xmlns:ns1="http://api.vrmtechnologies.com/">
         <return>
            <dateCreated>2010-09-08T10:23:37-04:00</dateCreated>
            <lastUpdated>2010-09-08T13:00:44-04:00</lastUpdated>
            <firstName>Martin</firstName>
            <lastName>Test</lastName>
            <active>true</active>
            <id>2</id>
            <version>1</version>
            <serviceTypes xsi:type="ns3:serviceType" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns:ns3="http://api.vrmtechnologies.com/">
               <active>true</active>
            </serviceTypes>
            <serviceTypes xsi:type="ns3:serviceType" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns:ns3="http://api.vrmtechnologies.com/">
               <active>true</active>
            </serviceTypes>
         </return>
      </ns1:retrieveTechnicianResponse>
   </soap:Body>
</soap:Envelope>

Regards,

Martin


Loading...