userAG
userAG

Reputation: 99

How to mention the primary key of H2 database table in a cordapp

I am following the cordapp example code and created IOUs. Can anyone please let me know where can I see the primary key of its H2 database ? How Can I update to have a composite key ?

Upvotes: 0

Views: 112

Answers (1)

Joel
Joel

Reputation: 23140

The database schema for IOUState is defined here: https://github.com/corda/cordapp-example/blob/release-V3/kotlin-source/src/main/kotlin/com/example/schema/IOUSchema.kt.

All state schemas must subclass PersistentState. PersistentState sets the state table's primary key to a composite key which is an instance of PersistentStateRef. PersistentStateRef combines:

  • The hash of the transaction that generated the state
  • The state's index in the outputs of that transaction

As of Corda 3, you cannot change the state's table to use a different primary key.

Upvotes: 1

Related Questions