Answer the question
In order to leave comments, you need to log in
How to extract data from multiple tables?
I get a json body in which there is one object, inside which there is an array of objects.
I manage to save all this to the database, but I don’t know how to retrieve the data back in its original form, since the data is stored in different tables.
Question: How original?
json body that comes:
{ "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"
}
@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;
}
Answer the question
In order to leave comments, you need to log in
Didn't find what you were looking for?
Ask your questionAsk a Question
731 491 924 answers to any question