Migrating to Spring Boot 2.2.0, all the properties with the @JsonIgnore
annotation are now serialized in the API Rest Body (while in Boot 2.1.9 worked fine).
Furthermore, an "_embedded"
attribute is added before each nested object.
It seems a Jackson issue.
Details of the code:
@Entity
@Audited
@Data
@EqualsAndHashCode(callSuper = true, of = { "makeId", "modelId", "versionId", "bodyTypeId", "modelYear" })
@ToString(callSuper = true, of = { "makeName", "modelName", "versionName", "bodyTypeId", "modelYear" })
@NoArgsConstructor
@RequiredArgsConstructor
@Table(schema = "fleet", name = "vehicles", uniqueConstraints = { @UniqueConstraint(columnNames = { "id", "make_id", "model_id", "version_id", "body_type_id", "model_year", "port_number" }) })
public class Vehicle extends BaseEntity implements VehicleBaseMakeInfo {
@OneToMany(mappedBy = "vehicleRef", cascade = CascadeType.DETACH, orphanRemoval = false, fetch = FetchType.LAZY)
@JsonIgnore
private Set<Car> cars = new HashSet<>();
@Length(max = 250)
@Column(name = "make_id", length = 250)
private String makeId; // UK_1
@Length(max = 250)
@Column(name = "make_name", length = 250)
@NonNull
@NotBlank
private String makeName;
@Length(max = 250)
@Column(name = "model_id", length = 250)
private String modelId;
...
Once I execute the GET request "http://localhost:8081/api/vehicles"
I receive
{
"id": 105,
"state": "ACTIVE",
"enabled": true,
"avatarDocumentId": null,
"makeId": "Bmw",
"makeName": "Bmw",
"modelId": "X4",
"modelName": "X4",
"modelNameOriginal": null,
"versionId": "Executive",
"versionName": "Executive",
"bodyTypeId": "Wagon",
"engineCapacity": 2.0,
"fuelingId": "Unleaded",
"power": 184.0,
"co2": 2,
"detailedTransmissionId": "Manual",
"tractionName": "4x4",
"portNumber": 3,
"urbanCycle": 4.3,
"extraUrbanCycle": 3.8,
"mixedCycle": 4.0,
"price": 27000.0,
"annualFringeBenefit": null,
"fringeCustomValue": false,
"modelYear": 2016,
"sourceType": "CUSTOM",
"inProduction": true,
"fringeAlgMatchingState": null,
"fringeMatchingCorrection": null,
"requiredReviewType": null,
"fringeSimilarVehicleId": null,
"useType": "PASSENGER_TRANSPORT",
"correctToCreateAsNew": false,
"productionStartDate": null,
"productionEndDate": null,
"calculatedMonthFringeBenefit": null,
"fullVersionExtended": "Bmw X4 Executive Wagon 3p 4x4 Unleaded 2016",
"calculatedAnnualFringeBenefit": null,
"objectId": "105",
"_embedded": {
"cars": [
{
"id": 258,
"state": "INSTALLED",
"enabled": true,
"avatarDocumentId": null,
"contractVersions": [
{
"id": 308,
"state": "ACTIVE",
As you can notice, the "_embedded"and "cars" should not be present. Before upgrading to Boot 2.2.0 It worked fine
Thanks
Antonio