In my project spring I have a relation OneToMany with two classes Table and Item
and in my app angular2
I have two interfaces like that export interface
Table{
id: number;
type: string;
items: Item[];
}
export interface Item{
id:number;
type: string;
position:number;
value: string;
}
so when I want that when I get My table object I want to have a possibility that in my html page I can browse all elements (Items) in this page just with Table object without do another request to get Items using ID of current Table
when I log my object Table after getting it from database
I get as value of items = null;
this is my classes in server side
@Entity
@Data
public class Item{
@Id
@GeneratedValue(strategy = GenerationType.IDENTITY)
private Long id;
private String type;
@ManyToOne
private Table table;
String value;
int position;
public Item() {
}
}
@Entity
@Data
public class Table{
@Id
@GeneratedValue(strategy = GenerationType.IDENTITY)
private Long id;
String type;
@OneToMany(mappedBy = "table")
private List<Item> items;
public Table(){
}
}