TL;DR; DTO vs full entity
we are exposing our entities with JAX RS and JSON Binding (Java context). Works fine. Now if an entity will be added, updated or deleted, we want to update Algolia.
It works fine so far, but I want to now a good/bad practice adivse.
Example: Entity Food
@NotNull public String name; @Embedded @Valid public Nutritions nutritions = new Nutritions(); private String description; @OneToOne @NotNull @JsonbTypeAdapter(FoodCategoryAdapter.class) @JsonbProperty("foodCategoryId") public FoodCategory foodCategory;
All json annotations are for our own API. and obviously are not working for algolia.
Should I use my complete entity (which is already optimized for our own API) as input for algolia or should I create a DTO? Or should I only use annotations to achieve the correct behaviour?