does not have any one-to-many relations

Hi. I wrote some tests for and I saw that Program extend BaseOpenmrsMetadata which have a field creator which is type User.class and this field has a many-to-one annotation. Program.hbm.xml also has a field many-to-one which links program to an user but User doesn’t seem to have any one-to-many in it or in parent classes. As far as I know this should be a bidirectional relation and User should have a list of BaseOpenmrsMetadata or something like that. Is this a bug?

BaseOpenmrsMetadata creator field:


@alinmihaila99 i think the reason as to why the Program.hbm.xml has a bi-directional many-to-one associations to User and yet the User.hbm.xml doesn’t return the same favor in its hbm.xml bi-directional mappings is because a User in openmrs is a any person who has been authenticated in the system who may be under a program at a particular or not, so i think having a bi-directional mapping of a program in a User hbm.xml mapping would be abit unfair :cowboy_hat_face:


I think he ask where is the references to the programs in the user. Like a one to many on a list of programs.

What @gcliff said here is right. Not all users belong to programs, nor, apparently, has there been a need to use a property like this to get the programs associated to a user. Not all mappings need to be bi-directional. So, unless there’s a use-case for this, it’s best not to maintain an addition mapping.

1 Like