How can I create a new instance of an entity without a primary key?


android enthusiast

Sorry, this is a stupid question. I'm trying to get familiar with Kotlin and have a problem. I have a Kotlin application where I use Room to store data.

Here is my entity class:

@Entity
data class Link(@PrimaryKey(autoGenerate = true) var _id: Int,
        @ColumnInfo(name = "link_url") var linkUrl: String?,
        @ColumnInfo(name = "timestamp") var timestamp: Long?)

How to create a new instance Linkwithout specifying it _id?

which is

var link: Link = Link("url", 12334)

Thank you in advance!

Angelina

You can create another constructor @Ignoreannotated so it will be ignored by Room:

@Ignore
constructor(var linkUrl: String?, timestamp: Long?) : this (null, linkUrl, timestamp)

If you pass nullan auto-generated field, it will automatically generate the new value.

Related


cassandra::Can I create table without primary key?

Renjith VR Right now I'm learning Cassandra , so I got a table without a primary key . But it has some indexes. So here is my doubt, can I create table without primary key? CREATE TABLE subscription (subscriberid varchar,productid varchar,panaccessproductid va

cassandra::Can I create table without primary key?

Renjith VR Right now I'm learning Cassandra , so I got a table without a primary key . But it has some indexes. So here is my doubt, can I create table without primary key? CREATE TABLE subscription (subscriberid varchar,productid varchar,panaccessproductid va

cassandra::Can I create table without primary key?

Renjith VR Right now I'm learning Cassandra , so I got a table without a primary key . But it has some indexes. So here is my doubt, can I create table without primary key? CREATE TABLE subscription (subscriberid varchar,productid varchar,panaccessproductid va

cassandra::Can I create table without primary key?

Renjith VR Right now I'm learning Cassandra , so I got a table without a primary key . But it has some indexes. So here is my doubt, can I create table without primary key? CREATE TABLE subscription (subscriberid varchar,productid varchar,panaccessproductid va

cassandra::Can I create table without primary key?

Renjith VR Right now I'm learning Cassandra , so I got a table without a primary key . But it has some indexes. So here is my doubt, can I create table without primary key? CREATE TABLE subscription (subscriberid varchar,productid varchar,panaccessproductid va

cassandra::Can I create table without primary key?

Renjith VR Right now I'm learning Cassandra , so I got a table without a primary key . But it has some indexes. So here is my doubt, can I create table without primary key? CREATE TABLE subscription (subscriberid varchar,productid varchar,panaccessproductid va

cassandra::Can I create table without primary key?

Renjith VR Right now I'm learning Cassandra , so I got a table without a primary key . But it has some indexes. So here is my doubt, can I create table without primary key? CREATE TABLE subscription (subscriberid varchar,productid varchar,panaccessproductid va

cassandra::Can I create table without primary key?

Renjith VR Right now I'm learning Cassandra , so I got a table without a primary key . But it has some indexes. So here is my doubt, can I create table without primary key? CREATE TABLE subscription (subscriberid varchar,productid varchar,panaccessproductid va

cassandra::Can I create table without primary key?

Renjith VR Right now I'm learning Cassandra , so I got a table without a primary key . But it has some indexes. So here is my doubt, can I create table without primary key? CREATE TABLE subscription (subscriberid varchar,productid varchar,panaccessproductid va

cassandra::Can I create table without primary key?

Renjith VR Right now I'm learning Cassandra , so I got a table without a primary key . But it has some indexes. So here is my doubt, can I create table without primary key? CREATE TABLE subscription (subscriberid varchar,productid varchar,panaccessproductid va

cassandra::Can I create table without primary key?

Renjith VR Right now I'm learning Cassandra , so I got a table without a primary key . But it has some indexes. So here is my doubt, can I create table without primary key? CREATE TABLE subscription (subscriberid varchar,productid varchar,panaccessproductid va

Create new object without primary key angle

Miomir Skivic I have something like this const objectValues = { "A": { "level": "1" }, "B": { "active": "false" }, "TEST": { "value": "abc", "must": "true" }, "D": { "comma": "false",

Create new object without primary key angle

Miomir Skivic I have something like this const objectValues = { "A": { "level": "1" }, "B": { "active": "false" }, "TEST": { "value": "abc", "must": "true" }, "D": { "comma": "false",