Dismiss
Announcing Stack Overflow Documentation

We started with Q&A. Technical documentation is next, and we need your help.

Whether you're a beginner or an experienced developer, you can contribute.

Sign up and start helping → Learn more about Documentation →

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(){

        }
    }
share|improve this question

Your Answer

 
discard

By posting your answer, you agree to the privacy policy and terms of service.

Browse other questions tagged or ask your own question.