Hello, all.
I am working on a CDS core module for OpenMRS. One functionality is to query a series of events when CDS was utilized and to serve them in JSON through a controller. My data model is shown in the following image. Basically, the table cdss_usage
stores the events where cds was utilized. The table cdss_usage_recommendation
stores each recommendation the the cds has provided. There is a many-to-one foreign key from cdss_usage_recommendation
to cdss_usage
. The intended stuctures is such that a cdss_usage
can have many cdss_usage_recommendation
, but cdss_usage_recommendation
can only have one ```cdss_usage``.
When I model this relationship in JPA, shown in the corresponding image. I set the @OneToMany
and @JsonManagedReference
on the recommendations field in CdssUsage
and JsonBackReference
, @ManyToOne
and @JoinColumn
on the usage field in CdssUsageRecommendation
.
However, when I request the CdssUsage
through a controller, the retriever enters an infinite recursive loop and does not return the proper representation of the usage.
Unless, I am missing something, I believe I modeled the entities correctly. Does anyone have an idea what is going wrong?
Thanks.