PropertyInfo. Java
@Entity
@NoArgsConstructor
@Builder
@AllArgsConstructor
@Table(name = "property_info")
@lombok.Data
@TypeDefs({
@TypeDef(name = "json", typeClass = JsonStringType.class),
@TypeDef(name = "jsonb", typeClass = JsonBinaryType.class),
@TypeDef(name = "jsonb-node", typeClass = JsonNodeBinaryType.class),
@TypeDef(name = "json-node", typeClass = JsonNodeStringType.class),
@TypeDef(name = "string-array", typeClass = StringArrayType.class),
@TypeDef(name = "int-array", typeClass = IntArrayType.class)
})
public class PropertyInfo implements Serializable{
@Column(name = "property_id")
private Long propertyId;
@Type(type = "jsonb")
@Column(name = "staff", columnDefinition = "jsonb")
private Map<String, StaffDto> staff;
}
PropertyInfoRepository. Java
@Query(value = "SELECT p.staff->'Center Head' as staff FROM property_info p", nativeQuery = true)
List<PropertyStaffInterface> getUserMapping();
PropertyStaffInterface
interface PropertyStaffInterface {
StaffDto getStaff();
}
Данные
персонал
{'Center Head':{"name": "prateek Singh", "role": "Center Head", "user_id": "42727979", "hub_name": "Kochi"}}
персонал -> «начальник центра»
{"name": "prateek Singh", "role": "Center Head", "user_id": "42727979", "hub_name": "Kochi"}
StaffDto. Java
@lombok.Data
@Builder
@AllArgsConstructor
@NoArgsConstructor
public class StaffDto implements Serializable {
@JsonProperty("role")
public String role;
@JsonProperty("user_id")
public String userId;
@JsonProperty("name")
public String name;
@JsonProperty("hub_name")
public String hubName;
}
Сведения об ошибке:
org.springframework.orm.jpa.JpaSystemException: No Dialect mapping for JDBC type: 1111; nested exception is org.hibernate.MappingException: No Dialect mapping for JDBC type: 1111
У меня вопрос, как извлечь json объект из Postgres, используя JPA при весенней загрузке?