При переходе на Spring Boot 2.2.0 все свойства с аннотацией @JsonIgnore
теперь сериализуются в API Rest Body (в то время как в Boot 2.1.9 работало нормально). Кроме того, атрибут "_embedded"
добавляется перед каждым вложенным объектом.
Кажется, проблема Джексона.
Детали кода:
@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;
...
Как только я выполнюПОЛУЧИТЬ запрос "http://localhost:8081/api/vehicles"
Я получаю
{
"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",
Как вы можете заметить," _embedded "и" cars "не должны присутствовать. До обновления до Boot 2.2.0 все работалоотлично
Спасибо
Антонио