Мне приходит json тело, в котором есть один объект, внутри которого есть массив объектов.
мне удается это все сохранить в базу данных, но не знаю как извлечь данные обратно первозданном виде, так как данные хранятся в разных таблицах.
Вопрос: Как первозданном виде?
json тело, который приходит:
{ "ACTIVITY": {
"CODE": "sale",
"NAME": "Продажи",
"NOTE": ""
},
"ADDRESS": [
{
"NAME": "Покровка",
"DEPART": {
"CODE": "001-007",
"NAME": "Управление методологии"
}
},
{
"NAME": "хочу в париж",
"DEPART": {
"CODE": "001-005",
"NAME": "test test технологий"
}
},
{
"NAME": "это я тестирую",
"DEPART": {
"CODE": "002-002",
"NAME": "Отдел продаж"
}
}
],
"AGREEMENT_DATE": "2022-01-17 00:00:00",
"AGREEMENT_TYPE": "test партнера",
"BIC": "10301",
"BRAND": "ЯЯЯЯЯ",
"COMMENTS": "",
"COMMISSIONER": "test test",
"CURATOR": {
"NAME": "Пов в в"
},
"FIN_ACCOUNTS": {
"ACCOUNT": "test"
},
"PARTNER": {
"NAME": "dd test dd",
"INN": "test"
},
"RATE_TYPE": {
"CODE": "test",
"NAME": "test",
"NOTE": "test"
},
"RETENTION_SCHEM": "Со счета test",
"TARIF": {
"CODE": "test",
"NAME": "test",
"NOTE": "",
"RATE": {
"STAVKA": "15",
"SROK": "24"
}
},
"WORKER": "test test test"
}
pojo:
@Data
@Entity
@Builder
@NoArgsConstructor
@AllArgsConstructor
@Table(name = "information", schema = "public")
public class Information {
@Id
@GeneratedValue(generator = "UUID")
@GenericGenerator(
name="UUID",
strategy = "org.hibernate.id.UUIDGenerator"
)
@JsonIgnore
private UUID id;
@JsonAlias(value = "AGREEMENT_DATE")
private String agreementDate;
@JsonAlias(value = "AGREEMENT_TYPE")
private String agreementType;
@JsonAlias(value = "BIC")
private String bic;
@JsonAlias(value = "BRAND")
private String brand;
@JsonAlias(value = "COMMENTS")
private String comments;
@JsonAlias(value = "COMMISSIONER")
private String commissioner;
@JsonAlias(value = "RETENTION_SCHEM")
private String retentionSchem;
@JsonAlias(value = "WORKER")
private String worker;
@JsonAlias(value = "ACTIVITY")
@OneToOne(mappedBy = "information", cascade = {CascadeType.ALL})
private Activity activity;
@OneToOne(mappedBy = "information", cascade = {CascadeType.ALL})
private UserDto userDto;
@OneToMany(mappedBy = "information", cascade = {CascadeType.ALL})
private List<Address> address;
@OneToOne(mappedBy = "information", cascade = {CascadeType.ALL})
@JsonAlias(value = "CURATOR")
private Curator curator;
@JsonAlias(value = "FIN_ACCOUNTS")
@OneToOne(mappedBy = "information", cascade = {CascadeType.ALL})
private FinAccounts finAccounts;
@OneToOne(mappedBy = "information", cascade = {CascadeType.ALL})
@JsonAlias(value = "PARTNER")
private Partner partner;
@OneToOne(mappedBy = "information", cascade = {CascadeType.ALL})
@JsonAlias(value = "RATE_TYPE")
private RateType rateType;
@OneToOne(mappedBy = "information", cascade = {CascadeType.ALL})
@JsonAlias(value = "TARIF")
private Tarif tarif;
}
database screen: