コード例 #1
0
  public void addPhoneNumberDescriptor(boolean methodAccess) {
    XMLDescriptor descriptor = new XMLDescriptor();
    descriptor.setJavaClass(PhoneNumber.class);

    XMLDirectMapping numberMapping = new XMLDirectMapping();
    numberMapping.setAttributeName("number");
    numberMapping.setXPath("text()");
    descriptor.addMapping(numberMapping);

    XMLInverseReferenceMapping owningEmployee = new XMLInverseReferenceMapping();
    owningEmployee.setReferenceClass(Employee.class);
    owningEmployee.setMappedBy("phoneNumbers");
    owningEmployee.setAttributeName("owningEmployee");
    if (methodAccess) {
      owningEmployee.setSetMethodName("setOwningEmployee");
      owningEmployee.setGetMethodName("getOwningEmployee");
    }
    descriptor.addMapping(owningEmployee);

    this.addDescriptor(descriptor);
  }
コード例 #2
0
  public void addAddressDescriptor(boolean methodAccess) {
    XMLDescriptor descriptor = new XMLDescriptor();
    descriptor.setJavaClass(Address.class);

    XMLDirectMapping streetMapping = new XMLDirectMapping();
    streetMapping.setAttributeName("street");
    streetMapping.setXPath("street/text()");
    descriptor.addMapping(streetMapping);

    XMLDirectMapping cityMapping = new XMLDirectMapping();
    cityMapping.setAttributeName("city");
    cityMapping.setXPath("city/text()");
    descriptor.addMapping(cityMapping);

    XMLDirectMapping stateMapping = new XMLDirectMapping();
    stateMapping.setAttributeName("state");
    stateMapping.setXPath("state/text()");
    descriptor.addMapping(stateMapping);

    XMLDirectMapping countryMapping = new XMLDirectMapping();
    countryMapping.setAttributeName("country");
    countryMapping.setXPath("country/text()");
    descriptor.addMapping(countryMapping);

    XMLInverseReferenceMapping owningEmployee = new XMLInverseReferenceMapping();
    owningEmployee.setReferenceClass(Employee.class);
    owningEmployee.setMappedBy("address");
    owningEmployee.setAttributeName("owningEmployee");
    if (methodAccess) {
      owningEmployee.setSetMethodName("setOwningEmployee");
      owningEmployee.setGetMethodName("getOwningEmployee");
    }
    descriptor.addMapping(owningEmployee);

    this.addDescriptor(descriptor);
  }