I have json file with json object as value of property inside:
{
"name": "name",
"json": {...}
}
I need to get it automatically in RestController and use it as entity in JPA+Hibernate.
My entity is:
UPDATE -> more specified entity
@Entity
@Table(name = "collections")
public class Collection {
@Id
private String name;
@Column(name = "cache_limit")
private int limit;
@Column(name = "cache_algorithm")
private String algorithm;
@Transient
private JsonNode schema;
@JsonIgnore
@Column(name ="json_schema")
private String jsonSchema;
public Collection() {
}
public String getJsonSchema() {
return schema.toString();
}
public void setJsonSchema(String jsonSchema) {
ObjectMapper mapper = new ObjectMapper();
try {
schema = mapper.readTree(jsonSchema);
} catch (IOException e) {
throw new RuntimeException("Parsing error -> String to JsonNode");
}
}
..setters and getters for name limit algorithm schema..
}
When I use entityManager.persist(Collection) I have json_schema column as NULL
How can I solve It? The problem is in setJsonSchema() perhaps
update:
public String getJsonSchema() {
return jsonSchema;
}
public void setJsonSchema(JsonNode schema) {
this.jsonSchema = schema.toString();
}
Such getters/setters don't solve the problem
Cat getCat(int name){ return cats.getCatByName(name);}and it returnsJSONobject withnameandjsonproperty is empty?