0

When I naively use Jackson to convert to JSON i receive this exception:

Caused by: com.fasterxml.jackson.databind.exc.InvalidDefinitionException: No serializer found for class org.apache.cayenne.access.DefaultDataRowStoreFactory and no properties discovered to create BeanSerializer

Edit: I'd like to do something like this:

ObjectContext context = cayenneRuntime.newContext();

List<User> users = ObjectSelect.query(User.class).select(context);
JsonObject json = Json.mapper.convertValue(obj, Map.class)

Are there any existing solutions? Thanks

Gero
  • 1
  • 1

1 Answers1

0

Considering that in a general case Cayenne gives you not just objects, but a virtual graph of objects, serialization to JSON becomes a more quirky topic than it initially appears.

The short answer: you'd have manually build JSON for whatever subgraph of your object graph.

While not a direct answer, it may be worth mentioning that Agrest framework (ex. LinkRest) supports rule-based serialization of Cayenne object graphs to JSON. But it is not a standalone component. I.e. it will only work if you use it for your REST services.

andrus_a
  • 2,528
  • 1
  • 16
  • 10