In the process of learning java programming, I write for myself a small RESTful service that caused the problem.
To develop a RESTful service I use Spring Boot and Hibernate. The essence of the problem: after introducing a one-to-many relationship between database entities, I cannot transfer objects read from the database to the client. When writing to the database there are no problems.
Here is the graphical database schema: 
When executing the object transfer method, an error occurs.
2016-06-15 20:24:36.631 WARN 1372 --- [nio-8080-exec-1] .wsmsDefaultHandler ExceptionResolver : Failed to write HTTP message: org.springframework.http.converter.HttpMessageNotWritableException: Could not write content: could not extract ResultSet (through reference chain: prodinfo.models.Avtor["lkat"]); nested exception is com.fasterxml.jackson.databind.JsonMappingException: could not extract ResultSet (through reference chain: prodinfo.models.Avtor["lkat"]) The method of request and transfer of the object itself:
@RequestMapping(value="/getlist") @ResponseBody public Avtor avtorout(String urladdress) { List<Avtor> avtorlist = avtorDao.getByUrladdress(urladdress); Avtor avtor = avtorlist.get(0); return avtor; } The getByUrladdress () method from avtorDao:
public List<Avtor> getByUrladdress(String urladdress) { return entityManager.createQuery( "from Avtor where urladdress = :urladdress") .setParameter("urladdress", urladdress) .getResultList(); } Avtor Entity Model:
@Entity @Table(name="Avtor" ,schema="public" ) public class Avtor implements Serializable { @Id @GeneratedValue(strategy = GenerationType.AUTO) private long id; @NotNull @Type(type = "text") private String urladdress; @Type(type = "text") private String avtorname; private String update_avtor; @OneToMany(cascade = CascadeType.ALL, mappedBy = "title_lkat") private Set<Lkat> lkat = new HashSet<>(); public Set<Lkat> getLkat() { return this.lkat; } public void setLkat(Set<Lkat> lkat) { this.lkat = lkat; } public void addLkat(Lkat lkat) { lkat.setAvtor(this); this.lkat.add(lkat); } public Avtor() { } public Avtor(long id) { this.id = id; } public Avtor(String urladdress) { this.urladdress = urladdress; } public Avtor(String avtorname, String update_avtor) { this.avtorname = avtorname; this.update_avtor = update_avtor; } public Avtor(long id, String avtorname, String update_avtor) { this.id = id; this.avtorname = avtorname; this.update_avtor = update_avtor; } public Avtor(String urladdress, String avtorname, String update_avtor) { this.urladdress = urladdress; this.avtorname = avtorname; this.update_avtor = update_avtor; } public Avtor(long id, String urladdress, String avtorname, String update_avtor) { this.id = id; this.urladdress = urladdress; this.avtorname = avtorname; this.update_avtor = update_avtor; } public long getId() { return id; } public void setId(long id) { this.id = id; } public String getUrladdress() { return urladdress; } public void setUrladdress(String urladdress) { this.urladdress = urladdress; } public String getAvtorname() { return avtorname; } public void setAvtorname(String avtorname) { this.avtorname = avtorname; } public String getUpdate_avtor() { return update_avtor; } public void setUpdate_avtor(String update_avtor) { this.update_avtor = update_avtor; } } Because without a one-to-many connection, objects are transferred without problems, the question arises how to transfer objects from a database with entity connections correctly?
@JsonManagedReferenceand@JsonBackReference. But usually no one gives the Entity out, using the DTO instead. - enzo@JsonManagedReferenceand@JsonBackReferencedid not solve the problem. - Nirax