Using @JoinColumn instead of @Column with @ManyToOne in BaseOpenmrsData

In BaseOpenmrsData, the fields voidedBy and changedBy are annotated with @ManyToOne followed by @Column

AFAIK @Column cannot be used with @ManyToOne and should be replaced by @JoinColumn.

I noticed the exception when building the OAuth2 module with OpenMRS Platform 1.11.4 which has similar BaseOpenmrsData class. I got the following exception : org.hibernate.AnnotationException: @Column(s) not allowed on a @ManyToOne property: org.openmrs.module.oauth2.Client.changedBy (p.s Client is a subclass of BaseOpenmrsData) Here is a StackOverflow post on the issue :

On replacing @Column with @JoinColumn in core, the problem was fixed. I can create a ticket and provide the patch if I get the green flag from the developer community

3 Likes

Good catch. Please do send a pull request to fix that.

1 Like