0
私はCrudRepository
に2つのエンティティを持っています。スプリングデータエンティティ:再帰を停止
機械エンティティ
_machine_id || name || description
特性実体
characteristic_id || machine_id || name || description || type || value
JSON:
[{"name":"CNC","description":"Metallverarbeitung","characteristics":[{"name":"Final Piping Connections","description":"Final Piping Connections","type":0,"value":0,"machine":{"name":"Marvins Maschine","description":"Bizeps","characteristics":[{"name":"Final Piping Connections","description":"Final Piping Connections","type":0,"value":0,"machine":{"name":"Marvins Maschine","description":"Bizeps","characteristics":[{"name":"Final Piping Connections","description":"Final Piping Connections","type":0,"value":0,"machine":{"name":"Marvins Maschine","description":"Bizeps","characteristics":[{"name":"Final Piping Connections","description":"Final Piping Connections","type":0,"value":0,"machine":{"name":"Marvins Maschine","description":"Bizeps","characteristics":[{"name":"Final Piping Connections","description":"Final Piping Connections","type":0,"value":0,"machine":{"name":"Marvins Maschine","description":"Bizeps","characteristics":[{"name":"Final Piping Connections","description":"Final Piping Connections","type":0,"value":0,"machine":{"name":"Marvins Maschine","description":"Bizeps","characteristics":[{"name":"Final Piping Connections","description":"Final Piping Connections","type":0,"value":0,"machine":{"name":"Marvins Maschine","description":"Bizeps","characteristics":[{"name":"Final Piping Connections","description":"Final Piping Connections","type":0,"value":0,"machine":{"name":"Marvins Maschine","description":"Bizeps","characteristics":[{"name":"Final Piping Connections","description":"Final Piping Connections","type":0,"value":0,"machine":{"name":"Marvins Maschine","description":"Bizeps","characteristics":[{"name":"Final Piping Connections","description":"Final Piping Connections","type":0,"value":0,"machine":{"name":"Marvins Maschine","description":"Bizeps","characteristics":
質問:なぜ再帰があるとどのように私はそれを生成することを防ぐことができますか?
マシン
@Entity
public class Machine {
private int machine_id;
private String name;
private String description;
private Set<Characteristic> characteristics;
@OneToMany(fetch = FetchType.EAGER, mappedBy = "machine", cascade = CascadeType.ALL)
public Set<Characteristic> getCharacteristics() {
return characteristics;
}
public void setCharacteristics(Set<Characteristic> characteristics){
this.characteristics = characteristics;
}
public Machine(){}
public Machine(String name, String description){
this.name = name;
this.description = description;
}
@Override
public String toString() {
return "Machine [id=" + machine_id + ", name=" + name + ", description=" + description + "]";
}
@Id
@GeneratedValue
public int getId() {
return machine_id;
}
public void setId(int machine_id) {
this.machine_id = machine_id;
}
@Column
public String getName() {
return name;
}
public void setName(String name) {
this.name = name;
}
@Column
public String getDescription() {
return description;
}
public void setDescription(String description) {
this.description = description;
}
}
特性
@Entity
public class Characteristic {
private int characteristic_id;
private String name;
private String description;
private int type;
private int value;
private Machine machine;
@ManyToOne
@JoinColumn(name="machine_id")
public Machine getMachine(){
return machine;
}
public void setMachine(Machine machine){
this.machine = machine;
}
public Characteristic() {}
@Id
@GeneratedValue
public int getId() {
return characteristic_id;
}
public void setId(int characteristic_id) {
this.characteristic_id = characteristic_id;
}
@Column
public String getName() {
return name;
}
public void setName(String name) {
this.name = name;
}
@Column
public String getDescription() {
return description;
}
public void setDescription(String description) {
this.description = description;
}
@Column
public int getType() {
return type;
}
public void setType(int type) {
this.type = type;
}
@Column
public int getValue() {
return value;
}
public void setValue(int value) {
this.value = value;
}
@Override
public String toString() {
return "Characteristic [id=" + characteristic_id + ", name=" + name + ", description=" + description + ", type=" + type
+ ", value=" + value + "]";
}
}