0

I switched from WildFly to OpenLiberty and in OpenLiberty Eclipselink is the default JPA provider. I am using the default JSON-B to convert the entity to a JSON object:

@Path("test")
public class TestResource {
    @GET
    public Response response() {
        JsonbConfig jsonbConfig = new JsonbConfig();
        jsonbConfig.withPropertyVisibilityStrategy(new PrivateVisibilityStrategy()); // allow private fields to being displayed
        jsonbConfig.withNullValues(true);
        return Response.ok(JsonbBuilder.create(jsonbConfig).toJson(new TestEntity())).build();
    }
}



@Entity
public class TestEntity {

    @Id
    @GeneratedValue
    private Long id;
}

And the response:

{
 "_persistence_fetchGroup": null,
 "id": 1
}

I can however not allow null values to be displayed at all, but that is not what I want, because I have other values which can be null and must be displayed.

How can I remove this property _persistence_fetchGroup from being processed by the JSON builder in Java EE 8?

alexander
  • 1,191
  • 2
  • 20
  • 40
  • are you sure this this related in any way to Wildfly/OpenLiberty? – Repoker Sep 30 '19 at 10:20
  • have you tried using jsonbConfig.withNullValues(false) with @JsonbProperty(nillable=true) annotations in nullable fields? that might work for you – Repoker Sep 30 '19 at 10:33
  • @Repoker It is not related to the ApplicationServer, but to the persistence provider (The change of the server just explained why my persistence provider changed). Indeed, that works well, but will blow up my entities. Thanks anyway! :) – alexander Oct 01 '19 at 07:32

0 Answers0