Я пишу запрос критерия, чтобы получить результаты для jsonb в postgres. Я могу запросить столбец jsonb через hibernate. Я не могу получить определенные ключи jsonb. Я не могу найти способ.
Я пробовал собственный запрос, но мне нужен некоторый выход в запросе критериев гибернации. Аргумент commonjson - это jsonb в postgresql, это -
{"appl_id": 726516, "applied_by": "pankajkumarnnl94@gmail.com", "service_id": 9880004, "version_no": 4, "appl_ref_no": "BSEH/2018/00728", "sub_version": 1, "payment_date": "2018-12-04T11:54:20.24+05:30", "payment_mode": "PayUbizz", "reference_no": "7726929249", "service_name": "Migration Certificate Board of School Education Haryana, Bhiwani", "department_id": 784, "location_value": 1218758, "base_service_id": 988, "department_name": " Board of School Education Haryana", "registration_id": "", "submission_date": "2018-12-04", "submission_mode": "online", "no_of_attachment": 2, "submission_location": "1578947~1218758~Board of School Education Haryana"}
Класс модели -> ApplInfoJson
package com.saral.reporting.model;
import java.util.Map;
import javax.persistence.Column;
import javax.persistence.Entity;
import javax.persistence.GeneratedValue;
import javax.persistence.GenerationType;
import javax.persistence.Id;
import javax.persistence.Table;
import org.hibernate.annotations.Type;
import com.fasterxml.jackson.annotation.JsonProperty;
@Entity
@Table(name = "r_app_json",schema="saral1", catalog="saral1")
public class ApplInfoJson {
@Id
@Column(name = "aid")
@GeneratedValue(strategy = GenerationType.IDENTITY)
private Long aid;
@Column(name = "id")
private Long id;
@JsonProperty("appl_info")
@Column(name = "appl_info")
private String applInfo;
@Column(name = "application_form_attributes")
private String applicationFormAttributes;
@Column(name = "enclosure_data")
private String enclosureData;
@Column(name = "service_id")
private Long serviceId;
@Column(name = "combined_json")
@Type(type = "JsonDataUserType")
private Map<String , Object> combinedJson;
@Column(name ="location_value")
private Long locationValue;
public Long getLocationValue() {
return locationValue;
}
public void setLocationValue(Long locationValue) {
this.locationValue = locationValue;
}
public Long getServiceId() {
return serviceId;
}
public void setServiceId(Long serviceId) {
this.serviceId = serviceId;
}
public Long getAid() {
return aid;
}
public void setAid(Long aid) {
this.aid = aid;
}
public Long getId() {
return id;
}
public void setId(Long id) {
this.id = id;
}
public String getApplInfo() {
return applInfo;
}
public void setApplInfo(String applInfo) {
this.applInfo = applInfo;
}
public String getApplicationFormAttributes() {
return applicationFormAttributes;
}
public void setApplicationFormAttributes(String applicationFormAttributes) {
this.applicationFormAttributes = applicationFormAttributes;
}
public String getEnclosureData() {
return enclosureData;
}
public void setEnclosureData(String enclosureData) {
this.enclosureData = enclosureData;
}
public Map<String, Object> getCombinedJson() {
return combinedJson;
}
public void setCombinedJson(Map<String, Object> combinedJson) {
this.combinedJson = combinedJson;
}
@Override
public String toString() {
return "ApplInfoJson [aid=" + aid + ", id=" + id + ", applInfo=" + applInfo + ", applicationFormAttributes="
+ applicationFormAttributes + ", enclosureData=" + enclosureData + ", serviceId=" + serviceId
+ ", combinedJson=" + combinedJson + ", locationValue=" + locationValue + "]";
}
}
Используемая функция ->
public List<ApplInfoJson> findByCombinedJson(String commonJson) {
DetachedCriteria criteria = DetachedCriteria.forClass(ApplInfoJson.class);
List<ApplInfoJson> results = (List<ApplInfoJson>) getHibernateTemplate().findByCriteria(criteria);
return results;
}
Я хочу, чтобы что-то передавало имя ключа и получало данные с определенным ключом.