Question

Given the JPA-RS example here, i added a new property for the address to the Student class:

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

The Address class:

@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.
}

When accessing the metadata URL http://host:port/context-root/persistence/persistence-unit/metadata/entity/Student, it describes the model without embedding the attributes of the newly added property:

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

But it does work as intended when sending an object like this, also it returns the object in this form using GET:

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

My question: Is this an intended behaviour? Let's say i want to use the metadata api to give users knowledge about the general model they have to use. The currect design is extremly misleading. Same applies for renaming an attribute.

Was it helpful?

Solution

This is a bug in JPA-RS. I have opened the following bug for this issue:

Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top