table joining in OData4j

41 views
Skip to first unread message

Israr Ansari

unread,
Dec 5, 2016, 4:35:34 AM12/5/16
to odata4j-discuss

I want to fetch data from two table in odata4j Employee(table) and Education(table),and the common column is EmployeeId. so what should be the code for joining both table.I use below code for fetching data but it take more time then expected.please help



private void DataListEmp;oyee() {

    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();
}



Reply all
Reply to author
Forward
0 new messages