java - Spring boot with JPA and ManyToMany: JsonIdentifyInfo not working properly -
i've 2 classes causing problem: teacher , schoolclass (class java keyword already). both have long id.
a teacher can have many classes , class can have many teachers.
if request teacher (only importent vars):
{   "classes": [     {      "teachers": [        {         "classes": [           1         ],        }      ],     }   ] } but if request class (complete):
{   "timestamp": 1445530016078,   "status": 500,   "error": "internal server error",   "exception": "org.springframework.http.converter.httpmessagenotwritableexception",   "message": "could not write content: java.lang.integer cannot cast java.lang.long (through reference chain:      at.scool.model.db.schoolclass[\"teachers\"]->java.util.hashset[0]->at.scool.model.db.teacher[\"classes\"]->java.util.hashset[0]);      nested exception com.fasterxml.jackson.databind.jsonmappingexception:      java.lang.integer cannot cast java.lang.long (through reference chain:      at.scool.model.db.schoolclass[\"teachers\"]->java.util.hashset[0]->at.scool.model.db.teacher[\"classes\"]->java.util.hashset[0])",   "path": "/api/class/1" } teacher
@manytomany @jsonidentityinfo(generator = objectidgenerators.propertygenerator.class, property = "id") private set<schoolclass> classes = new hashset<>(); schoolclass
@manytomany @jsonidentityinfo(generator = objectidgenerators.propertygenerator.class, property = "id") private set<teacher> teachers = new hashset<>(); how fix error?
update
i noticed now, property value 'id' not taken in schoolclass. (start of output jsonignore on teachers set)
{ "@id": 1, "id": 1,  
 
  
Comments
Post a Comment