Properties with @Embeddable and @XmlPath(".") are not displayed correctly in JPA-RS metadata

StackOverflow https://stackoverflow.com/questions/20971733

  •  25-09-2022
  •  | 
  •  

Pergunta

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.

Foi útil?

Solução

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

Licenciado em: CC-BY-SA com atribuição
Não afiliado a StackOverflow
scroll top