Questions tagged [android-room-relation]
69 questions
8
votes
0 answers
@Relation Room DB with multiple columns
If i want to related 2 tables and the relation is not only one column but more, is there a way to use the Room @Relation annotation with more arguments to achive that? Perhaps somehting like below
@Relation(parentColumn = "{message_id,account_id}",…

james04
- 1,580
- 2
- 20
- 46
5
votes
0 answers
Android Room: apply multiple columns in relation of embedded object
In my Android App I am using Room for data storage. I am currently facing the problem, that I need to put 2 columns in my @Relation of the embedded object because the relation depends on 2 columns. See below the structure:
@Entity(tableName =…

Felix H
- 155
- 1
- 2
- 10
4
votes
1 answer
Android Room - Many to Many Relation with additional field
I have a Many to Many relationship set up on my Room database denoted by the following diagram:
I want to add extra field to "CrossRef" table. My question is how do I go about having DateWithSteaks get this "isCompleted" variable from "CrossRef"…

Кирилл Химов
- 335
- 3
- 9
3
votes
2 answers
Android Room getting count of elements in an 'incoming foreign key list' in an 'embedded entity'?
I have 2 Entities, Grade and Student, Student is having a foreign key towards the class room. Embedded entity ClassRoom looks like this,
data class ClassRoom(
@Embedded
val level: ClassLevel
@Relation(
parentColumn = "id",
…
user3348051
2
votes
1 answer
Delete All Values in One to Many Relationship Room Kotlin
I want to delete all values inside one to many relationship
Parent Table :
@Entity(tableName = "Product")
data class Products (
@PrimaryKey(autoGenerate = false)
@ColumnInfo(name = "id") var id : Int = 0,
@ColumnInfo(name = "name")
…

SasidharanIOS
- 252
- 1
- 3
- 12
2
votes
2 answers
What should we do for nested objects in Room?
If there is a structure like my JSON structure below, how should we create Entity Classes? There are no examples of this. While @embeded was used for inner arrays in the articles written long ago, now a structure like converter is used. Which one…
user17115124
2
votes
1 answer
Room Android ignores @Query conditions in Dao class (Strange)
I am posting this because same issue is already there on stackoverflow but no solution on this. I am using Room library for db operations. I have created data classes with @Embedded and @Relation with other tables. Now the issue is when I put join…

TechHelper
- 822
- 10
- 24
2
votes
1 answer
Delete old table and create new one and prepopulate it - RoomDatabase
I am creating a simple android application in android studio with java.
I have a roomdatabase db with a table named user that has four columns
name, profession, age, description and I have prepopulated using a database that i made in sqlite…

nCoder
- 53
- 5
2
votes
1 answer
Many To Many Relationship (IDs in complex data) Android Room
I want to achieve a many to many relationship with this tow data classes Member and Team since the team can have several members and the member can be in several teams
The Member Class have a reference to the teams IDs as a key in Map
data class…

Hussien Fahmy
- 1,119
- 6
- 24
2
votes
2 answers
Query one to many relationship Android Room
I have a one to many relationship. One Parent can hold many Child entities.
The children have the property date, which is of type Instant.
I have made a class which combines these two entities:
data class Combined(
@Embedded val parent: Parent,
…

shko
- 64
- 2
- 20
2
votes
0 answers
Room @Relation with nested dynamic WHERE clause
Suppose I have items which can each have many categories:
@Entity(tableName = "items")
data class Item(
@PrimaryKey val item_id: Long,
val external_id: String,
val name: String,
val price: Long,
val image:…

Daniel Wilson
- 18,838
- 12
- 85
- 135
2
votes
0 answers
How to access columns of child entity with query while using room relation?
I have two entity order and customer. Each order is associated with zero or single customer and each customer is associated with zero or many orders.
@Entity
public class Order {
@PrimaryKey(autoGenerate = true)
public long id;
public…

Patriotic
- 2,103
- 4
- 26
- 36
2
votes
0 answers
Android room @Relation left join
Let's say I have two entities, question and answer which have a one-to-many relation, for each question there could be 0..n answers. They are defined as:
@Entity(tableName="questions")
data class Question (
@PrimaryKey
val id: Long,
val…

oitantksi
- 21
- 1
- 2
2
votes
1 answer
Android Room Embedded Relation ignores where condition
I have a somewhat complex set of tables with @Relations. Here is my first table:
@Entity(tableName = "commodity")
class Commodity(@NotNull @PrimaryKey val id : String,
val __typename : String,
val name : String,
…

Kristy Welsh
- 7,828
- 12
- 64
- 106
1
vote
1 answer
Android Room one to many relation data class throw's error "Entities cannot have relations"
Disclaimer: I'm a complete beginner to Android development in Kotlin and just started some weeks ago.
My goal is to create an Quiz App which gets it's Questions and Answers from a local, prepopulated Room database.
SQLITE:
The sqlite database has…

Duffischer
- 11
- 1