how to join two table in odata4j

44 views Asked by At

I want to fetch data from two tables, Employee and Education, in odata4j. The common column is EmployeeId.

How can I join the tables? I use this for fetching data but it takes more time then expected.

private void DataListPosition() {

    new AsyncTask<Void, Void, Void>() {
        @Override
        protected Void doInBackground(Void... voids) {
            try {
                ConnectionOData4j connectionClass = new ConnectionOData4j(context);
                ODataConsumer consumer = connectionClass.getConnection();

                for(OEntity entity : consumer.getEntities("Employee").execute()){

                    final String name=entity.getProperty("Name" , String.class).getValue();

                    ((Activity) context).runOnUiThread(new Runnable() {
                        public void run() {

                          EmployeeName=name;

                        }
                    });
                }

            }catch (Exception e) {
                final String strError=e.getMessage();
                ((Activity)context).runOnUiThread(new Runnable() {
                    public void run() {

                        Toast.makeText(context, strError, Toast.LENGTH_LONG).show();

                    }
                });
            }

            return null;
        }
    }.execute();


}
private void DataListEducation() {

    new AsyncTask<Void, Void, Void>() {
        @Override
        protected Void doInBackground(Void... voids) {
            try {
                ConnectionOData4j connectionClass = new ConnectionOData4j(context);
                ODataConsumer consumer = connectionClass.getConnection();


                for(OEntity entity : consumer.getEntities("Education").execute()){

                    final String education=entity.getProperty("Education" , String.class).getValue();

                    ((Activity) context).runOnUiThread(new Runnable() {
                        public void run() {
                        EmployeeEducation=education;

                        }
                    });
                }

            }catch (Exception e) {
                final String strError=e.getMessage();
                ((Activity)context).runOnUiThread(new Runnable() {
                    public void run() {

                        Toast.makeText(context, strError, Toast.LENGTH_LONG).show();

                    }
                });
            }

            return null;
        }
    }.execute();


}
0

There are 0 answers