0

I'm trying to setup a Dao that enables partial updates for a table in Java using the following example:

Partial Updates got added to Room in 2.2.0

In Dao you do the following:

// Here you specify the target entity
@Update(entity = Foo::class)
fun update(partialFoo: PartialFoo)

And along your entity Foo create a PartialFoo containing the primary key and the fields you want to update.

@Entity 
class PartialFoo {
    @ColumnInfo(name = "id")
    val id: Long,

    @ColumnInfo(name = "thing1")
    val instructions: String,
}

The above was taken from here: https://stackoverflow.com/a/64388012/14664018 which is in Kotlin. How can I accomplish this in Java? What does partialFoo: PartialFoo mean?

AtomicallyBeyond
  • 348
  • 1
  • 15

1 Answers1

0

In Dao you do the following:

// Here you specify the target entity
@Update(entity = Foo::class)
void update(entity = PartialFoo.class)

And along your entity Foo create a PartialFoo containing the primary key and the fields you want to update.

@Entity 
class PartialFoo {
    @ColumnInfo(name = "id")
    private Long id;

    @ColumnInfo(name = "thing1")
    private String instructions;
}
AtomicallyBeyond
  • 348
  • 1
  • 15