[CORDA-1297] Columns nullability (#3112)

JPA/Hibernate entities need to impose the correct NULL/NOT NULL constraints on the database - whatever these correct values actually are.
API change: net.corda.core.schemas.PersistentStateRef fields (index and txId) are now non-nullable. Rationale: The fields were always effectively non-nullable - values were set from non-nullable fields of other objects. The class is used in context of database table Primary Key of for other entities and a database already imposes those columns as non-nullable (even if JPA annotation nullable=false was absent).
This commit is contained in:
Maksymilian Pawlak
2018-05-25 18:03:24 +01:00
committed by szymonsztuka
parent 380ab22917
commit 7d69bc664a
34 changed files with 175 additions and 137 deletions

View File

@ -31,7 +31,7 @@ object DummyLinearStateSchemaV1 : MappedSchema(schemaFamily = DummyLinearStateSc
/**
* UniqueIdentifier
*/
@Column(name = "external_id")
@Column(name = "external_id", nullable = true)
var externalId: String?,
@Column(name = "uuid", nullable = false)
@ -41,16 +41,16 @@ object DummyLinearStateSchemaV1 : MappedSchema(schemaFamily = DummyLinearStateSc
/**
* Dummy attributes
*/
@Column(name = "linear_string")
@Column(name = "linear_string", nullable = false)
var linearString: String,
@Column(name = "linear_number")
@Column(name = "linear_number", nullable = false)
var linearNumber: Long,
@Column(name = "linear_timestamp")
@Column(name = "linear_timestamp", nullable = false)
var linearTimestamp: Instant,
@Column(name = "linear_boolean")
@Column(name = "linear_boolean", nullable = false)
var linearBoolean: Boolean
) : PersistentState()
}

View File

@ -21,13 +21,13 @@ object DummyLinearStateSchemaV2 : MappedSchema(schemaFamily = DummyLinearStateSc
@CollectionTable(name = "dummy_linear_states_v2_parts", joinColumns = [(JoinColumn(name = "output_index", referencedColumnName = "output_index")), (JoinColumn(name = "transaction_id", referencedColumnName = "transaction_id"))])
override var participants: MutableSet<AbstractParty>? = null,
@Column(name = "linear_string") var linearString: String,
@Column(name = "linear_string", nullable = false) var linearString: String,
@Column(name = "linear_number") var linearNumber: Long,
@Column(name = "linear_number", nullable = false) var linearNumber: Long,
@Column(name = "linear_timestamp") var linearTimestamp: java.time.Instant,
@Column(name = "linear_timestamp", nullable = false) var linearTimestamp: java.time.Instant,
@Column(name = "linear_boolean") var linearBoolean: Boolean,
@Column(name = "linear_boolean", nullable = false) var linearBoolean: Boolean,
@Transient
val uid: UniqueIdentifier