Business
Jobs
  • About Us
  • Solutions
    • Job Postings
      Post your job and receive qualified candidates in 48h.
    • Candidate Assessments
      500+ technical and psychological tests, plus anti-fraud.
    • Headhunting
      Tailor-made executive search from start to finish.
    • Payroll + EOR
      Payroll dispersal and EOR across 15+ LATAM countries.
  • Pricing
  • Jobs

0

323
Views
Android Room Allow Dao @Query to populate @Ignore columns

I'm wanting my Dao to populate @Ignore columns in my Entity class. For example:

Entity

@Entity(tableName = "example")
data class Example(
    @PrimaryKey
    val id: Long,
    val value: Int
) {
    @Ignore
    var nextId: Long = 0L
}

Dao

@Dao
interface ExampleDao {
    @Query(value = "SELECT *, (id + 1) AS nextId FROM example")
    fun getAllExamples(): List<Example>
}

However, when the application gets built, the following warning gets produced: The query returns some columns [nextId] which are not used by com.example.app.Example and it doesn't populate nextId.

Is it possible to include @Ignore columns in a @Query (if so, how)? If not, what are some strategies that can be employed to populate columns that are not present in my tables into my Entity class.

Note: I'm fully aware with the example provided that I can simply do something like:

@Ignore
val nextId: Long = id + 1

But is not the point of the question I am asking.

over 4 years ago · Santiago Trujillo
1 answers
Answer question

0

Based on the information that @CommonsWare has given me, the solution that I went with is

data class ExampleWithNextId(
    @Embedded
    val example: Example) {
    var nextId: Long = 0L
}

Then use it in Dao like so

@Dao
interface ExampleDao {
    @Query(value = "SELECT *, (id + 1) AS nextId FROM example")
    fun getAllExamplesWithNextId(): List<ExampleWithNextId>
}
over 4 years ago · Santiago Trujillo Report
Answer question
Find remote jobs

Discover the new way to find a job!

Top jobs
Top job categories
Business
Post vacancy Pricing Sales
Legal
Terms and conditions Privacy policy
© 2026 PeakU Inc. All Rights Reserved.
Andres GPT
Show me some job opportunities
There's an error!