We're updating the issue view to help you get more done. 

Corda's JPA classes should not be final or have final methods

Description

The JEE7 specification stipulates the following for @Entity and @Embeddable objects (and presumably @MappedSuperclass ones too):

  1. The class must be annotated with the javax.persistence.Entity annotation.

  2. The class must have a public or protected, no-argument constructor. The class may have other constructors.

  3. The class must not be declared final. No methods or persistent instance variables must be declared final.

  4. If an entity instance is passed by value as a detached object, such as through a session bean's remote business interface, the class must implement the Serializable interface.

However, the net.corda.core.schemas.PersistentStateRef class and both entities in net.corda.finance.schemas are declared as final, as are almost all of their methods. Similarly, while net.corda.core.schemas.PersistentState, net.corda.core.schemas.CommonSchemaV1$LinearState and net.corda.core.schemas.CommonSchemaV1$FungibleState are not final, most of their methods are. This means that JPA cannot create proxies for any of these classes.

The solution is to apply the kotlin-allopen plugin to the core and finance modules.

1 2 3 4 5 6 7 8 9 apply plugin: 'kotlin-allopen' allOpen { annotations( "javax.persistence.Entity", "javax.persistence.Embeddable", "javax.persistence.MappedSuperclass" ) }

To be fair, we should probably also ask whether these classes should implement java.io.Serializable as well.

Status

Assignee

Michele Sollecito

Reporter

Chris Rankin

Priority

Medium

Labels

None

Severity

None

Fix versions

Ported to...

None

Feature Team

Data / Deployment

Sprint

None