Questions tagged [android-room-relation]
69 questions
1
vote
0 answers
Relation vs View
Based on my research we have two way for getting related data from two or more tables.
For example if we have 2 tables like below:
@Entity
public class User {
@PrimaryKey public long userId;
public String name;
public int…

golkarm
- 1,021
- 1
- 11
- 22
1
vote
3 answers
How to get the most recent relation item instead of a list in Android Room
I have a structure as follows:
A Conversation that has one or more Messages.
Conversation and Message are each in their own tables.
I created a ConversationDetailed relation POJO merging the Conversation with a list of its messages.
public class…

Shadow
- 4,168
- 5
- 41
- 72
1
vote
1 answer
How do I pass my Data object to DAO and access all data object properties in Query?
I have simple data object that I want to insert into room database but as I am using auto increment on my primary key I am doing it as below
@Dao
interface T1Dao {
@Query("INSERT INTO tbl_t1(data1, data2) VALUES ( :T1.data1, :T1.data2) ")
fun…

Vishal Pawar
- 4,324
- 4
- 28
- 54
1
vote
2 answers
Room @Relation returning only the first item of the table
I am using Room in Android for my database also I am using @Relation (based on this: https://developer.android.com/reference/android/arch/persistence/room/Relation.html)
to fetch data from the relation entities that are related one-to-many with a…

Marino Arias
- 11
- 6
0
votes
1 answer
Android Room invalid schema only on Lollipop 5.1 SDK 22 with duplicated primaryKeyPosition
I have the following Entity:
@Entity(tableName = "game_regions",
primaryKeys = {"_game", "_region_area"},
foreignKeys = {
@ForeignKey(
entity = GameEntity.class,
…

Nexussim Lements
- 535
- 1
- 15
- 47
0
votes
1 answer
NullPointerException while retrieving data from room
I have 3 entitites (Location, Current and Forecast) with following relationships:
1.) Location - Current (one-one)
2.) Location - Forecast (one-one)
Now to retrieve data from it i wrote a query
@Transaction
@Query(
"SELECT…

Ansh T
- 13
- 3
0
votes
0 answers
Room getter returning null
My task is to implement Kmap solver. I want to store state of the buttons in Room database but i faced with problem. The function getButton() in realization returns me null instead of my data
@ColumnInfo(name = "buttons")
.
I create the row with…

Dmytro Bilash
- 1
- 1
0
votes
1 answer
Room database model changed unexpectedly
For some reason, I started getting this error:
Room cannot verify the data integrity. Looks like you've changed schema but forgot to update the version number. You can simply fix this by increasing the version number.
I did integrate some changed…

AndreiBogdan
- 10,858
- 13
- 58
- 106
0
votes
1 answer
Why my Databaseview name appears as non found in my Dao?
I dont know why but Android Studiodoesnt find my DatabaseView. Even if i install others projects
This is the DatabaseView. Its created in a class called LibroDatos.
package com.example.pruebaexamenroom;
import…
0
votes
1 answer
ROOM database query on primary key field returns an int > 0 from COUNT(*)[etc.] but returned null from SELECT(*)[etc.]
we have a ROOM database with a table containing a Date field and and an amount field. The Date field is the (@NonNull) primary key. An initial query counts the number of records where the date <= an input date. If the first query returns a result >…

mmcclure2257
- 11
- 2
0
votes
1 answer
How to ignore primary key when I insert room database entity
How do I ignore the primary key when I insert some entity?
Room Entity has to have more than 1 primary key.
For example, there is an entity following under.
@Entity(primaryKeys = ["id"], tableName = "someEntity")
data class SomeEntity(
val id:…

Hello World
- 13
- 3
0
votes
2 answers
Update Query in Child Table won't relect in parent table Android Room Kotlin
Parent Table :
@Entity(tableName = "Product")
data class Products (
@PrimaryKey(autoGenerate = false)
@ColumnInfo(name = "id")
var id : Int = 0,
@ColumnInfo(name = "name")
var name : String? = null,
@ColumnInfo(name =…

SasidharanIOS
- 252
- 1
- 3
- 12
0
votes
1 answer
How to improve my Room database architecture?
I am new to databases. I am not a professional developer. I would like your advice. I want to create a database that manages the students in a class. Students belong to only one class. I present to you my model. Can you let me know if this is…

Wowocode
- 23
- 3
0
votes
1 answer
How to observe livedata of nested relation pojo android room
I have the following schema in my application (simplified for ease)
@PrimaryKey(serverId)
data class Server(
val serverId: Long,
val serverDescription: String
)
@PrimaryKey(siteServerId, siteSiteId)
data class Site(
val siteServerId:…

james04
- 1,580
- 2
- 20
- 46
0
votes
0 answers
Room query returns list instead of map
I have a table Messages (PrimaryKey messageId) and a table ReadUpdates. Each message has many ReadUpdates that are related with
I want to query the Room Database with the below sql, and get a Map with key=Message and value=List
@Query(
"""
…

james04
- 1,580
- 2
- 20
- 46