Empresas
Empleos
  • Sobre nosotros
  • Soluciones
    • Publicación de vacantes
      Publica tu vacante y recibe candidatos calificados en 48h.
    • Evaluación de candidatos
      500+ pruebas técnicas y psicológicas, más anti-fraude.
    • Headhunting
      Búsqueda ejecutiva a la medida de principio a fin.
    • Nómina + EOR
      Dispersión de nómina y EOR en más de 15 países de LATAM.
  • Precios
  • Empleos

0

320
Vistas
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 Respuestas
Responde la pregunta

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 Denunciar
Responde la pregunta
Encuentra empleos remotos

¡Descubre la nueva forma de encontrar empleo!

Top de empleos
Top categorías de empleo
Empresas
Publicar vacante Precios Comercial
Legal
Términos y condiciones Política de privacidad
© 2026 PeakU Inc. All Rights Reserved.
Andres GPT
Recomiéndame algunas ofertas
Necesito ayuda