dimanche 5 juillet 2015

How to get response Entety with List?

I have Object which has attribute: List<Node> nodeChild; When I return response: return new ResponseEntity<>(myObject, HttpStatus.OK); In browser I get json with all attributes , but without list nodeChild inside myObject .

Entety:

@Entity
@javax.persistence.Table(name="node")
public class Node implements Serializable {

@Id
@GeneratedValue
@Column(name="id_node")
protected int id_node;
@ManyToOne
@JoinColumn(name="id_parent")
protected Node id_parent;

@Column(name="node_name")
protected String node_name;

@JsonBackReference
@OneToMany(fetch = FetchType.EAGER,mappedBy = "id_parent",cascade =     CascadeType.ALL)
protected List<Node> nodeChild;

This is what I got:

{"id_node":2,"id_parent":{"id_node":1,"id_parent":null,"node_name":null},"node_name":null}

In java when I try before return response ... myObject.getNodeChild(); I got the list.

Aucun commentaire:

Enregistrer un commentaire