A
A
Arslanali2016-08-02 10:01:13
Android
Arslanali, 2016-08-02 10:01:13

GreenDao join, now to select some columns?

Hello colleagues.
There is a raw request to the database:

select sn.[NEWSPAPER_MNEMONIK_NAME],
         sh.[NUMBER_PUBLICATION],
         sn.[PERIOD],
         sb.[SUBSCRIBER_NAME],
         sb.[PHONE1]
 from SUBSCRIBER sb, [SHIPPING] sh, [SUBSCRIPTION] sn
 where  sn.[ID_SUBSCRIBER] = sb.[_id]
 and sh.[ID_SUBSCRIPTION] = sn.[_id]
 and sh.[STATUS_DELIVERY] = '0' -- (или '1' - доставлено)

I want to perform a similar query in GreenDao displaying the declared fields.
I do so.
QueryBuilder<Shipping> qb = shippingDao.queryBuilder()
                .where(ShippingDao.Properties.Status_delivery.eq(0));

        Join subscriptionJoin = qb.
                join(ShippingDao.Properties.Id_subscription, Subscription.class);

        Join subscriberJoin = qb.
                join(subscriptionJoin,
                        SubscriptionDao.Properties.Id_subscriber,
                        Subscriber.class, SubscriberDao.Properties.Id);

        List<Shipping> bigEuropeanCities = qb.list();


        for(Shipping e :bigEuropeanCities) {

            Log.d("LOG_TAG", e.getId_shipping().toString());
        }

Not exactly what you need.

Answer the question

In order to leave comments, you need to log in

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question