-2

Raw query:

SELECT * FROM SAVED_JOB2 S, JOB J WHERE J._id=S._id ORDER BY DATE_SAVED DESC

How can I achieve sort for column in JOIN table. I have tried:

QueryBuilder<Job> queryBuilder = daoSession.queryBuilder(Job.class);
queryBuilder.join(JobDao.Properties.Id, SavedJob2.class, SavedJob2Dao.Properties.Id);
List<Job> list = queryBuilder1.list();

This normal JOIN works perfect. But I need to sort for date_saved column in table SavedJob.

I tried to add this line:

queryBuilder.orderDesc(SavedJob2Dao.Properties.date_saved);

But this line returns this error:

Property 'date_saved' is not part of com.xxx.xxx.db.JobDao

Table JobDao: 
id (PK)
title
description
requirements
allowance
type
status

Table SavedJobDao:
id (PK autoincrement)
j_id (FK to JabDao)
date_saved
status
Zarul Izham
  • 569
  • 5
  • 17

1 Answers1

0

You don't need to do any JOIN with greenDao. It works with objects, so in your savedJob you should have an object Job instead job_id.

So you can order by date_saved, but searching in savedJob only, you don't need either JOIN.

There are a lot of examples. And the official doc is awesome!.

oskarko
  • 3,382
  • 1
  • 26
  • 26