Questions tagged [android-room-relation]

69 questions
1
vote
1 answer

Android Room Subquery unmatched field error

I can't figure out how to bind a subquery select within an attribute of the entity, I simply need to bind the "main_game" subquery into the mainGame String attribute of my entity: My DAO: @Dao public interface GamesDao { @Query("SELECT *,…
1
vote
1 answer

Android Room `@Relation` to a class with `@Embedded` entities

I have 3 tables A, X, Y. Records of A are defined by pairs of X and Y - in another table AWithXY. I can model A the way I receive list of X or Y in a list like below: data class AWithXY( @Embedded val a: A, @Relation( parentColumn =…
Luke
  • 2,539
  • 2
  • 23
  • 40
1
vote
1 answer

Parameter specified as non-null is null exception with Room Relations

I've defined a model that represents a meeting, with a menu and a workout plan. The menu has a list of courses, each of which has a list of meals, and the workout plan has a list of exercises. [ { "menu": { "courses": [ { …
DaniLiat
  • 45
  • 5
1
vote
1 answer

How to avoid duplicate data in roomdatabase?

I am creating an app for my students. I am a teacher and hobby developer. Therefore, I need help. With three fragments, I successively create the name of the class, and the data of the student(first Name, last Name,..) then I attribute evaluation…
1
vote
1 answer

Android Room Relations get limited fields from embedded model

I have a model like that class UserWithPets { @Embedded var user: User? = null @Relation( parentColumn = "id", entityColumn = "userId" ) var pets: List = ArrayList() } with models data class User( val…
Guigui
  • 127
  • 2
  • 8
1
vote
1 answer

One to many relationship in Room Database

There is an event in my project and there are timelines in this event. Each event has its own timelines. I want to list the timelines of each event with the codes I have written, but I cannot access it via the adapter. My…
user11143033
1
vote
2 answers

POJO within POJO, Entity-Relation problem

I have five tables in my database: AREA, AREA_TYPE, SAMPLE, PACK, UNIT @Entity(tableName = "AREA") data class AreaEntity( @PrimaryKey val id:String, val title:String, @ColumnInfo(name = "area_type_id") val…
1
vote
0 answers

Room relational query method with paging

In Room 2.4, there is a new feature called relational query method in DAO which you can write your custom query to select columns from 2 entities and Room can be able to aggregate into Map> return type. I have a fairly…
Eric Li
  • 143
  • 1
  • 8
1
vote
2 answers

Best way to deserialize Json with nested objects into Android Room Entity with ForeignKeys

I have a Client api. The json response looks like this: { "clientId": 1, "createdAt": null, "updatedAt": null, "monthlyPaymentAmount": null, "person": { // Omitted data here }, "paymentType": { // Omitted…
1
vote
0 answers

Android Room + AutoValue breaks schema generation

I have a rather complicated (though not entirely unusual) scenario that seems to break with Android Room version 2.4.0 (specifically 2.4.0-beta01. It works on 2.4.0-alpha05). I'll put the code down below, but I'll attempt to describe my situation in…
skywalkerdude
  • 117
  • 1
  • 8
1
vote
1 answer

Android Room belongsTo (one to one) relationship

Let's say I have an Article table like this: Article { id; title; content; main_reference_id; secondary_reference_id; } And there is a Reference table somewhat like this: Reference { id; …
Riajul
  • 1,140
  • 15
  • 20
1
vote
1 answer

triple join in room database using room relation

I need to triple join my entities using @relation anotion in room, but I don't know how. here is my summary of entities: @Entity(tableName = "session_table") data class Session( @PrimaryKey(autoGenerate = true) var sessionId: Long = 0L, …
1
vote
1 answer

Room SELECT Query for 1-n hashmap relationship

I have the following ORM model: Basically I want to track all public facilities of a state. So I have 1-n Relationship with a public facility like e.g. school: public class StateWithFacilities { @Embedded State state; @Relation(entity…
1
vote
1 answer

Efficient way for Inheritance Table schemes

I'm planning to display an listview of CarServiceEntries. The CarServiceEntry class contains basic data of a service: @Entity abstract class CarServiceEntry( private int id; private Date date; private float odometer; /* …
igodie
  • 497
  • 1
  • 4
  • 16
1
vote
1 answer

How to insert, update and delete a many-to-many relationship in android room?

Following the Android documentation for many-to-many relations, found here: Define many-to-many relationships I have the following entities @Entity class Song( @PrimaryKey val songId: Long, @ColumnInfo val name: String, @ColumnInfo val…