带有@Embeddable和@XmlPath(“。”)的属性在JPA-RS元数据中无法正确显示

时间:2014-01-07 12:32:57

标签: jpa eclipselink moxy jpa-rs

鉴于JPA-RS示例here,我将地址的新属性添加到Student类:

@Embedded
@XmlPath(".")
private Address address;

Address类:

@XmlRootElement
@XmlAccessorType(XmlAccessType.FIELD)
@Embeddable
public class Address implements Serializable {
    private static final long serialVersionUID = 1L;

    private String streetName;
    private int streetNumber;
    private int zipCode;
    private String city;

    // constructor, getters, etc.
}

访问元数据网址http://host:port/context-root/persistence/persistence-unit/metadata/entity/Student时,它会描述模型而不嵌入新添加的属性的属性:

{
  "name": "Student",
  "attributes": [
    {
      "name": "id",
      "type": "Long"
    },
    {
      "name": "name",
      "type": "String"
    },
    {
      "name": "address",
      "type": "Address"
    },
    {
      "name": "courses",
      "type": "List<Course>"
    }
  ],

但它在发送这样的对象时确实有效,并且它使用GET返回此表单中的对象:

{
  "name": "John",
  "streetName": "Rue Doe",
  "streetNumber": 123,
  "zipCode": 45678,
  "city": "Samplesten"
}

我的问题:这是预期的行为吗?假设我想使用元数据api为用户提供有关他们必须使用的一般模型的知识。目前的设计极具误导性。同样适用于重命名属性。

1 个答案:

答案 0 :(得分:1)

这是JPA-RS中的错误。我已针对此问题打开了以下错误: