我有public class MainClass {
public MainClass() {
OtherClass o = new OtherClass(this); //I am looking for "this" keyword to send the instance
}
public void someMethod() {
}
}
public class OtherClass {
public OtherClass(MainClass m) { //and this receiver method
m.someMethod();
}
}
@ManyToMany
。
如果我发回物品,我会得到:
@JsonIdentityInfo(generator = ObjectIdGenerators.IntSequenceGenerator.class)
Spring boot with JPA and ManyToMany: JsonIdentifyInfo not working properly
教师
error: "Bad Request"
exception: "org.springframework.http.converter.HttpMessageNotReadableException"
message: "Could not read document: No _valueDeserializer assigned↵ at [Source: java.io.PushbackInputStream@3021b8dc; line: 1, column: 244] (through reference chain: at.scool.model.db.Teacher["classes"]->java.util.HashSet[0]->at.scool.model.db.SchoolClass["teachers"]->java.util.HashSet[0]->at.scool.model.db.Teacher["id"]); nested exception is com.fasterxml.jackson.databind.JsonMappingException: No _valueDeserializer assigned↵ at [Source: java.io.PushbackInputStream@3021b8dc; line: 1, column: 244] (through reference chain: at.scool.model.db.Teacher["classes"]->java.util.HashSet[0]->at.scool.model.db.SchoolClass["teachers"]->java.util.HashSet[0]->at.scool.model.db.Teacher["id"])"
path: "/api/teacher/1"
status: 400
timestamp: 1446921619542
SchoolClass
@ManyToMany
@JsonIdentityInfo(generator = ObjectIdGenerators.PropertyGenerator.class, property = "id")
private Set<SchoolClass> classes = new HashSet<>();
答案 0 :(得分:3)
@ zt1983811
是的 - 我找到了一个我忘了在这里发布的解决方案
一个原因:我不认为这是“好”。编程,但我们走了:
<强>答案强>
一个班级需要<?php
if( isset( $_GET['view_1'] ) == 'list' ){
echo "This is List view";
}else if( isset($_GET['view_2'] ) == 'grid' ){
echo "This is Grid view";
}
?>
<br>
<a href="?view_1=list">List View</a> <br>
<a href="?view_2=grid">Grid View</a>
在上面:
@JsonIdentityInfo
另一个人需要变量:
@JsonIdentityInfo(generator = ObjectIdGenerators.IntSequenceGenerator.class)
public class Teacher {
// ...
@ManyToOne(optional = false)
@JsonBackReference(value = "teachers")
private School school;