내가 변경할 수없는 별도의 프로젝트에 콩 세트가 있습니다. 이 bean은 JPA와 JAXB 어노테이션을 모두 가지고 있으며 RESTful 구현에 사용되고있다. 내 관계의 대부분은 게으르며, 어떤 요소가 실제로 전송을 위해 정렬되었는지에 대한 좀 더 세분화 된 제어를 달성하기를 희망했다.MOXy의 xml-transient 선언은 어떻게 작동합니까?
아래와 같이 수정 된 MOXy Customer.java 클래스가 있습니다.
@javax.xml.bind.annotation.XmlType
@javax.xml.bind.annotation.XmlAccessorType(value=javax.xml.bind.annotation.XmlAccessType.PROPERTY)
public class Customer {
private String name;
private Address address;
private List<PhoneNumber> phoneNumbers;
// getters and setters
}
내가 정렬 화 작업을 제어하기 위해 목시는 EclipseLink-OXM 매핑을 사용할 수 싶지만, 내가 예상대로이 작동하지 않는. JAXB 어노테이션을 사용하면 요소 (필드 또는 특성)를 일시적으로 선언하지만 eclipselink-oxm.xml은 유형에 대한 일시적인 선언 만 허용합니다.
<?xml version="1.0"?>
<xml-bindings
xmlns="http://www.eclipse.org/eclipselink/xsds/persistence/oxm">
<java-types>
<java-type name="example.gettingstarted.Customer">
<xml-root-element/>
<java-attributes>
<xml-element java-attribute="name" xml-path="personal-info/name/text()"/>
<xml-element java-attribute="address" xml-path="contact-info/address"/>
</java-attributes>
</java-type>
<java-type name="example.gettingstarted.PhoneNumber" xml-transient="true" />
</java-types>
</xml-bindings>
예외 :
Exception [EclipseLink-110] (Eclipse Persistence Services - 2.1.0.v20100614-r7608): org.eclipse.persistence.exceptions.DescriptorException
Exception Description: Descriptor is missing for class [example.gettingstarted.PhoneNumber].
Mapping: org.eclipse.persistence.oxm.mappings.XMLCompositeCollectionMapping[phoneNumbers]
Descriptor: XMLDescriptor(example.gettingstarted.Customer --> [DatabaseTable(customer)])
나는 XML 과도 특성을 제거, 또는 false로 설정하면, 고객 나는 같은 유형의 과도를 선언 할 때, 나는 다음과 같은 예외를 얻을 예상대로 XML로 변환됩니다. 고객 빈을 수정하지 않고 전화 번호의 정렬을 억제 할 수있는 방법이 있습니까?
Perfect. 이것은 효과가 있었다. 나는 .xsd를 더 조심스럽게 읽어야했다. – Fil